Skip to content

mcp_protocol

Crate: mcp_protocol · Path: crates/mcp_protocol
Description (Cargo.toml): Model Context Protocol (MCP) implementation for PromptFleet - JSON-RPC 2.0 compatible

Standards-compliant MCP implementation for PromptFleet agents. Provides JSON-RPC 2.0 wire format, HTTP/HTTPS transport with OAuth 2.1 Bearer token support, tool discovery (tools/list) and tool execution (tools/call), and interoperability with Python FastMCP and TypeScript MCP SDKs. Built on top of protocol_transport_core.

From crates/mcp_protocol/Cargo.toml:

FeaturePurpose
defaultclient, server, proxy
clientMCP client module
serverMCP server module
proxyConnect to external MCP servers outside Kubernetes
sse-clientDirect SSE client — avoids proxy hop for performance (enables client)
sse-serverDirect SSE server — accepts direct SSE connections (enables server)

Modules: auth, client, error, handler, server, types, proxy (feature-gated).

Key types and traits:

  • McpProtocolHandler — main handler; implements both ProtocolHandler and AsyncProtocolHandler from protocol_transport_core
  • ToolProvider trait — async trait for tool listing and execution (list_tools, call_tool)
  • QueryModeSingle (standard) or Aggregate (multi-provider tool listing)
  • AuthHandler — authentication strategy trait (re-exported from auth)

Re-exports from types: JsonRpcRequest, JsonRpcResponse, JsonRpcError, Tool, CallToolRequest, CallToolResult, Content, InitializeRequest, InitializeResult, ServerCapabilities, ServerInfo, ListToolsResult.

Re-exports from error: MCP error types.

Convenience functions:

  • create_mcp_handler() — quick setup with default capabilities
  • create_mcp_handler_with_capabilities(capabilities) — quick setup with custom capabilities

Constants: MCP_PROTOCOL_VERSION ("2025-06-18"), JSONRPC_VERSION ("2.0").

use mcp_protocol::{McpProtocolHandler, ServerCapabilities, create_mcp_handler};
// Quick setup with defaults
let handler = create_mcp_handler();
// Or with builder pattern
let handler = McpProtocolHandler::new()
.with_capabilities(ServerCapabilities::default())
.with_query_mode(mcp_protocol::QueryMode::Single);

See the MCP guide for end-to-end examples of connecting to external MCP servers.

Full API reference: cargo doc -p mcp_protocol --no-deps --all-features