mirror of
https://github.com/bitbaum/ai-kit.git
synced 2026-12-04 05:30:38 +01:00
The fleet's products already serve MCP (OrangeCat's and Loki's /api/mcp), and the next thing every one of them wants is to call one: a bot on OrangeCat asking Loki as the person, a product reaching a vendor's server with the person's token. Each would write the same forty lines of JSON-RPC over Streamable HTTP, and each would get one of the two response shapes wrong (a server may answer a POST with JSON or with an SSE stream, per request). So the client lives here, once. @bitbaum/ai-kit/mcp: McpClient (initialize once with the session id carried, tools/list, tools/call, both response shapes read the same way, a tool error as data and a JSON-RPC error as McpError), toolDefinitionsFrom (the server's tools in the shape complete() takes). No OAuth flow, no stdio, no resources or prompts until a caller needs them. Tests against a fake server in both answer shapes, plus the failed-handshake path. Claude-Session: https://claude.ai/code/session_019MDtmrXvMqAqZtbpQ4x3et Co-authored-by: Claude <noreply@anthropic.com>