Skip to content

Commit f7c0b8c

Browse files
committed
Add tool name mapping from JSON for improved display in MCP server extraction
1 parent 87852b3 commit f7c0b8c

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/extension.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from 'path';
44
import * as os from 'os';
55
import tokenEstimatorsData from './tokenEstimators.json';
66
import modelPricingData from './modelPricing.json';
7+
import toolNamesData from './toolNames.json';
78
import { BackendFacade } from './backend/facade';
89
import { BackendCommandHandler } from './backend/commands';
910
import * as packageJson from '../package.json';
@@ -265,6 +266,9 @@ class CopilotTokenTracker implements vscode.Disposable {
265266
// These are reference prices for cost estimation purposes only
266267
private modelPricing: { [key: string]: ModelPricing } = modelPricingData.pricing as { [key: string]: ModelPricing };
267268

269+
// Tool name mapping - loaded from toolNames.json for friendly display names
270+
private toolNameMap: { [key: string]: string } = toolNamesData as { [key: string]: string };
271+
268272
// Helper method to get repository URL from package.json
269273
private getRepositoryUrl(): string {
270274
const repoUrl = packageJson.repository?.url?.replace(/^git\+/, '').replace(/\.git$/, '');
@@ -1981,10 +1985,19 @@ class CopilotTokenTracker implements vscode.Disposable {
19811985
/**
19821986
* Extract server name from an MCP tool name.
19831987
* MCP tool names follow the format: mcp.server.tool or mcp_server_tool
1984-
* For example: "mcp.io.github.git" → "io", "mcp_io_github_git" → "io"
1985-
* Note: Splits on both '.' and '_' to handle various naming conventions
1988+
* For example: "mcp.io.github.git.assign_copilot_to_issue" → "GitHub MCP"
1989+
* Uses the display name from toolNames.json (the part before the colon).
1990+
* Falls back to extracting the second segment if no mapping exists.
19861991
*/
19871992
private extractMcpServerName(toolName: string): string {
1993+
// First, try to get the display name from toolNames.json and extract the server part
1994+
const displayName = this.toolNameMap[toolName];
1995+
if (displayName && displayName.includes(':')) {
1996+
// Extract the part before the colon (e.g., "GitHub MCP" from "GitHub MCP: Issue Read")
1997+
return displayName.split(':')[0].trim();
1998+
}
1999+
2000+
// Fallback: extract from tool name structure
19882001
// Remove the mcp. or mcp_ prefix
19892002
const withoutPrefix = toolName.replace(/^mcp[._]/, '');
19902003
// Split on . or _ and take the first part (server identifier)

0 commit comments

Comments
 (0)