Tool Call Execution
The execution of an MCP tool call, from its resolved MCPToolCall.
MCPToolkit resolves each call in the app, into an
MCPToolCall, and hands it to the tool runner (smarter.apps.llmtool.runner), which
executes it with execute_mcp_call(). The call carries the MCPClient’s
MCPEndpoint, so nothing here reads the database, and the
same call can run in the app’s process today, or in a worker without credentials (ADR-038).
The executor checks allowed_tools and allowed_resources again, from the endpoint, so a
worker doesn’t trust its caller to have checked them.
- class smarter.apps.mcpclient.execution.MCPToolCall(**data)[source]
Bases:
ToolCallAn MCP tool call, resolved for execution.
- Variables:
endpoint – The MCPClient’s resolved endpoint, credential included.
operation –
toolto call a tool, orread_resourceto read a resource.tool_name – The tool’s name, as the server reports it, for
tool.uri – The resource’s URI, for
read_resource.arguments – The tool’s arguments, from the LLM.
- endpoint: MCPEndpoint
- model_config = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- smarter.apps.mcpclient.execution.MCP_TOOL_CALL_KIND: Final = 'mcp'
The
kindof an MCP tool call, which selectsexecute_mcp_call().
- smarter.apps.mcpclient.execution.READ_RESOURCE: Final = 'read_resource'
The operation that reads one of the server’s resources.
It matches
MCPFunction.kind.
- smarter.apps.mcpclient.execution.TOOL: Final = 'tool'
The operation that calls one of the server’s tools.
It matches
MCPFunction.kind.
- smarter.apps.mcpclient.execution.execute_mcp_call(call)[source]
Execute a resolved MCP tool call: connect, perform the handshake, call the tool or read the resource, and disconnect.
- Parameters:
call (
ToolCall) – The call, anMCPToolCall.- Return type:
- Returns:
The tool’s text, with
is_errorwhen the tool reports an error, or a result with afailurewhen the call couldn’t be made: refused, unreachable, timed out, or not allowed.- Raises:
TypeError – If the call isn’t an
MCPToolCall.