feat(mcp): expose arch-metrics, memory, export-snapshot, import-snapshot as MCP tools — closes #121#128
Merged
Conversation
…hot as MCP tools — closes #121 PRs #107, #109, #110 added 4 new CLI commands but did not register them in the MCP server's _TOOL_DEFINITIONS dict. AI agents using CodeLens via MCP (Claude Desktop, Cursor, etc.) could not invoke these features. Added 4 tool definitions with full JSON Schema parameter specs: - arch-metrics: workspace, format, top - memory: workspace, action (write|read|list|delete), name, content - export-snapshot: workspace, output - import-snapshot: workspace, input, merge MCP tool count: 50 → 54. CLI command count remains 67 (some CLI commands like 'init', 'serve', 'watch' are intentionally not exposed as MCP tools because they don't make sense in an MCP context). The MCP server's _dynamic_tool_definitions() mechanism (line 1387) already auto-generates tool definitions for any CLI command not in _TOOL_DEFINITIONS, but the auto-generated specs lack parameter schemas (everything is treated as opaque 'workspace' + 'args'). The explicit definitions added here give AI agents proper parameter discovery.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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.



What
Fixes RED TEAM issue #121: MCP server was missing tools for 4 new CLI commands added in #107, #109, #110. AI agents using CodeLens via MCP (Claude Desktop, Cursor, etc.) could not invoke these features.
What changed
Added 4 tool definitions with full JSON Schema parameter specs to
scripts/mcp_server.py_TOOL_DEFINITIONS:arch-metricsworkspace,format(json/markdown/ai/sarif/compact, default: ai),top(default: 50)memoryworkspace,action(write/read/list/delete),name,contentexport-snapshotworkspace,outputimport-snapshotworkspace,input,merge(default: False)MCP tool count: 50 → 54. CLI command count remains 67 (some CLI commands like
init,serve,watchare intentionally not exposed as MCP tools because they don't make sense in an MCP context).Why explicit definitions (vs auto-generation)
The MCP server's
_dynamic_tool_definitions()mechanism (line 1387) already auto-generates tool definitions for any CLI command not in_TOOL_DEFINITIONS, but the auto-generated specs lack parameter schemas (everything is treated as opaqueworkspace+args). The explicit definitions added here give AI agents proper parameter discovery so they can call the tools correctly without trial-and-error.Verification
Test suite: 1183 passed, 1 pre-existing failure (#118 — test expectation mismatch, unrelated).
Test plan
_TOOL_DEFINITIONSwith correct parameter schemasRisk
Low. Only adds new entries to a dict — no existing tool definitions are modified. The MCP server's tool dispatch already handles these command names via the existing CLI command registry.