codegraph icon indicating copy to clipboard operation
codegraph copied to clipboard

MCP tool names have incorrect prefix (codegraph_codegraph_* instead of codegraph_*)

Open PVLPM opened this issue 6 months ago • 2 comments

Bug Description

When installed via npx for OpenCode and initialized as described in the instructions, the installed MCP commands have the prefix codegraph_codegraph_* instead of the expected codegraph_*.

Expected Behavior

The MCP tools should be named codegraph_search, codegraph_context, codegraph_node, etc.

Actual Behavior

The tools are instead named codegraph_codegraph_search, codegraph_codegraph_context, codegraph_codegraph_node, etc. (note the doubled codegraph_ prefix).

This causes AI Agents to fail when trying to invoke tools like codegraph_search:

⚙ invalid [tool=codegraph_search, error=Model tried to call unavailable tool 'codegraph_search'. Available tools: ..., codegraph_codegraph_search, ...]

The agent cannot find codegraph_search and instead falls back to using glob or other alternative tools, breaking CodeGraph functionality.

Steps to Reproduce

  1. Install CodeGraph via npx for OpenCode
  2. Initialize it as described in the instructions
  3. Attempt to use any CodeGraph tool (e.g., codegraph_search)
  4. Observe that the tools are named codegraph_codegraph_* instead

Environment

  • OpenCode + MCP
  • CodeGraph installed via npx

Suggested Fix

The tool prefix should be codegraph_ (e.g., codegraph_search), not codegraph_codegraph_. The MCP server configuration likely has a redundant prefix in the tool name definition.

Here is the full transcription:

Let me start by searching for relevant code.
⚙ invalid [tool=codegraph_search, error=Model tried to call unavailable tool 'codegraph_search'. Available tools: ast_grep_replace, ast_grep_search, auto_continue, bash, codegraph_codegraph_callees, codegraph_codegraph_callers, codegraph_codegraph_context, codegraph_codegraph_explore, codegraph_codegraph_files, codegraph_codegraph_impact, codegraph_codegraph_node, codegraph_codegraph_search, codegraph_codegraph_status, edit, gh_grep_searchGitHub, glob, grep, grep_app_searchGitHub, invalid, lazyweb_lazyweb_compare_image, lazyweb_lazyweb_find_similar, lazyweb_lazyweb_health, lazyweb_lazyweb_list_categories, lazyweb_lazyweb_list_collections, lazyweb_lazyweb_search, MiniMax_understand_image, MiniMax_web_search, playwright_browser_annotate, playwright_browser_click, playwright_browser_close, playwright_browser_console_messages, playwright_browser_drag, playwright_browser_drop, playwright_browser_evaluate, playwright_browser_file_upload, playwright_browser_fill_form, playwright_browser_handle_dialog, playwright_browser_hide_highlight, playwright_browser_highlight, playwright_browser_hover, playwright_browser_mouse_click_xy, playwright_browser_mouse_down, playwright_browser_mouse_drag_xy, playwright_browser_mouse_move_xy, playwright_browser_mouse_up, playwright_browser_mouse_wheel, playwright_browser_navigate, playwright_browser_navigate_back, playwright_browser_network_request, playwright_browser_network_requests, playwright_browser_pdf_save, playwright_browser_press_key, playwright_browser_resize, playwright_browser_resume, playwright_browser_run_code_unsafe, playwright_browser_select_option, playwright_browser_snapshot, playwright_browser_start_tracing, playwright_browser_start_video, playwright_browser_stop_tracing, playwright_browser_stop_video, playwright_browser_tabs, playwright_browser_take_screenshot, playwright_browser_type, playwright_browser_video_chapter, playwright_browser_wait_for, question, read, read_session, shadcn_get_add_command_for_items, shadcn_get_audit_checklist, shadcn_get_item_examples_from_registries, shadcn_get_project_registries, shadcn_list_items_in_registries, shadcn_search_items_in_registries, shadcn_view_items_in_registries, skill, subtask, task, todowrite, webfetch, websearch, websearch_web_search_exa, write.]
⚙ invalid [tool=codegraph_search, error=Model tried to call unavailable tool 'codegraph_search'. Available tools: ast_grep_replace, ast_grep_search, auto_continue, bash, codegraph_codegraph_callees, codegraph_codegraph_callers, codegraph_codegraph_context, codegraph_codegraph_explore, codegraph_codegraph_files, codegraph_codegraph_impact, codegraph_codegraph_node, codegraph_codegraph_search, codegraph_codegraph_status, edit, gh_grep_searchGitHub, glob, grep, grep_app_searchGitHub, invalid, lazyweb_lazyweb_compare_image, lazyweb_lazyweb_find_similar, lazyweb_lazyweb_health, lazyweb_lazyweb_list_categories, lazyweb_lazyweb_list_collections, lazyweb_lazyweb_search, MiniMax_understand_image, MiniMax_web_search, playwright_browser_annotate, playwright_browser_click, playwright_browser_close, playwright_browser_console_messages, playwright_browser_drag, playwright_browser_drop, playwright_browser_evaluate, playwright_browser_file_upload, playwright_browser_fill_form, playwright_browser_handle_dialog, playwright_browser_hide_highlight, playwright_browser_highlight, playwright_browser_hover, playwright_browser_mouse_click_xy, playwright_browser_mouse_down, playwright_browser_mouse_drag_xy, playwright_browser_mouse_move_xy, playwright_browser_mouse_up, playwright_browser_mouse_wheel, playwright_browser_navigate, playwright_browser_navigate_back, playwright_browser_network_request, playwright_browser_network_requests, playwright_browser_pdf_save, playwright_browser_press_key, playwright_browser_resize, playwright_browser_resume, playwright_browser_run_code_unsafe, playwright_browser_select_option, playwright_browser_snapshot, playwright_browser_start_tracing, playwright_browser_start_video, playwright_browser_stop_tracing, playwright_browser_stop_video, playwright_browser_tabs, playwright_browser_take_screenshot, playwright_browser_type, playwright_browser_video_chapter, playwright_browser_wait_for, question, read, read_session, shadcn_get_add_command_for_items, shadcn_get_audit_checklist, shadcn_get_item_examples_from_registries, shadcn_get_project_registries, shadcn_list_items_in_registries, shadcn_search_items_in_registries, shadcn_view_items_in_registries, skill, subtask, task, todowrite, webfetch, websearch, websearch_web_search_exa, write.]
✱ Grep "vehicleClass.*i18n|t\(.*vehicle|t\(.*class.*name" (31 matches)

PVLPM avatar May 21 '26 22:05 PVLPM

I encountered the same issue, but I suspect this might be an OpenCode problem. OpenCode appears to prepend the MCP server name to every MCP tool name.


I managed to get opencode to invoke the tools correctly by adding a note about this to AGENTS.md.

### Caution
Depending on the agents used, these codegraph tools might have a duplicated `codegraph_ prefix` (e.g., `codegraph_context` -> `codegraph_codegraph_context`). Verify your tool list before invocation.

CrazyZfp avatar May 23 '26 06:05 CrazyZfp

Thanks for the detailed transcript — it actually contains the answer. This is OpenCode's tool-naming behavior, not a CodeGraph misconfiguration: OpenCode prefixes every MCP tool with its server key. You can see it across your whole tool list in the same paste — lazyweb_lazyweb_* and websearch_web_search_exa are doubled the exact same way. Any MCP server whose tools already namespace themselves shows up "doubled" in OpenCode. Since CodeGraph's tools are named codegraph_search / codegraph_context / … and the server is registered under the key codegraph, OpenCode renders them as codegraph_codegraph_search, etc.

The tools still work under those names — in OpenCode the agent just has to call codegraph_codegraph_search instead of codegraph_search. As @CrazyZfp found, a one-line note in AGENTS.md steers the agent to the right names:

Depending on the agent, these codegraph tools may have a doubled codegraph_ prefix (e.g. codegraph_context → codegraph_codegraph_context). Verify the tool list before invoking.

We can't fix this cleanly on the CodeGraph side without renaming every tool to drop the codegraph_ prefix — which would break the names in every other client (Claude Code, Cursor, Codex) and all the docs/instructions that reference codegraph_*. So I'm closing this as client-side behavior. Thanks for the clear report, and the AGENTS.md note above is the fix for now.

colbymchenry avatar May 29 '26 03:05 colbymchenry