Repository navigation
Conversation
kylecarbs
force-pushed
the
kylecarbs/agents-mcp-servers
branch
5 times, most recently
from
March 16, 2026 16:57
055959c to
f395164
Compare
Adds the ability for admins to attach MCP (Model Context Protocol)
servers to individual chats. MCP servers provide additional tools
to the chat agent, enabling integration with external services.
API changes:
- POST /chats accepts optional mcp_servers field (admin-only)
- POST /chats/{id}/messages accepts mcp_servers to update config
- Chat responses include mcp_servers (auth headers stripped)
Implementation:
- New JSONB column on chats table stores per-chat MCP config
- chatd reads mcp_servers from chat row, discovers tools via
Streamable HTTP transport, filters by allow/deny regex, and
registers them as fantasy.AgentTool with mcp__{slug}__{name}
- MCP server failures are logged but never block the chat
- Auth headers are passed to MCP servers but never returned in API
No global MCP server registry, no admin UI, no separate table.
Each chat is self-contained with its MCP configuration.
kylecarbs
force-pushed
the
kylecarbs/agents-mcp-servers
branch
from
March 16, 2026 17:01
f395164 to
4a140e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability for admins to attach MCP (Model Context Protocol) servers to individual chats. MCP servers provide additional tools to the chat agent, enabling integration with external services like Linear, GitHub, Sentry, etc.
API
POST /api/experimental/chats{ "content": [{"type": "text", "text": "What are my open issues?"}], "mcp_servers": [ // optional, admin-only { "slug": "linear", "url": "https://mcp.linear.app/sse", "display_name": "Linear", "auth_headers": {"Authorization": "Bearer lin_api_..."}, "tool_allow_regex": "", "tool_deny_regex": "delete_.*" } ] }POST /api/experimental/chats/{id}/messagesSame
mcp_serversfield to update the config on subsequent messages.Response
Chatobjects includemcp_serversin responses (auth headers are always stripped).Design decisions
mcp_serversfield requiresActionUpdateonResourceDeploymentConfig. Non-admins who omit it get a normal chat.Implementation
chattool.MCPServer()— Connects to a remote MCP server via Streamable HTTP, initializes the protocol, discovers tools, filters by allow/deny regex, and returnsfantasy.AgentToolinstances namedmcp__{slug}__{tool_name}.chatd.runChat()— Parseschat.MCPServersJSONB, connects to all servers in parallel, registers tools before the chat loop starts.Tests
chattool/mcpserver_test.go(8 subtests) — Tool discovery, tool execution, error handling, allow/deny regex filtering, empty servers, invalid input.chatd_test.go(2 integration tests):TestChatMCPServerConnectionFailure— Dead URL → chat errors with MCP message.TestChatMCPServerToolsDiscovered— Real MCP server → tools registered, chat completes.