diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx index 315cea60..c48912bf 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx @@ -908,6 +908,8 @@ const MCPServerComponent = ({ name, server }: { name: string, server: MCPServer const voidSettings = useSettingsState() const isOn = voidSettings.mcpUserStateOfName[name]?.isOn + const removeUniquePrefix = (name: string) => name.split('_').slice(1).join('_') + return (
@@ -948,7 +950,7 @@ const MCPServerComponent = ({ name, server }: { name: string, server: MCPServer data-tooltip-content={tool.description || ''} data-tooltip-class-name='void-max-w-[20px]' > - {tool.name} + {removeUniquePrefix(tool.name)} )) ) : ( diff --git a/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts b/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts index 7e727131..440a2af8 100644 --- a/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts +++ b/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts @@ -175,19 +175,22 @@ export class MCPChannel implements IServerChannel { await client.connect(transport); console.log(`Connected via HTTP to ${serverName}`); const { tools } = await client.listTools() + const toolsWithUniqueName = tools.map(({ name, ...rest }) => ({ name: this._addUniquePrefix(name), ...rest })) info = { status: isOn ? 'success' : 'offline', - tools: tools, + tools: toolsWithUniqueName, command: server.url.toString(), } } catch (httpErr) { console.warn(`HTTP failed for ${serverName}, trying SSE…`, httpErr); transport = new SSEClientTransport(server.url); await client.connect(transport); + const { tools } = await client.listTools() + const toolsWithUniqueName = tools.map(({ name, ...rest }) => ({ name: this._addUniquePrefix(name), ...rest })) console.log(`Connected via SSE to ${serverName}`); info = { status: isOn ? 'success' : 'offline', - tools: [], + tools: toolsWithUniqueName, command: server.url.toString(), } } @@ -206,6 +209,7 @@ export class MCPChannel implements IServerChannel { // Get the tools from the server const { tools } = await client.listTools() + const toolsWithUniqueName = tools.map(({ name, ...rest }) => ({ name: this._addUniquePrefix(name), ...rest })) // Create a full command string for display const fullCommand = `${server.command} ${server.args?.join(' ') || ''}` @@ -213,7 +217,7 @@ export class MCPChannel implements IServerChannel { // Format server object info = { status: isOn ? 'success' : 'offline', - tools: tools, + tools: toolsWithUniqueName, command: fullCommand, } @@ -225,6 +229,10 @@ export class MCPChannel implements IServerChannel { return { _client: client, mcpServerEntryJSON: server, mcpServer: info } } + private _addUniquePrefix(base: string) { + return `${Math.random().toString(36).slice(2, 8)}_${base}`; + } + private async _createClient(serverConfig: MCPConfigFileEntryJSON, serverName: string, isOn = true): Promise { try { const c: ClientInfo = await this._createClientUnsafe(serverConfig, serverName, isOn)