feat(protocols): implement MCP JSON-RPC transport layer

Add complete MCP protocol implementation:
- mcp_types.rs: JSON-RPC types, initialize, tools, resources, prompts
- mcp_transport.rs: Stdio-based transport with split mutexes for stdin/stdout
- McpServerConfig builders for npx/node/python MCP servers
- Full McpClient trait implementation for tools/resources/prompts
- Add McpError variant to ZclawError

Transport supports:
- Starting MCP server processes via Command
- JSON-RPC 2.0 request/response over stdio
- Length-prefixed message framing
- Tool listing and invocation
- Resource listing and reading
- Prompt listing and retrieval

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-24 02:00:10 +08:00
parent d6df52b43f
commit 5a35243fd2
4 changed files with 709 additions and 0 deletions

View File

@@ -3,7 +3,11 @@
//! Protocol support for MCP (Model Context Protocol) and A2A (Agent-to-Agent).
mod mcp;
mod mcp_types;
mod mcp_transport;
mod a2a;
pub use mcp::*;
pub use mcp_types::*;
pub use mcp_transport::*;
pub use a2a::*;