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
initializehandshake, requests with timeouts, progress and cancellation, server requests (ping,roots/list) and notifications. Port ofclient.tsin pi-mcpv1.0.0. - config
mcp.json: the MCP servers of the agent directory and, for trusted projects, of<project>/.yapi/mcp.json, in themcpServersshape other MCP clients share. Project entries replace global ones of the same name. Port ofextensions/mcp/config.tsandcore/mcp-servers.tsin piv1.0.0.- connection
- One configured server’s connection: lazy connects and reconnects, its
tools and resources, its credentials, and its state for
/mcp. Port ofextensions/mcp/runtime.tsin piv1.0.0. - content
- Tool result content for a model. Port of
toLlmContentinprotocol/content.tsof pi-mcpv1.0.0. - extension
- The built-in MCP extension: connects the servers in
mcp.jsonand those extensions register withpi.registerMcpServerwhen a session starts, and servers registered later right away. A server inmcp.jsontakes precedence over a registered one of the same name. The extension registers tools asmcp__<server>__<tool>. Port ofextensions/mcp/index.tsin piv1.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.tsin pi-mcpv1.0.0. - jsonrpc
- JSON-RPC 2.0 messages as MCP exchanges them, and the client’s errors. Port
of
protocol/jsonrpc.tsin pi-mcpv1.0.0. - log
- Log messages servers send with
notifications/message, appended tomcp.login the agent directory and rotated tomcp.log.1past 5 MB. Port ofextensions/mcp/log.tsin piv1.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-mcpv1.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.tsin piv1.0.0. - stdio
- The stdio transport: a server process speaking newline-delimited JSON-RPC
on stdin and stdout. Port of
transports/stdio.tsin pi-mcpv1.0.0. - tools
- MCP tools as session tools, and the three resource tools. Port of
extensions/mcp/tools.tsandresources.tsin piv1.0.0. - transport
- The two MCP transports behind one type.