diff --git a/core/config/load.ts b/core/config/load.ts index da95ec5a8..5400bc81b 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -63,6 +63,8 @@ import { } from "../util/paths"; import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; +import { useHub } from "../control-plane/env"; +import { localPathToUri } from "../util/pathToUri"; import { defaultContextProvidersJetBrains, defaultContextProvidersVsCode, @@ -70,8 +72,6 @@ import { defaultSlashCommandsVscode, } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; -import { useHub } from "../control-plane/env"; -import { localPathToUri } from "../util/pathToUri"; import { modifyContinueConfigWithSharedConfig } from "./sharedConfig"; import { validateConfig } from "./validation.js"; @@ -517,6 +517,8 @@ async function intermediateToFinalConfig( continueConfig, mcpId, abortController.signal, + "MCP Server", + server.faviconUrl, ); if (mcpError) { errors.push(mcpError); diff --git a/core/core.ts b/core/core.ts index 73ff29f8f..32be84cda 100644 --- a/core/core.ts +++ b/core/core.ts @@ -944,13 +944,14 @@ export class Core { const llm = await this.configHandler.llmFromTitle(selectedModelTitle); const contextItems = await callTool( - tool.uri ?? tool.function.name, + tool, JSON.parse(toolCall.function.arguments || "{}"), { ide: this.ide, llm, fetch: (url, init) => fetchwithRequestOptions(url, init, config.requestOptions), + tool, }, ); diff --git a/core/index.d.ts b/core/index.d.ts index ca9536911..b1d15847a 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -859,6 +859,7 @@ export interface ToolExtras { ide: IDE; llm: ILLM; fetch: FetchFunction; + tool: Tool; } export interface Tool { diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 706fa57d9..f3b565285 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -1,4 +1,4 @@ -import { ContextItem, ToolExtras } from ".."; +import { ContextItem, Tool, ToolExtras } from ".."; import { MCPManagerSingleton } from "../context/mcp"; import { BuiltInToolNames } from "./builtIn"; @@ -86,13 +86,18 @@ async function callToolFromUri( throw new Error(`Failed to call tool: ${toolName}`); } - return (response.content as any).map((item: any) => { + return (response.content as any).map((item: any): ContextItem => { if (item.type !== "text") { throw new Error( `Continue received item of type "${item.type}" from MCP tool, but currently only supports "text".`, ); } - return { name: toolName, description: toolName, content: item.text }; + return { + name: extras.tool.displayTitle, + description: "Tool output", + content: item.text, + icon: extras.tool.faviconUrl, + }; }); default: @@ -101,10 +106,12 @@ async function callToolFromUri( } export async function callTool( - uri: string, + tool: Tool, args: any, extras: ToolExtras, ): Promise { + const uri = tool.uri ?? tool.function.name; + switch (uri) { case BuiltInToolNames.ReadFile: return await readFileImpl(args, extras);