Skip to main content

Module mcp

Module mcp 

Source
Expand description

MCP (Model Context Protocol) client — stdio and HTTP+SSE transport, JSON-RPC 2.0.

Supports the bounded subset needed for tool proxy:

  • initialize / initialized handshake
  • tools/list to discover tools
  • tools/call to invoke them

Also supports:

  • resources/list and resources/read
  • prompts/list and prompts/get

Structs§

ElicitationRequest
MCP elicitation request forwarded to a host (Claude elicitation control).
JsonRpcError
A JSON-RPC 2.0 error object.
JsonRpcRequest
A JSON-RPC 2.0 request.
JsonRpcResponse
A JSON-RPC 2.0 response.
McpClient
An MCP client owns a transport and manages JSON-RPC communication.
McpPrompt
A prompt template exposed by an MCP server.
McpPromptArgument
An argument to an MCP prompt template.
McpPromptMessage
A message in an MCP prompt response.
McpResource
A resource exposed by an MCP server.
McpResourceContent
Content returned from reading an MCP resource.
McpServer
Configuration for a single MCP server.
McpServerConfig
Configuration for a single MCP server in the Claude Code .mcp.json format.
McpTool
A tool that wraps an MCP server tool. Registered with a namespaced name mcp__<server_name>__<tool_name>.
McpToolAnnotations
Optional 2025-03-26 MCP tool annotations that carry hints about the tool’s side-effects. All fields default to false / None.
McpToolRouter
A mapping from tool name prefix to MCP server name.
McpToolSpec
A tool spec as returned by the MCP server’s tools/list.
ServerCapabilities
Capabilities advertised by an MCP server during the initialize handshake.

Enums§

KillOutcome
Result of a graceful process kill.
McpServerTrust
Per-MCP-server trust level. Controls whether annotation hints from a server are believed when classifying side-effects.

Constants§

DEFAULT_KILL_GRACE_PERIOD
Default grace period for MCP subprocess shutdown (5 seconds).
DEFAULT_STDIO_READ_TIMEOUT
Default timeout for reading a single JSON-RPC line from a stdio MCP server. Generous on purpose — real servers can pause briefly during large tool runs without being broken.

Traits§

ElicitationHandler
Handles MCP -32042 UrlElicitationRequired by asking the host.

Functions§

discover_mcp_servers
Discover MCP server configurations from the workspace.
dispatch_request
Dispatch a JSON-RPC request to the appropriate handler.
kill_gracefully
Kill a child process gracefully: send SIGTERM, wait for the grace period, then send SIGKILL if still alive.
load_mcp_config
Load MCP server configurations from a JSON file. Expected format:
new_elicitation_slot
Create an empty elicitation-handler slot.

Type Aliases§

SharedElicitationHandler
Shared slot so the CLI control channel can install a handler after MCP clients are constructed.