Skip to content

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

call_tool(
    tool_name: str, arguments: dict[str, Any]
) -> MCPToolResult

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
async def call_tool(
    self,
    tool_name: str,
    arguments: dict[str, Any],
) -> MCPToolResult:
    """Execute a tool on the server.

    Args:
        tool_name: Name of the tool to invoke.
        arguments: Key-value arguments matching the tool's input schema.

    Returns:
        MCPToolResult with the server's response content.
    """
    ...

close async

close() -> None

Close the connection and release any held resources.

Source code in src/symfonic/tools/mcp/protocol.py
async def close(self) -> None:
    """Close the connection and release any held resources."""
    ...

list_tools async

list_tools() -> list[MCPToolDefinition]

Discover available tools from the server.

Returns:

Type Description
list[MCPToolDefinition]

List of tool definitions reported by the MCP server.

Source code in src/symfonic/tools/mcp/protocol.py
async def list_tools(self) -> list[MCPToolDefinition]:
    """Discover available tools from the server.

    Returns:
        List of tool definitions reported by the MCP server.
    """
    ...