Skip to content

feat(mcp): state the structural questions in the scout and analysis profiles - #2708

Open
DeusData wants to merge 2 commits into
mainfrom
feat/mcp-profile-instructions
Open

DeusData wants to merge 2 commits into
mainfrom
feat/mcp-profile-instructions

Conversation

@DeusData

Copy link
Copy Markdown
Owner

Stacked on #2698. Until #2698 merges, this diff also shows its commit (c2ee122); this PR adds only 5e345e3.

What changes

The read-only analysis profile and the fast scout profile serve the graph subagents (codebase-memory-auditor, codebase-memory-scout). Their server instructions only listed tools. Like the default profile in #2698, they now state as facts, keywords first, which structural questions the graph answers: where a symbol is defined, who calls a function and what it calls; the analysis profile also covers call chains, data flow and change impact. Under tool search these instructions are what a client loads before the model searches.

profile before after
analysis 190 chars 648 chars
scout 199 chars 427 chars

Both stay well under Claude Code's 4,096-character cut. The profile names, the check_index_coverage pointer and the absence of index_repository are unchanged, and the existing profile tests still assert them.

Tests

  • server_handle_analysis_profile_filters_and_rejects_mutators and server_handle_scout_profile_exposes_only_the_fast_tier now also assert the structural-question text.
  • Revert check: with feat(mcp): load the structural tools upfront and say what the graph answers #2698's src/mcp/mcp.c, exactly those two tests fail; with this change both pass.
  • Local (macOS arm64, ASan/UBSan test runner): mcp 379 passed / 0 failed / 4 skipped (Windows-only).
  • Lint: clang-format (Homebrew LLVM 22) and cppcheck 2.20 (the CI lint image) both clean.
  • Linux and Windows legs were not run locally: this is a string-only change, so PR CI is the gate.

Refs #509

…nswers

Claude Code defers every MCP tool behind ToolSearch by default: at session
start the model sees only tool names and server instructions, while Grep and
Read are always loaded. Codex does the same and shows the server instructions
as the namespace description of the deferred tools. Agents therefore reached
for grep before the graph tools were even loaded (#509, discussion #2025).

- tools/list: search_graph, trace_path and get_code_snippet carry
  _meta["anthropic/alwaysLoad"] = true (a documented per-tool hint), so the
  structural discovery path loads upfront while the other 14 tools stay
  deferred. About 4.6K characters of schema; clients that do not know the key
  ignore it, as MCP reserves _meta.
- Server instructions (default profile) now state, keywords first and as
  facts, which structural questions the graph answers and where grep fits
  better: 309 -> 999 characters, within Claude Code's 4,096-character cut.
- SessionStart/SubagentStart: the untrusted-metadata label now covers the
  graph-derived project name only. Wrapping the routing sentences too told the
  model to treat cbm's own guidance as data. The other sentences are unchanged;
  sanitization is unchanged.

The initialize byte budget is raised deliberately from 512 B to 1.5 KiB (1,188
bytes now); tools/list stays within its 21 KiB budget (20,938 bytes).

Refs #509

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
…rofiles

The read-only analysis profile and the fast scout profile serve the graph
subagents (codebase-memory-auditor, codebase-memory-scout). Their server
instructions listed tools only. Like the default profile, they now state as
facts which structural questions the graph answers (where a symbol is defined,
who calls a function, what it calls, and for analysis also call chains, data
flow and change impact), keywords first: analysis 190 -> 648 characters, scout
199 -> 427, well within Claude Code's 4,096-character cut. The profile names,
check_index_coverage and the absence of index_repository are unchanged.

Stacked on #2698.

Refs #509

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>

This branch has not been deployed

No deployments
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