feat(mcp): default tool surface trimmed to 4 — explore, node, search, callers (#818)

callees/impact/files/status stay fully functional (handlers, CLI, library
API untouched; CODEGRAPH_MCP_TOOLS re-enables any) but are no longer
LISTED by default. Evidence: codegraph_impact appears in zero recorded
eval runs ever; its blast-radius info already arrives inline on explore
(Blast radius section) and node (dependents note). callees is redundant
by construction (a symbol's body IS its callee list). files/status
"reduce to one grep" per the tiny-repo audit, and staleness banners
already inline pending-sync. callers stays: exhaustive call-site
enumeration (incl. callback registrations, per-definition sections) is
the one job explore/node don't replicate. Fewer tools = fewer mis-picks
+ ~300 schema tokens saved per session; presence itself steers.

server-instructions rewritten around the 4-tool surface ("what does X
call" → node body+trail; "what breaks" → callers + inline blast radius).
Tiny-repo gate unchanged (its trio ⊆ the default set); stale gate
comment corrected (context/trace are long gone — its "5 core tools" are
today's trio).

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-06-11 20:50:22 -05:00
committed by GitHub
co-authored by Claude Opus 4.8
parent f9fcc2cd6a
commit c450fd95b7
4 changed files with 60 additions and 19 deletions
+19 -8
View File
@@ -17,13 +17,23 @@ describe('CODEGRAPH_MCP_TOOLS allowlist', () => {
const listed = () => new ToolHandler(null).getTools().map(t => t.name).sort();
it('exposes the full tool surface when unset', () => {
it('exposes the default 4-tool surface when unset', () => {
delete process.env[ENV];
const all = listed();
expect(all).toContain('codegraph_explore');
expect(all).not.toContain('codegraph_context');
expect(all).not.toContain('codegraph_trace');
expect(all.length).toBeGreaterThanOrEqual(8);
// The default set (see DEFAULT_MCP_TOOLS): explore + node are the
// validated workhorses, search the cheap lookup, callers the one
// irreplaceable enumerator. callees/impact/files/status stay defined
// and executable but unlisted — impact appeared in ZERO recorded runs.
expect(listed()).toEqual([
'codegraph_callers',
'codegraph_explore',
'codegraph_node',
'codegraph_search',
]);
});
it('re-enables an unlisted tool via the allowlist (impact)', () => {
process.env[ENV] = 'explore,impact';
expect(listed()).toEqual(['codegraph_explore', 'codegraph_impact']);
});
it('filters ListTools to the allowlisted short names', () => {
@@ -36,9 +46,10 @@ describe('CODEGRAPH_MCP_TOOLS allowlist', () => {
expect(listed()).toEqual(['codegraph_explore', 'codegraph_search']);
});
it('treats an empty/whitespace value as unset (full surface)', () => {
it('treats an empty/whitespace value as unset (default surface)', () => {
process.env[ENV] = ' ';
expect(listed().length).toBeGreaterThanOrEqual(8);
expect(listed()).toHaveLength(4);
expect(listed()).toContain('codegraph_explore');
});
it('rejects a disabled tool on execute (defense in depth)', async () => {