datarobot_genai.drmcp.core.mcp_instance
mcp_instance
DataRobotMCP
Bases: FastMCP
Extended FastMCP that supports DataRobot specific features like deployments and prompts.
Source code in datarobot_genai/drmcp/core/mcp_instance.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
get_tools
async
Compat wrapper: fastmcp 3.x renamed get_tools→list_tools and returns a list.
get_prompts
async
Compat wrapper: fastmcp 3.x renamed get_prompts→list_prompts and returns a list.
get_resources
async
Compat wrapper: fastmcp 3.x renamed get_resources→list_resources and returns a list.
notify_prompts_changed
async
Notify connected clients that the prompt list has changed.
This method attempts to send a prompts/list_changed notification to inform clients that they should refresh their prompt list.
Note: In stateless HTTP mode (default for this server), notifications may not reach clients since each request is independent. This method still logs the change for auditing purposes and will work if the server is configured for stateful connections.
See: https://github.com/modelcontextprotocol/python-sdk/issues/710
Source code in datarobot_genai/drmcp/core/mcp_instance.py
get_deployment_mapping
async
Get the list of deployment IDs for all registered dynamic tools.
Returns
Dictionary mapping deployment IDs to tool names.
Source code in datarobot_genai/drmcp/core/mcp_instance.py
set_deployment_mapping
async
Add or update the mapping of a deployment ID to a tool name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment_id
|
str
|
The ID of the deployment. |
required |
tool_name
|
str
|
The name of the tool associated with the deployment. |
required |
Source code in datarobot_genai/drmcp/core/mcp_instance.py
remove_deployment_mapping
async
Remove the mapping of a deployment ID to a tool name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment_id
|
str
|
The ID of the deployment to remove. |
required |
Source code in datarobot_genai/drmcp/core/mcp_instance.py
get_prompt_mapping
async
Get the list of prompt ID for all registered dynamic prompts.
Returns
Dictionary mapping prompt template id to prompt template version id and name
Source code in datarobot_genai/drmcp/core/mcp_instance.py
set_prompt_mapping
async
set_prompt_mapping(prompt_template_id: str, prompt_template_version_id: str, prompt_name: str) -> None
Add or update the mapping of a deployment ID to a tool name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_template_id
|
str
|
The ID of the prompt template. |
required |
prompt_template_version_id
|
str
|
The ID of the prompt template version. |
required |
prompt_name
|
str
|
The prompt name associated with the prompt template id and version. |
required |
Source code in datarobot_genai/drmcp/core/mcp_instance.py
remove_prompt_mapping
async
Remove the mapping of a prompt_template ID to a version and prompt name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_template_id
|
str
|
The ID of the prompt template to remove. |
required |
prompt_template_version_id
|
str
|
The ID of the prompt template version to remove. |
required |
Source code in datarobot_genai/drmcp/core/mcp_instance.py
ToolKwargs
Bases: TypedDict
Keyword arguments passed through to FastMCP's mcp.tool() decorator.
All parameters are optional and forwarded directly to FastMCP tool registration. See FastMCP documentation for full details on each parameter.
Source code in datarobot_genai/drmcp/core/mcp_instance.py
dr_core_mcp_tool
dr_core_mcp_tool(**kwargs: Unpack[ToolKwargs]) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Combine decorator that includes mcp.tool() and dr_mcp_extras().
All keyword arguments are passed through to FastMCP's mcp.tool() decorator. See ToolKwargs for available parameters.
Source code in datarobot_genai/drmcp/core/mcp_instance.py
dr_mcp_tool
dr_mcp_tool(tool_category: DataRobotMCPToolCategory = DataRobotMCPToolCategory.USER_TOOL, **mcp_tool_init_args: Unpack[ToolKwargs]) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Combine decorator that includes mcp.tool() and dr_mcp_extras().
All keyword arguments are passed through to FastMCP's mcp.tool() decorator. See ToolKwargs for available parameters.
Source code in datarobot_genai/drmcp/core/mcp_instance.py
dr_mcp_integration_tool
dr_mcp_integration_tool(**mcp_tool_init_args: Unpack[ToolKwargs]) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Decorate mcp tool created as a wrapper of external service API (e.g., DataRobot Predictive AI, github API).
Source code in datarobot_genai/drmcp/core/mcp_instance.py
dr_mcp_extras
Combine decorator that includes log_execution and trace_execution().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
default is "tool", other options are "prompt", "resource" |
'tool'
|
Source code in datarobot_genai/drmcp/core/mcp_instance.py
register_tools
async
register_tools(fn: AnyFunction, name: str | None = None, title: str | None = None, description: str | None = None, tags: set[str] | None = None, deployment_id: str | None = None, tool_category: DataRobotMCPToolCategory = DataRobotMCPToolCategory.USER_TOOL_DEPLOYMENT) -> Tool
Register new tools after server has started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
AnyFunction
|
The function to register as a tool |
required |
name
|
str | None
|
Optional name for the tool (defaults to function name) |
None
|
title
|
str | None
|
Optional human-readable title for the tool |
None
|
description
|
str | None
|
Optional description of what the tool does |
None
|
tags
|
set[str] | None
|
Optional set of tags to apply to the tool |
None
|
deployment_id
|
str | None
|
Optional deployment ID associated with the tool |
None
|
tool_category
|
DataRobotMCPToolCategory
|
Category of the tool. Its value is from DataRobotMCPToolCategory |
USER_TOOL_DEPLOYMENT
|
Returns
The registered Tool object
Source code in datarobot_genai/drmcp/core/mcp_instance.py
register_prompt
async
register_prompt(fn: AnyFunction, name: str | None = None, title: str | None = None, description: str | None = None, tags: set[str] | None = None, meta: dict[str, Any] | None = None, prompt_template: tuple[str, str] | None = None, prompt_category: DataRobotMCPPromptCategory = DataRobotMCPPromptCategory.USER_PROMPT_TEMPLATE_VERSION) -> Prompt
Register new prompt after server has started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
AnyFunction
|
The function to register as a prompt |
required |
name
|
str | None
|
Optional name for the prompt (defaults to function name) |
None
|
title
|
str | None
|
Optional human-readable title for the prompt |
None
|
description
|
str | None
|
Optional description of what the prompt does |
None
|
tags
|
set[str] | None
|
Optional set of tags to apply to the prompt |
None
|
meta
|
dict[str, Any] | None
|
Optional dict of metadata to apply to the prompt |
None
|
prompt_template
|
tuple[str, str] | None
|
Optional (id, version id) of the prompt template |
None
|
prompt_category
|
DataRobotMCPPromptCategory
|
Category of prompt. Its value is from DataRobotMCPPromptCategory |
USER_PROMPT_TEMPLATE_VERSION
|
Returns
The registered Prompt object