a2a_pack.mcp.server
Core MCP JSON-RPC handler — transport-agnostic.
The handler maps the MCP wire protocol onto an :class:A2AAgent:
initializeadvertises tool support and echoes the server identity from the agent's :class:AgentCard.tools/listenumerates the agent's skills.tools/calldispatches into :meth:A2AAgent.invoke_json.
A transport (stdio, HTTP) calls :meth:MCPServer.handle with each
decoded JSON-RPC message and forwards the returned dict back to the
client. Notifications return None.
MCPServer (class)
MCPServer(agent: 'A2AAgent', *, context_builder: 'ContextBuilder | None' = None) -> 'None'Transport-agnostic MCP request handler for an :class:A2AAgent.
__init__ (method)
__init__(self, agent: 'A2AAgent', *, context_builder: 'ContextBuilder | None' = None) -> 'None'Initialize self. See help(type(self)) for accurate signature.
handle (method)
handle(self, message: 'dict[str, Any]') -> 'dict[str, Any] | None'Dispatch one JSON-RPC message. Returns response or None for notifications.
parse_message (function)
parse_message(raw: 'str | bytes') -> 'dict[str, Any]'Parse a JSON-RPC frame; raises :class:_MCPError with PARSE_ERROR.
skills_to_tools (function)
skills_to_tools(agent: 'A2AAgent') -> 'list[dict[str, Any]]'Render the agent's skills as MCP tool descriptors.
tool_call_error (function)
tool_call_error(message: 'str') -> 'dict[str, Any]'Wrap a tool-side failure as an MCP CallToolResult with isError=true.
tool_call_result (function)
tool_call_result(spec: 'SkillSpec', value: 'Any') -> 'dict[str, Any]'Wrap a skill return value as an MCP CallToolResult.
Source: apps/a2a/a2a_pack/mcp/server.py