Skip to content

feat(agents): Markdown agents pick their MCP servers with mcpServers - #1766

Merged
edenreich merged 1 commit into
mainfrom
feat/agent-mcp-servers
Nov 8, 2026
Merged

edenreich merged 1 commit into
mainfrom
feat/agent-mcp-servers

Conversation

@edenreich

@edenreich edenreich commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A Markdown agent now names the MCP servers its threads bring up with mcpServers, the key Claude Code uses:

---
name: timekeeper
description: Tells the current time in any timezone.
mcpServers:
  - demo-server
---
  • Without the key a thread gets the enabled servers of its computer, as before. An empty list gives it none.
  • The worker connects only the named servers and starts only those with run: true, so an agent never starts a container it does not use.
  • A named server comes up even when mcp.yaml sets enabled: false for 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-level mcp.enabled: false still turns MCP off for every agent.
  • A name the computer's mcp.yaml lacks is skipped with a warning, and the thread still opens.
  • An inline server definition is ignored with a warning, so agent files never carry a URL, a header or a secret.

Closes #1759

How it flows

The list takes the path the tool lists take:

  1. mdagent.go reads mcpServers as names.
  2. ResolveThreadAgent puts them on the thread options when a thread opens as the agent on the daemon.
  3. ThreadOptions.MCPServers is part of Portable(), so a relay or a teleport carries the resolved list, never the agent name. It is omitzero, so an empty list survives the wire as [].
  4. The worker gets INFER_AGENT_MCP_SERVERS, and the container narrows mcp.yaml with mcp.SelectServers before the MCP supervisor connects or starts anything.

A subagent the Agent tool starts gets the same list on every spawn path: a daemon thread, headless --keep-alive and the tmux pane.

Tests

  • tests/e2e/agent_mcp_test.go runs two MCP 2026-07-28 servers answering server/discover, tools/list and tools/call. The daemon opens a thread as an agent naming chosen (disabled in mcp.yaml) and ghost. The model is offered MCP_chosen_echo and not MCP_other_echo, the call reaches chosen, and other gets no request at all. A thread without an agent then gets other and not chosen. Against a binary built from main, the agent's thread gets other instead and the test fails.
  • Unit tests cover the frontmatter (names, an empty list, an inline definition), the Portable() and JSON round trip, the worker env, the Agent tool's env and thread options, and SelectServers.
  • task test:e2e, task precommit:run and go test ./... pass.

Examples and docs

  • examples/mcp/agents/ holds timekeeper, which uses only the demo server, and summarizer, which uses none. Both are mounted into the example's CLI container.
  • docs/subagents.md documents the key in a new MCP Servers section and drops it from the ignored keys and the limitations. docs/mcp-integration.md points to it.

Known gaps

  • The warning for a missing server names the server and not the agent. The worker never learns the agent's name, since a relay carries the resolved lists instead. The daemon tags the worker's log lines with the conversation.
  • For a subagent the Agent tool starts, MCP tool names in a tools list 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

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
@edenreich
edenreich requested a review from a team as a code owner November 8, 2026 19:51
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Nov 8, 2026
@edenreich
edenreich merged commit 65b8c22 into main Nov 8, 2026
1 check passed
@edenreich
edenreich deleted the feat/agent-mcp-servers branch November 8, 2026 20:18
@edenreich edenreich moved this from Todo to Done in 2026 Nov 8, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.250.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Markdown agents pick their MCP servers with mcpServers

1 participant