feat: add MCP integration for external tool servers

Implement Model Context Protocol (MCP) support so Flynn can spawn MCP
server processes, discover their tools, and make them available to the
agent alongside builtin tools.

- McpClient: wraps @modelcontextprotocol/sdk with StdioClientTransport
  for process lifecycle, tool discovery (listTools), and invocation (callTool)
- McpManager: lifecycle management for multiple MCP servers with
  startAll/stopAll/restart, tool bridging into ToolRegistry
- Bridge: converts MCP tools to Flynn Tool interface with mcp:<server>:<tool>
  namespacing to avoid collisions with builtin tools
- Config: add env and cwd fields to mcp server schema
- ToolRegistry: add unregister() method for MCP server cleanup
- Daemon: wire McpManager into startup and shutdown lifecycle
- Tests: 28 new tests (bridge, manager, registry unregister)
This commit is contained in:
William Valentin
2026-02-05 20:10:37 -08:00
parent aa95f2132c
commit cd839c7f0c
13 changed files with 1410 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@
},
"dependencies": {
"@anthropic-ai/sdk": "^0.39.0",
"@modelcontextprotocol/sdk": "^1.26.0",
"better-sqlite3": "^11.0.0",
"cli-highlight": "^2.1.11",
"grammy": "^1.35.0",