227
228
private async _callToolForServer(serverId: string, name: string, args: Record<string, unknown>, chatSessionResource?: string, token: CancellationToken = CancellationToken.None): Promise<MCP.CallToolResult> {
229
>
this._logService.debug(`[McpGateway][ToolBroker] callToolForServer '${serverId}' tool '${name}' with args: ${JSON.stringify(args)}`);
mcpGatewayToolBrokerChannel.ts
230
>
231
>
const server = this._getServerById(serverId);
232
>
if (!server) {
233
throw new Error(`Unknown server: ${serverId}`);
234
}
236
>
const tool = server.tools.get().find(t =>
237
>
t.definition.name === name && (t.visibility & McpToolVisibility.Model)
238
>
);
239
>
if (!tool) {
240
throw new Error(`Unknown tool '${name}' on server '${serverId}'`);
241
}
243
>
const context = chatSessionResource ? { chatSessionResource: URI.parse(chatSessionResource) } : undefined;
244
>
const result = await tool.call(args, context, token);
245
>
this._logService.debug(`[McpGateway][ToolBroker] Tool '${name}' on '${serverId}' completed (isError=${result.isError ?? false}, content blocks=${result.content.length})`);
246
>
return result;
247
>
}
248
249
private async _listResourcesForServer(serverId: string): Promise<readonly MCP.Resource[]> {