Skip to main content

Module mcp

Module mcp 

Source
Expand description

Model Context Protocol: a client for stdio and streamable HTTP servers (pi-mcp), and the built-in extension that exposes their tools.

Re-exports§

pub use client::ClientOptions;
pub use client::McpClient;
pub use client::RequestOptions;
pub use client::ResourceKind;
pub use client::Root;
pub use client::Tool;
pub use jsonrpc::McpError;
pub use transport::Transport;

Modules§

client
An MCP client over one transport: the initialize handshake, requests with timeouts, progress and cancellation, server requests (ping, roots/list) and notifications. Port of client.ts in pi-mcp v1.0.0.
config
mcp.json: the MCP servers of the agent directory and, for trusted projects, of <project>/.yapi/mcp.json, in the mcpServers shape other MCP clients share. Project entries replace global ones of the same name. Port of extensions/mcp/config.ts and core/mcp-servers.ts in pi v1.0.0.
connection
One configured server’s connection: lazy connects and reconnects, its tools and resources, its credentials, and its state for /mcp. Port of extensions/mcp/runtime.ts in pi v1.0.0.
content
Tool result content for a model. Port of toLlmContent in protocol/content.ts of pi-mcp v1.0.0.
extension
The built-in MCP extension: connects the servers in mcp.json and those extensions register with pi.registerMcpServer when a session starts, and servers registered later right away. A server in mcp.json takes precedence over a registered one of the same name. The extension registers tools as mcp__<server>__<tool>. Port of extensions/mcp/index.ts in pi v1.0.0.
http
The streamable HTTP transport: each message is a POST whose reply is JSON or an event stream, plus a GET stream for messages the server starts. Port of transports/streamable-http.ts in pi-mcp v1.0.0.
jsonrpc
JSON-RPC 2.0 messages as MCP exchanges them, and the client’s errors. Port of protocol/jsonrpc.ts in pi-mcp v1.0.0.
log
Log messages servers send with notifications/message, appended to mcp.log in the agent directory and rotated to mcp.log.1 past 5 MB. Port of extensions/mcp/log.ts in pi v1.0.0.
oauth
OAuth for MCP servers: protected resource and authorization server discovery, dynamic client registration, the authorization code flow with Proof Key for Code Exchange (PKCE), and refresh. Port of oauth/ in pi-mcp v1.0.0, which adapts the MCP TypeScript SDK, limited to what pi’s coding agent uses.
sign_in
OAuth sign-in for remote MCP servers. Port of extensions/mcp/oauth.ts in pi v1.0.0.
stdio
The stdio transport: a server process speaking newline-delimited JSON-RPC on stdin and stdout. Port of transports/stdio.ts in pi-mcp v1.0.0.
tools
MCP tools as session tools, and the three resource tools. Port of extensions/mcp/tools.ts and resources.ts in pi v1.0.0.
transport
The two MCP transports behind one type.