Skip to content

mcp: prefer announced server title for tool prefixes and picker labels#318638

Merged
connor4312 merged 2 commits into
mainfrom
connor4312/299787
May 27, 2026
Merged

mcp: prefer announced server title for tool prefixes and picker labels#318638
connor4312 merged 2 commits into
mainfrom
connor4312/299787

Conversation

@connor4312
Copy link
Copy Markdown
Member

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.

  • Introduces a shared McpPrefixGenerator with a take(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)

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)
Copilot AI review requested due to automatic review settings May 27, 2026 22:13
@connor4312 connor4312 enabled auto-merge (squash) May 27, 2026 22:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 McpServer to 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 require server.toolPrefix === d.toolPrefix to reuse an existing server. Now it matches only by IDs, so a definition label change (possible for extension-provided definitions where id is stable) won’t recreate/update the server and it will keep using the old definition.label as fallback display/prefix. Consider including serverDefinition.label in 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

Comment thread src/vs/workbench/contrib/mcp/common/mcpServer.ts Outdated
Comment thread src/vs/workbench/contrib/mcp/test/common/mcpPrefixGenerator.test.ts
Comment thread src/vs/workbench/contrib/mcp/test/common/mcpPrefixGenerator.test.ts Outdated
@connor4312 connor4312 merged commit 0245c88 into main May 27, 2026
25 checks passed
@connor4312 connor4312 deleted the connor4312/299787 branch May 27, 2026 23:02
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants