mcp: prefer announced server title for tool prefixes and picker labels#318638
Merged
Conversation
Reworks how MCP tool prefixes are generated and how MCP servers are labelled in the Configure Tools picker so that the server-announced serverInfo.title (falling back to serverInfo.name) is preferred over the mcp.json key. - Introduces a shared McpPrefixGenerator with a ake(name): IReference<string> API that hands out collision-resolved tool prefixes and releases them on dispose. Replaces the eager one-shot generator that used to live in McpService. - McpServer now derives its tool prefix from its preferred name (announced title when known, otherwise the mcp.json label) so registry-style names like io.github.upstash/context7 no longer end up as truncated mcp_io_github_ups_* prefixes. - Configure Tools picker and ToolDataSource.classify for MCP sources now prefer serverLabel (the announced title) over label . - Adds unit tests for McpPrefixGenerator covering collisions, slot reuse on dispose, bucket cleanup, and name sanitization. Fixes #299749 Fixes #299787 (Commit message generated by Copilot)
Contributor
There was a problem hiding this comment.
Pull request overview
Updates MCP tool prefix generation and MCP server labeling to prefer server-announced serverInfo.title/name over the mcp.json key, improving readability and avoiding truncated registry-style identifiers in tool names and UI.
Changes:
- Introduces a shared
McpPrefixGenerator.take(name): IReference<string>that manages collision-resolved prefixes with reuse on dispose. - Updates
McpServerto derive its tool prefix from server-announced metadata when available, and updates MCP source labeling in the tool picker and source classification. - Adds unit tests for prefix collisions, reuse, bucket cleanup, and name sanitization.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/mcp/test/common/mcpPrefixGenerator.test.ts | Adds unit tests for the new prefix generator behavior. |
| src/vs/workbench/contrib/mcp/common/mcpService.ts | Switches to a shared prefix generator and removes per-refresh eager prefix allocation. |
| src/vs/workbench/contrib/mcp/common/mcpServer.ts | Adds McpPrefixGenerator and updates servers to compute prefixes from preferred (announced) names. |
| src/vs/workbench/contrib/chat/common/tools/languageModelToolsService.ts | Prefers serverLabel for MCP tool source classification labels. |
| src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.ts | Prefers serverLabel for MCP server bucket labels in the Configure Tools picker. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/mcp/common/mcpService.ts:205
updateCollectedServers()used to requireserver.toolPrefix === d.toolPrefixto reuse an existing server. Now it matches only by IDs, so a definitionlabelchange (possible for extension-provided definitions whereidis stable) won’t recreate/update the server and it will keep using the olddefinition.labelas fallback display/prefix. Consider includingserverDefinition.labelin the reuse criteria or updating the server’s label when the definition changes.
// Transfer over any servers that are still valid.
for (const server of currentServers) {
const match = definitions.find(d => defsEqual(server.object, d));
if (match) {
pushMatch(match, server);
} else {
server.object.dispose();
- Files reviewed: 5/5 changed files
- Comments generated: 3
roblourens
approved these changes
May 27, 2026
roblourens
approved these changes
May 27, 2026
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.
mcp: prefer announced server title for tool prefixes and picker labels
Reworks how MCP tool prefixes are generated and how MCP servers are labelled
in the Configure Tools picker so that the server-announced
serverInfo.title(falling back to
serverInfo.name) is preferred over the mcp.json key.McpPrefixGeneratorwith atake(name): IReference<string>API that hands out collision-resolved tool prefixes and releases them on
dispose. Replaces the eager one-shot generator that used to live in
McpService.
title when known, otherwise the mcp.json label) so registry-style names
like
io.github.upstash/context7no longer end up as truncatedmcp_io_github_ups_*prefixes.ToolDataSource.classifyfor MCP sources nowprefer
serverLabel(the announced title) overlabel.McpPrefixGeneratorcovering collisions, slot reuse ondispose, bucket cleanup, and name sanitization.
Fixes #299749
Fixes #299787
(Commit message generated by Copilot)