fix(mcp): resolve project arg by unique name tail when exact lookup misses#1054
Merged
Conversation
…isses Agents naturally pass the repo folder name (codebase-memory-mcp), but indexed project names derive from the full path (E:\project\graph\x -> E-project-graph-x), so every graph tool answered 'project not found or not indexed' while list_projects clearly showed the project. get_project_arg now falls back to a cache-dir filename scan when no <project>.db exists: a passed name matching exactly ONE indexed project as a segment-aligned tail (-<name>.db) adopts that project's full name (logged); zero or several matches keep the original name so the existing not-found error with the candidate list fires. Exact names never enter the scan, and internal-name drift stays #704's fallback in resolve_store. Closes #1025 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
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.
Closes #1025
Bug
Agents naturally pass the repo folder name (
codebase-memory-mcp), but indexed project names derive from the full path (E:\project\graph\x→E-project-graph-x). Every graph tool then answeredproject not found or not indexedwhilelist_projectsclearly showed the project — an unguessable name for any MCP client.Fix
get_project_arg(the shared getter behind all 11 project-taking tools, same choke point as the #640 aliases) gains a tail-resolution fallback: when no<project>.dbexists, scan cache-dir filenames for a segment-aligned tail match (-<project>.db):mcp.project_tail_resolved)Exact names never enter the scan (fast path untouched); internal-name drift stays #704's separate fallback in
resolve_store. Filename-level only — no DB opens on the fallback path.Reproduce-first
tool_project_arg_resolves_unique_tail_issue1025indexes three real fixtures under an overriddenCBM_CACHE_DIR(E-project-graph-suffix1025,F-alpha-amb1025,G-beta-amb1025) and asserts: unique tailsuffix1025resolves (RED on main: project-not-found), ambiguous tailamb1025stays an error, and the exact full name keeps working.Verification
Full local suite 6005 passed, 1 skipped, zero regressions; lint-ci clean.