symfonic.tools.mcp.protocol¶
protocol ¶
Protocol interface for MCP server connections.
MCPServerConnection is @runtime_checkable so adapters can be validated with isinstance() without requiring explicit inheritance.
MCPServerConnection ¶
Bases: Protocol
Abstract interface for connecting to MCP servers.
Any object that implements list_tools, call_tool, and close
with the correct signatures satisfies this protocol via structural
subtyping — no inheritance required.
Example::
class MyConnection:
async def list_tools(self) -> list[MCPToolDefinition]: ...
async def call_tool(self, tool_name, arguments) -> MCPToolResult: ...
async def close(self) -> None: ...
assert isinstance(MyConnection(), MCPServerConnection)
call_tool
async
¶
Execute a tool on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
Name of the tool to invoke. |
required |
arguments
|
dict[str, Any]
|
Key-value arguments matching the tool's input schema. |
required |
Returns:
| Type | Description |
|---|---|
MCPToolResult
|
MCPToolResult with the server's response content. |
Source code in src/symfonic/tools/mcp/protocol.py
close
async
¶
list_tools
async
¶
Discover available tools from the server.
Returns:
| Type | Description |
|---|---|
list[MCPToolDefinition]
|
List of tool definitions reported by the MCP server. |