code4me2
|
a8027c6386
|
server: add MCP client for JSON-RPC communication
Add core MCP client implementation for communicating with Model Context
Protocol servers over stdio using JSON-RPC 2.0.
MCPClient (server/mcp_client.go):
- JSON-RPC 2.0 client with request/response correlation
- Handles initialize, tools/list, tools/call lifecycle
- Secure environment variable filtering (blocks secrets, sanitizes PATH)
- Request timeouts and graceful shutdown
- Parses MCP tool definitions into Ollama's api.Tool format
- MCPClientOption pattern for dependency injection in tests
API Types (api/types.go):
- MCPServerConfig: Runtime server configuration
- MCPTool: Tool definition with JSON Schema inputSchema
- MCPToolResult: Execution result container
Relates to #7865
|
2025-12-28 15:06:47 -08:00 |