Skip to content

Commit 210a576

Browse files
author
Lasim
committed
feat(satellite): unify tool path format to use serverSlug for namespacing
1 parent f2f0d7c commit 210a576

File tree

8 files changed

+48
-67
lines changed

8 files changed

+48
-67
lines changed

services/satellite/src/core/mcp-server-wrapper.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,30 +240,27 @@ export class McpServerWrapper {
240240
throw new Error('Invalid tool_path parameter - must be a non-empty string in format "serverName:toolName"');
241241
}
242242

243-
// Parse tool_path from "serverName:toolName" format to "serverName-toolName" (internal namespaced format)
243+
// Validate tool_path format (serverSlug:toolName)
244244
const colonIndex = toolPath.indexOf(':');
245245
if (colonIndex <= 0) {
246-
throw new Error(`Invalid tool_path format: ${toolPath}. Expected format: "serverName:toolName" (e.g., "github:create_issue")`);
246+
throw new Error(`Invalid tool_path format: ${toolPath}. Expected format: "serverSlug:toolName" (e.g., "github:create_issue")`);
247247
}
248248

249-
const serverSlug = toolPath.substring(0, colonIndex);
250-
const toolName = toolPath.substring(colonIndex + 1);
251-
const namespacedToolName = `${serverSlug}-${toolName}`;
249+
// tool_path format matches internal namespaced format (unified to colon separator)
250+
const namespacedToolName = toolPath;
252251

253252
this.logger.info({
254253
operation: 'execute_mcp_tool',
255-
tool_path: toolPath,
256-
namespaced_tool_name: namespacedToolName
257-
}, `Executing tool: ${toolPath} (internal: ${namespacedToolName})`);
254+
tool_path: toolPath
255+
}, `Executing tool: ${toolPath}`);
258256

259257
this.logger.debug({
260258
operation: 'execute_mcp_tool_debug',
261259
tool_path: toolPath,
262-
namespaced_tool_name: namespacedToolName,
263260
arguments: toolArguments
264261
}, `Tool arguments for ${toolPath}`);
265262

266-
// Route to existing executeToolCall with namespaced format
263+
// Route to executeToolCall with namespaced format
267264
return await this.executeToolCall(namespacedToolName, toolArguments);
268265
}
269266

@@ -326,10 +323,10 @@ export class McpServerWrapper {
326323
namespaced_tool_name: namespacedToolName
327324
}, `Calling namespaced tool: ${namespacedToolName}`);
328325

