Skip to content

feat(harness): list deferred MCP servers in an mcpservers prompt section - #117

Merged
sanchitrk merged 1 commit into
canaryfrom
claude/cod-159-mcpservers-a222ce
Oct 31, 2026
Merged

sanchitrk merged 1 commit into
canaryfrom
claude/cod-159-mcpservers-a222ce

Conversation

@sanchitrk

Copy link
Copy Markdown
Contributor

Summary

MCP servers whose tools are not declared to the model are now listed in a harness-rendered mcpservers system-prompt section, so the model knows they exist and how to reach them.

  • Each line is - mcp__<server> (toolsearch): <summary>. The summary is the first line of the configured description, or of the server's instructions once it connected. Summaries are capped at 250 characters and the section at 4096; servers that don't fit are counted in a closing line.
  • Timing: the section is worked out after the startup wait for servers with direct tools, then held for the rest of the run. A server that connects mid-run shows at the next prompt.
  • Prompt cache: a change reaches the model as a system entry carrying only mcpservers, through the existing section-diff machinery, so the cached prefix survives.
  • When it is left out: while toolsearch is not declared (it turns itself on when a turn has deferred tools, so this only happens when it is turned off), and for a server disconnected on request.
  • Codemode: servers whose tools are all codemode are not listed, since nothing reaches them yet. A server with both codemode and deferred tools is listed under toolsearch.
  • mcpservers is a reserved section name in @codeworksh/plugin, like tools and cwd.
  • The toolsearch tool name moved to tool/search.ts, so the MCP domain and the prompt renderer don't depend on the built-in plugin.

Tests

  • test/mcp.section.test.ts (E2E, scripted model, real stdio server): a server is listed without a summary while connecting, connects mid-run without changing that run, gets its summary at the next prompt as a section-only entry, and is removed after a disconnect. Artifact: mcp.section.json.
  • test/mcp.section.live.test.ts (live, openai-codex gpt-6-luna): a deferred server is listed with its description, then after the description is dropped the next request carries only mcpservers with the summary from the instructions, and the model answers from it. Artifact: mcp.section.live.openai-codex.json.
  • Existing MCP thread artifacts now include mcpservers for threads with deferred servers.
  • vp check, typecheck (harness, plugin) and the full harness suite pass.

🤖 Generated with Claude Code

Servers whose tools are not declared to the model are listed in a new
harness-rendered `mcpservers` section, each with how its tools are reached
(`toolsearch`) and a one-line summary: the configured description, or the
first line of the server's instructions once it connected.

The section is worked out after the startup wait for servers with direct
tools and held for the rest of a run, so a server that connects mid-run
shows at the next prompt, as a system entry carrying only that section.
It is left out while toolsearch is not declared, and a server
disconnected on request is dropped from it. Servers whose tools are all
codemode are not listed, since nothing reaches them yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk merged commit 2577ed7 into canary Oct 31, 2026
2 checks passed
@sanchitrk
sanchitrk deleted the claude/cod-159-mcpservers-a222ce branch October 31, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant