Skip to content

fix(ai): stop guessing the MCP server name VSCode leaves out - #1423

Open
amascia-gg wants to merge 1 commit into
mainfrom
amascia/vscode-mcp-server-resolution
Open

fix(ai): stop guessing the MCP server name VSCode leaves out#1423
amascia-gg wants to merge 1 commit into
mainfrom
amascia/vscode-mcp-server-resolution

Conversation

@amascia-gg

Copy link
Copy Markdown
Member

VSCode names an MCP tool call mcp_{mangled server}_{tool}, where the server name is lowercased, has its non-alphanumeric groups replaced by _, and is cut at 13 characters. No separator marks the end of the server name, so the split is only knowable against a list of known configuration names.

When no local configuration matches, the fallback cut the name at the first _ and reported the result as the server. That name matches nothing on the API side, so the activity is dropped and the API logs an error. This is one of the causes behind the "Server not found for MCP activity" Sentry issue (NHI-1927). The raw name is now reported with an empty server, and the API splits it against the inventory of the whole account, which is wider than what one machine can see. The API side is in ward-runs-app!27641.

Two more fixes in the same path:

  • The history walk gets the server label from VSCode next to the tool id, but still asked the same guesswork helper for the tool half. With no discovery cache it recorded no_notion-search for a tool named notion-search. It now cuts the tool with the mangled label, which needs no lookup and makes the live hook and the history agree.
  • A payload with no tool name raised IndexError inside the hook, and the match loop tested the empty string on its first turn.

Note for reviewers: #1419 makes VSCode detectable on macOS and Windows, so the local configuration list is populated much more often there and this fallback becomes the exception it should be.

VSCode names an MCP tool call "mcp_{mangled server}_{tool}" with no separator
between the two halves, so the split is only knowable against a list of known
configuration names. When no local configuration matches, the fallback cut the
name at the first "_" and reported the result as the server, which resolves to
nothing on the API side and drops the activity. The raw name is reported instead:
the API matches it against the inventory of the whole account, which is wider
than what one machine can see.

The history walk keeps the label that VSCode records next to the tool id, so it
now cuts the tool with the mangled label and needs no lookup. Without a discovery
cache it reported "no_notion-search" for a tool named "notion-search".

An empty tool name no longer raises IndexError, and the match loop no longer
tests the empty string on its first turn.
@amascia-gg
amascia-gg requested review from a team as code owners August 19, 2026 12:58
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.00%. Comparing base (75327a4) to head (f2de3d7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1423   +/-   ##
=======================================
  Coverage   94.00%   94.00%           
=======================================
  Files         200      200           
  Lines       12636    12638    +2     
=======================================
+ Hits        11878    11880    +2     
  Misses        758      758           
Flag Coverage Δ
unittests 94.00% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant