Repository navigation
feat(agents): Markdown agents pick their MCP servers with mcpServers - #1766
Merged
Merged
Conversation
A Markdown agent's mcpServers frontmatter names the servers of the computer's mcp.yaml its threads bring up. Without the key a thread keeps the enabled servers, and an empty list brings up none. A named server comes up even when mcp.yaml disables it, so a server can serve one agent and stay off for every other chat. The daemon resolves the list with the rest of the agent, a relay or a teleport carries it on the thread options, and the worker gets it as INFER_AGENT_MCP_SERVERS. The container narrows mcp.yaml before the MCP supervisor connects or starts anything. A name mcp.yaml lacks is skipped with a warning, and an inline server definition is ignored with one, so agent files never carry a URL, a header or a secret. Subagents the Agent tool starts get the same list on every spawn path. Closes #1759
Closed
5 tasks
Contributor
|
🎉 This PR is included in version 0.250.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
A Markdown agent now names the MCP servers its threads bring up with
mcpServers, the key Claude Code uses:run: true, so an agent never starts a container it does not use.mcp.yamlsetsenabled: falsefor it. A server can then stay off for plain chats and serve only the agent that names it, such as an agent's own mailbox. The top-levelmcp.enabled: falsestill turns MCP off for every agent.mcp.yamllacks is skipped with a warning, and the thread still opens.Closes #1759
How it flows
The list takes the path the tool lists take:
mdagent.goreadsmcpServersas names.ResolveThreadAgentputs them on the thread options when a thread opens as the agent on the daemon.ThreadOptions.MCPServersis part ofPortable(), so a relay or a teleport carries the resolved list, never the agent name. It isomitzero, so an empty list survives the wire as[].INFER_AGENT_MCP_SERVERS, and the container narrowsmcp.yamlwithmcp.SelectServersbefore the MCP supervisor connects or starts anything.A subagent the
Agenttool starts gets the same list on every spawn path: a daemon thread,headless --keep-aliveand the tmux pane.Tests
tests/e2e/agent_mcp_test.goruns two MCP2026-07-28servers answeringserver/discover,tools/listandtools/call. The daemon opens a thread as an agent namingchosen(disabled inmcp.yaml) andghost. The model is offeredMCP_chosen_echoand notMCP_other_echo, the call reacheschosen, andothergets no request at all. A thread without an agent then getsotherand notchosen. Against a binary built frommain, the agent's thread getsotherinstead and the test fails.Portable()and JSON round trip, the worker env, theAgenttool's env and thread options, andSelectServers.task test:e2e,task precommit:runandgo test ./...pass.Examples and docs
examples/mcp/agents/holdstimekeeper, which uses only the demo server, andsummarizer, which uses none. Both are mounted into the example's CLI container.docs/subagents.mddocuments the key in a new MCP Servers section and drops it from the ignored keys and the limitations.docs/mcp-integration.mdpoints to it.Known gaps
Agenttool starts, MCP tool names in atoolslist are still dropped as unknown, because MCP tools register after the session starts. A thread opened as the agent on the daemon keeps them. This is documented under Limitations.Cross-repo impact
desktop: feat(settings): manage MCP servers in an MCPs tab and let agents pick theirs desktop#480 already writesmcpServersfrom the agent editor and opens threads by agent name, so no frame change is needed.docs: [DOCS] CLI Markdown agents pick their MCP servers with mcpServers docs#1136 documentsmcpServersfor Markdown agents.