Skip to content

Commit 0314942

Browse files
committed
Add tool name mapping from JSON for improved display in MCP server extraction
1 parent 68fd854 commit 0314942

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$/, '');
@@ -1892,10 +1896,19 @@ class CopilotTokenTracker implements vscode.Disposable {
18921896
/**
18931897
* Extract server name from an MCP tool name.
18941898
* MCP tool names follow the format: mcp.server.tool or mcp_server_tool
1895-
* For example: "mcp.io.github.git" → "io", "mcp_io_github_git" → "io"
1896-
* Note: Splits on both '.' and '_' to handle various naming conventions
1899+
* For example: "mcp.io.github.git.assign_copilot_to_issue" → "GitHub MCP"
1900+
* Uses the display name from toolNames.json (the part before the colon).
1901+
* Falls back to extracting the second segment if no mapping exists.
18971902
*/
18981903
private extractMcpServerName(toolName: string): string {
1904+
// First, try to get the display name from toolNames.json and extract the server part
1905+
const displayName = this.toolNameMap[toolName];
1906+
if (displayName && displayName.includes(':')) {
1907+
// Extract the part before the colon (e.g., "GitHub MCP" from "GitHub MCP: Issue Read")
1908+
return displayName.split(':')[0].trim();
1909+
}
1910+
1911+
// Fallback: extract from tool name structure
18991912
// Remove the mcp. or mcp_ prefix
19001913
const withoutPrefix = toolName.replace(/^mcp[._]/, '');
19011914
// Split on . or _ and take the first part (server identifier)

0 commit comments

Comments
 (0)