329-
// Parse the server slug from the namespaced tool name
330-
const dashIndex = namespacedToolName.indexOf('-');
331-
if (dashIndex <= 0) {
332-
throw new Error(`Invalid tool name format: ${namespacedToolName}. Expected format: serverSlug-toolName`);
326+
// Validate namespaced tool name format (serverSlug:toolName)
327+
const colonIndex = namespacedToolName.indexOf(':');
328+
if (colonIndex <= 0) {
329+
throw new Error(`Invalid tool name format: ${namespacedToolName}. Expected format: serverSlug:toolName`);
333330
}
334331

335332
// Find the cached tool to get the original tool name and verify it exists

services/satellite/src/process/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface MCPServerConfig {
77
installation_id: string; // Database ID from backend
88
installation_name: string; // e.g., "context7-john-R36no6FGoMFEZO9nWJJLT"
99
team_id: string; // Team UUID
10+
server_slug: string; // Server slug (e.g., "sequential", "brightdata-mcp-1")
1011
command: string; // "npx" for Node.js packages
1112
args: string[]; // ["-y", "@upstash/context7"]
1213
env: Record<string, string>; // Environment variables from three-tier config

services/satellite/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ export async function createServer() {
344344
installation_id: serverConfig.installation_id || serverName,
345345
installation_name: serverName,
346346
team_id: serverConfig.team_id || 'unknown',
347+
server_slug: serverConfig.server_slug || serverName,
347348
command: serverConfig.command!,
348349
args: serverConfig.args!,
349350
env: serverConfig.env || {}

services/satellite/src/services/command-processor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export class CommandProcessor {
320320
installation_id: payload.installation_id as string,
321321
installation_name: payload.installation_name as string,
322322
team_id: payload.team_id as string,
323+
server_slug: (payload.server_slug as string) || (payload.installation_name as string),
323324
command: payload.command as string,
324325
args: payload.args as string[],
325326
env: (payload.env as Record<string, string>) || {}

services/satellite/src/services/remote-tool-discovery-manager.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import { OAuthTokenService } from './oauth-token-service';
1313
*/
1414
export interface CachedTool {
1515
originalName: string;
16-
namespacedName: string; // e.g., "context7-resolve_library_id"
16+
namespacedName: string; // e.g., "context7:resolve_library_id"
1717
description: string;
1818
inputSchema: any;
1919
serverName: string;
20+
serverSlug: string; // Server slug for tool_path format (e.g., "brightdata-mcp-1")
2021
discoveredAt: Date;
2122
}
2223

@@ -407,16 +408,17 @@ export class RemoteToolDiscoveryManager {
407408

408409
// Convert to cached tools with namespacing using server_slug for friendly names
409410
const discoveredAt = new Date();
411+
// Use server_slug from config for friendly namespacing, fallback to server_name
412+
const serverSlug = config.server_slug || config.server_name || serverName;
413+
410414
const cachedTools: CachedTool[] = response.tools.map((tool: any) => {
411-
// Use server_slug from config for friendly namespacing, fallback to server_name
412-
const friendlyServerName = config.server_slug || config.server_name || serverName;
413-
414415
return {
415416
originalName: tool.name,
416-
namespacedName: `${friendlyServerName}-${tool.name}`,
417-
description: `[${friendlyServerName}] ${tool.description || 'No description'}`,
417+
namespacedName: `${serverSlug}:${tool.name}`,
418+
description: `[${serverSlug}] ${tool.description || 'No description'}`,
418419
inputSchema: tool.inputSchema || {},
419420
serverName: serverName, // Keep original serverName for routing
421+
serverSlug: serverSlug, // Store slug for tool_path format
420422
discoveredAt: discoveredAt
421423
};
422424
});

services/satellite/src/services/stdio-tool-discovery-manager.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import type { EventBus } from './event-bus';
99
export interface CachedStdioTool {
1010
serverName: string; // Installation name (e.g., "filesystem-john-abc123")
1111
originalName: string; // Tool name from server (e.g., "read_file")
12-
namespacedName: string; // User-facing name (e.g., "filesystem-read_file")
12+
namespacedName: string; // Namespaced name (e.g., "filesystem:read_file")
1313
description: string; // Tool description
1414
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1515
inputSchema: any; // JSON Schema for tool parameters
16+
serverSlug: string; // Server slug for tool_path format (e.g., "sequential")
1617
}
1718

1819
/**
@@ -94,21 +95,22 @@ export class StdioToolDiscoveryManager {
9495
return [];
9596
}
9697

97-
// Extract server slug from installation name (e.g., "filesystem-john-abc123" -> "filesystem")
98-
const serverSlug = this.extractServerSlug(installationName);
99-
98+
// Get server slug from process config (e.g., "sequential", "brightdata-mcp-1")
99+
const serverSlug = processInfo.config.server_slug;
100+
100101
const cachedTools: CachedStdioTool[] = [];
101102
const toolSet = new Set<string>();
102103

103104
for (const tool of response.tools) {
104-
const namespacedName = `${serverSlug}-${tool.name}`;
105-
105+
const namespacedName = `${serverSlug}:${tool.name}`;
106+
106107
const cachedTool: CachedStdioTool = {
107108
serverName: installationName,
108109
originalName: tool.name,
109110
namespacedName: namespacedName,
110111
description: tool.description || '',
111-
inputSchema: tool.inputSchema || {}
112+
inputSchema: tool.inputSchema || {},
113+
serverSlug: serverSlug
112114
};
113115

114116
this.toolCache.set(namespacedName, cachedTool);
@@ -272,16 +274,4 @@ export class StdioToolDiscoveryManager {
272274
return stats;
273275
}
274276

275-
/**
276-
* Extract server slug from installation name
277-
* Examples:
278-
* "filesystem-john-R36no6FGoMFEZO9nWJJLT" -> "filesystem"
279-
* "context7-alice-S47mp8GHpNGFZP0oWKKMU" -> "context7"
280-
*/
281-
private extractServerSlug(installationName: string): string {
282-
// Installation name format: {server_slug}-{team_slug}-{installation_id}
283-
// Take everything before the first hyphen
284-
const parts = installationName.split('-');
285-
return parts[0] || installationName;
286-
}
287277
}

services/satellite/src/services/tool-search-service.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,14 @@ export class ToolSearchService {
114114
* Flatten unified tools into searchable format
115115
*/
116116
private flattenTools(tools: UnifiedCachedTool[]): SearchableTool[] {
117-
return tools.map(tool => {
118-
const serverSlug = this.extractServerSlug(tool.namespacedName);
119-
120-
return {
121-
serverName: tool.serverName,
122-
serverSlug: serverSlug,
123-
toolName: tool.originalName,
124-
namespacedName: tool.namespacedName,
125-
description: tool.description,
126-
transport: tool.transport
127-
};
128-
});
129-
}
130-
131-
/**
132-
* Extract server slug from namespaced name
133-
* Example: "filesystem-read_file" -> "filesystem"
134-
*/
135-
private extractServerSlug(namespacedName: string): string {
136-
const dashIndex = namespacedName.indexOf('-');
137-
if (dashIndex > 0) {
138-
return namespacedName.substring(0, dashIndex);
139-
}
140-
return namespacedName;
117+
return tools.map(tool => ({
118+
serverName: tool.serverName,
119+
serverSlug: tool.serverSlug, // Use stored serverSlug directly
120+
toolName: tool.originalName,
121+
namespacedName: tool.namespacedName,
122+
description: tool.description,
123+
transport: tool.transport
124+
}));
141125
}
142126

143127
/**

services/satellite/src/services/unified-tool-discovery-manager.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import { RuntimeState } from '../process/runtime-state';
1212
export interface UnifiedCachedTool {
1313
serverName: string; // Installation name (e.g., "filesystem-john-abc123")
1414
originalName: string; // Tool name from server (e.g., "read_file")
15-
namespacedName: string; // User-facing name (e.g., "filesystem-read_file")
15+
namespacedName: string; // Namespaced name (e.g., "filesystem:read_file")
1616
description: string; // Tool description
1717
inputSchema: any; // JSON Schema for tool parameters
1818
transport: 'stdio' | 'http' | 'sse'; // Transport type for routing
19+
serverSlug: string; // Server slug for tool_path format (e.g., "brightdata-mcp-1")
1920
discoveredAt?: Date; // When the tool was discovered
2021
}
2122

@@ -171,17 +172,19 @@ export class UnifiedToolDiscoveryManager {
171172
description: tool.description,
172173
inputSchema: tool.inputSchema,
173174
transport: 'http' as const,
175+
serverSlug: tool.serverSlug,
174176
discoveredAt: tool.discoveredAt
175177
})),
176-
178+
177179
// Map stdio tools
178180
...stdioTools.map(tool => ({
179181
serverName: tool.serverName,
180182
originalName: tool.originalName,
181183
namespacedName: tool.namespacedName,
182184
description: tool.description,
183185
inputSchema: tool.inputSchema,
184-
transport: 'stdio' as const
186+
transport: 'stdio' as const,
187+
serverSlug: tool.serverSlug
185188
}))
186189
];
187190

@@ -197,7 +200,8 @@ export class UnifiedToolDiscoveryManager {
197200
if (stdioTool) {
198201
return {
199202
...stdioTool,
200-
transport: 'stdio'
203+
transport: 'stdio',
204+
serverSlug: stdioTool.serverSlug
201205
};
202206
}
203207

@@ -211,6 +215,7 @@ export class UnifiedToolDiscoveryManager {
211215
description: remoteTool.description,
212216
inputSchema: remoteTool.inputSchema,
213217
transport: 'http',
218+
serverSlug: remoteTool.serverSlug,
214219
discoveredAt: remoteTool.discoveredAt
215220
};
216221
}

0 commit comments

Comments
 (0)