feat(mcp): always expose tools and require projectPath when no default project (#94)#95
Merged
Merged
Conversation
…t project (#94) tools/list previously returned an empty array when no default project was resolved (unindexed cwd / roots-less client), so 通义灵码 (Lingma) showed 0 tools unless -p was set -- and -p is shared across every IDE window. Forward-port colby #964 (PR#966) + #993 (PR#1007): tools/list now ALWAYS exposes the visible tool surface. When a default project is resolved, projectPath stays optional (byte-identical to the golden). When none is resolved, the same tools are listed with projectPath marked required in each inputSchema so the agent supplies it per call. Reverses the c450fd95 empty-when-unindexed behavior. - schemas.rs: pure idempotent with_required_project_path transform handling all three required-array shapes (with-keys / empty / absent) + visible_tool_definitions_requiring_project_path; unit tests for each. - server.rs: tools/list dispatch arm always-exposes; rewrote the stale has_default_codegraph doc comment. - golden_mcp.rs: flipped+renamed the two empty-list tests, added a no-default McpServer::new(None) test, and asserted projectPath stays optional in the indexed-default guard. Golden reference/ byte-identical (roundtrip uses an indexed project).
…ots-less clients (#94)
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.
Fixes #94.
Problem
In 通义灵码 (Lingma) — a roots-less IDE that launches the MCP server from a fixed working directory and sends no
rootUri/workspaceFolders/roots—tools/listreturned an empty array unless-p <path>was set. But-pis shared across every IDE window, so it pins all windows to one project. Users were stuck: no-p→ 0 tools; with-p→ wrong project in every other window.Fix (forward-port colby #964 + #993)
tools/listnow ALWAYS returns the visible tool surface, even when no project is resolved. Removes the 0-tools dead end.inputSchema.requiredgainsprojectPath, nudging the agent to pass it per call. When a default project IS resolved,projectPathstays optional (byte-identical to the golden).This reverses the earlier
c450fd95"empty list when unindexed" behavior, which was the #94 root cause.Honest scope
This removes the dead end and provides the supported escape hatch (
projectPathper call, or-p). For the foreign-cwd Lingma case, per-call usability depends on the agent supplyingprojectPath— it is not zero-config per-window auto-binding (Lingma sends no workspace signal and supports no${workspaceFolder}; the deterministic alternative would need a per-project config file, deliberately out of scope). Documented as a known limitation indocs/mcp.md#project-resolution.Changes
crates/codegraph-mcp/src/schemas.rs: pure, idempotentwith_required_project_path(handles all threerequired-array shapes) +visible_tool_definitions_requiring_project_path; unit tests.crates/codegraph-mcp/src/server.rs:tools/listdispatch arm always-exposes; stale doc comments rewritten.crates/codegraph-mcp/tests/golden_mcp.rs: flipped+renamed the two empty-list tests, added a no-defaultMcpServer::new(None)test, asserted projectPath stays optional in the indexed guard.docs/mcp.md+README.md: honest always-list + projectPath-nudge story.Invariants
reference/BYTE-IDENTICAL (roundtripuses an indexed project; the change only affects the no-default path no golden frame exercises).handle_tools_calluntouched. No auto-indexing, no new tool/env var/schema migration, no per-project file, no hand version bump.Verification
make cigreen;cargo test -p codegraph-mcp+-p codegraph-benchgreen;git diff --quiet reference/exit 0.$HOMEtoo-broad / residualtools/callwith & without projectPath) — all behave per the honest framing.