Engine MCP
Execution-time MCP registries, facades, session handling, schema discovery, and tool calls.
For user-facing provider and tool config objects, see MCP configuration.
Parallel Structure
| Model layer | MCP layer | Purpose |
|---|---|---|
ModelProviderRegistry |
MCPProviderRegistry |
Holds provider configurations. |
ModelRegistry |
MCPRegistry |
Manages configs by alias and lazily creates facades. |
ModelFacade |
MCPFacade |
Provides a lightweight runtime facade scoped to one config. |
ModelConfig.alias |
ToolConfig.tool_alias |
Alias referenced by column configs. |
Registry
MCPToolDefinition
Definition of an MCP tool with its schema.
Methods:
| Name | Description |
|---|---|
to_openai_tool_schema |
Convert this tool definition to OpenAI function calling format. |
to_openai_tool_schema()
Convert this tool definition to OpenAI function calling format.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary in OpenAI's tool schema format with 'type' set to |
dict[str, Any]
|
'function' and nested 'function' containing name, description, |
dict[str, Any]
|
and parameters. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/registry.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
MCPToolResult
Result from executing an MCP tool call.
MCPRegistry
Registry for MCP tool configurations and facades.
MCPRegistry manages ToolConfig instances by tool_alias and lazily creates MCPFacade instances when requested. This is a config-only registry - all actual MCP operations are delegated to the MCPFacade and io module.
This mirrors the ModelRegistry pattern for consistency across the codebase.
Initialize the MCPRegistry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret_resolver
|
SecretResolver
|
Resolver for secrets referenced in provider configs. |
required |
mcp_provider_registry
|
MCPProviderRegistry
|
Registry of MCP provider configurations. |
required |
mcp_facade_factory
|
Callable[[ToolConfig, SecretResolver, MCPProviderRegistry], MCPFacade]
|
Factory for creating MCPFacade instances. |
required |
tool_configs
|
list[ToolConfig] | None
|
Optional list of tool configurations to register. |
None
|
Methods:
| Name | Description |
|---|---|
get_mcp |
Get or lazily create an MCPFacade for the given tool alias. |
get_tool_config |
Get a tool configuration by alias. |
register_tool_configs |
Register tool configurations at runtime. |
validate_no_duplicate_tool_names |
Validate that no ToolConfig has duplicate tool names across its providers. |
Attributes:
| Name | Type | Description |
|---|---|---|
facades |
dict[str, MCPFacade]
|
Get all instantiated facades. |
mcp_provider_registry |
MCPProviderRegistry
|
Get the MCP provider registry. |
tool_configs |
dict[str, ToolConfig]
|
Get all registered tool configurations. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/registry.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
facades
property
Get all instantiated facades.
mcp_provider_registry
property
Get the MCP provider registry.
tool_configs
property
Get all registered tool configurations.
get_mcp(*, tool_alias)
Get or lazily create an MCPFacade for the given tool alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_alias
|
str
|
The alias of the tool configuration. |
required |
Returns:
| Type | Description |
|---|---|
MCPFacade
|
An MCPFacade configured for the specified tool alias. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool config with the given alias is found. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/registry.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
get_tool_config(*, tool_alias)
Get a tool configuration by alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_alias
|
str
|
The alias of the tool configuration. |
required |
Returns:
| Type | Description |
|---|---|
ToolConfig
|
The tool configuration. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool config with the given alias is found. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/registry.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
register_tool_configs(tool_configs)
Register tool configurations at runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_configs
|
list[ToolConfig]
|
List of tool configurations to register. If a configuration with the same alias already exists, it will be overwritten. |
required |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/registry.py
107 108 109 110 111 112 113 114 | |
validate_no_duplicate_tool_names()
Validate that no ToolConfig has duplicate tool names across its providers.
This method eagerly fetches tool schemas for all registered ToolConfigs, which triggers duplicate tool name detection. This catches cases where multiple providers in the same ToolConfig expose a tool with the same name.
Raises:
| Type | Description |
|---|---|
DuplicateToolNameError
|
If any ToolConfig has duplicate tool names across providers. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/registry.py
193 194 195 196 197 198 199 200 201 202 203 204 | |
create_mcp_registry
Factory function for creating an MCPRegistry instance.
This factory function creates an MCPRegistry with a facade factory that creates MCPFacade instances on demand. It follows the same pattern as create_model_registry for consistency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_configs
|
list[ToolConfig] | None
|
Optional list of tool configurations to register. |
None
|
secret_resolver
|
SecretResolver
|
Resolver for secrets referenced in provider configs. |
required |
mcp_provider_registry
|
MCPProviderRegistry
|
Registry of MCP provider configurations. |
required |
Returns:
| Type | Description |
|---|---|
MCPRegistry
|
A configured MCPRegistry instance. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/factory.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
Facade
ModelFacade.generate() accepts a tool_alias parameter. When it is provided, ModelFacade looks up the matching MCPFacade from MCPRegistry, fetches tool schemas, passes them to the model, processes tool calls after each completion, tracks tool-call turns, and returns messages that include tool results for trace capture.
MCPFacade
Lightweight facade scoped to a specific ToolConfig.
MCPFacade provides a clean interface for MCP tool operations within the context of a specific tool configuration. It handles tool call extraction, validation, and execution using the mcp.io module for communication.
This mirrors the ModelFacade pattern where each facade is scoped to a specific configuration while sharing underlying resources through caching in the io module.
Methods:
| Name | Description |
|---|---|
get_tool_call_count |
Count the number of tool calls in a completion response. |
get_tool_schemas |
Get OpenAI-compatible tool schemas for this configuration. |
has_tool_calls |
Returns True if tool calls are present in the completion response. |
process_completion_response |
Process an LLM completion response and execute any tool calls. |
refuse_completion_response |
Refuse tool calls without executing them. |
Attributes:
| Name | Type | Description |
|---|---|---|
allow_tools |
list[str] | None
|
Optional allowlist of permitted tool names. |
max_tool_call_turns |
int
|
Maximum number of tool-calling turns permitted in a single generation. |
providers |
list[str]
|
List of MCP provider names for this configuration. |
timeout_sec |
float | None
|
Timeout in seconds for MCP tool calls. |
tool_alias |
str
|
The alias for this tool configuration. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
35 36 37 38 39 40 41 42 43 | |
allow_tools
property
Optional allowlist of permitted tool names.
max_tool_call_turns
property
Maximum number of tool-calling turns permitted in a single generation.
A turn is one iteration where the LLM requests tool calls. With parallel tool calling, a single turn may execute multiple tools simultaneously.
providers
property
List of MCP provider names for this configuration.
timeout_sec
property
Timeout in seconds for MCP tool calls.
tool_alias
property
The alias for this tool configuration.
get_tool_call_count(completion_response)
staticmethod
Count the number of tool calls in a completion response.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
74 75 76 77 | |
get_tool_schemas()
Get OpenAI-compatible tool schemas for this configuration.
Fetches tools from all providers in the configuration and applies allow_tools filtering if specified. Uses cached results from mcp_io.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of tool schemas in OpenAI function calling format. |
Raises:
| Type | Description |
|---|---|
MCPConfigurationError
|
If allowed tools are not found on any provider. |
DuplicateToolNameError
|
If the same tool name appears in multiple providers. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
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 | |
has_tool_calls(completion_response)
staticmethod
Returns True if tool calls are present in the completion response.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
79 80 81 82 | |
process_completion_response(completion_response)
Process an LLM completion response and execute any tool calls.
This is the primary method for handling tool calls from an LLM response. It extracts the response content, reasoning content, and all tool calls from the completion response, executes each tool call (including parallel tool calls), and returns the messages for continuing the conversation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
completion_response
|
ChatCompletionResponse
|
The canonical ChatCompletionResponse from the model client. |
required |
Returns:
| Type | Description |
|---|---|
list[ChatMessage]
|
A list of ChatMessages to append to the conversation history: |
list[ChatMessage]
|
|
list[ChatMessage]
|
|
Raises:
| Type | Description |
|---|---|
MCPToolError
|
If a requested tool is not in the allowed tools list. |
MCPToolError
|
If tool execution fails or times out. |
MCPConfigurationError
|
If a requested tool is not found on any configured provider. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
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 | |
refuse_completion_response(completion_response, refusal_message=None)
Refuse tool calls without executing them.
Used when the tool call turn budget is exhausted. Returns messages that include the assistant's tool call request but with refusal responses instead of actual tool results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
completion_response
|
ChatCompletionResponse
|
The canonical ChatCompletionResponse containing tool calls. |
required |
refusal_message
|
str | None
|
Optional custom refusal message. |
None
|
Returns:
| Type | Description |
|---|---|
list[ChatMessage]
|
A list of ChatMessages to append to the conversation history. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
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 227 228 229 | |
I/O Service
The I/O service owns a background event loop, pools MCP sessions by provider config, coalesces concurrent tool schema lookups, and executes parallel tool calls.
MCPIOService
Actor-style MCP I/O service owning all async state.
Methods:
| Name | Description |
|---|---|
call_tools |
Call multiple tools in parallel. |
clear_provider_caches |
Clear caches and session pool entries for specific providers. |
clear_session_pool |
Clear all pooled MCP sessions (best effort). |
clear_tools_cache |
Clear the list_tools cache (best effort). |
get_cache_info |
Get cache statistics for list_tools. |
get_session_pool_info |
Get information about the session pool. |
list_tools |
List tools from an MCP provider (cached with request coalescing). |
shutdown |
Shutdown the MCP event loop and close all sessions. |
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
call_tools(calls, *, timeout_sec=None)
Call multiple tools in parallel.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
clear_provider_caches(providers)
Clear caches and session pool entries for specific providers.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
96 97 98 99 100 101 102 103 104 105 106 | |
clear_session_pool()
Clear all pooled MCP sessions (best effort).
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
128 129 130 131 132 133 134 135 136 137 | |
clear_tools_cache()
Clear the list_tools cache (best effort).
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
108 109 110 111 112 113 114 115 116 117 | |
get_cache_info()
Get cache statistics for list_tools.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
119 120 121 122 123 124 125 126 | |
get_session_pool_info()
Get information about the session pool.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
139 140 141 142 143 144 145 146 | |
list_tools(provider, timeout_sec=None)
List tools from an MCP provider (cached with request coalescing).
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
73 74 75 76 77 78 79 | |
shutdown()
Shutdown the MCP event loop and close all sessions.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
Runtime Helpers
List tools from an MCP provider (cached with request coalescing).
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
402 403 404 | |
Return the names of all tools available on an MCP provider.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
407 408 409 | |
Call multiple tools in parallel.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
412 413 414 415 416 417 418 | |
Clear all caches for specific MCP providers.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
421 422 423 | |
Clear the list_tools cache.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
426 427 428 | |
Get cache statistics for list_tools.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
431 432 433 | |
Clear all pooled MCP sessions.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
436 437 438 | |
Get information about the session pool.
Source code in packages/data-designer-engine/src/data_designer/engine/mcp/io.py
441 442 443 | |