From b980f24f65c1e915988ed3b9081a89026dde8c05 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 17 Mar 2025 14:22:03 -0700 Subject: [PATCH 1/4] mcp progress --- core/tools/callTool.ts | 46 +++++++++++++++++++++------- extensions/vscode/package-lock.json | 6 ++-- gui/src/pages/config-error/index.tsx | 2 +- gui/src/redux/thunks/callTool.ts | 2 +- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 959752af1..5c1b0a1e7 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -86,18 +86,42 @@ async function callToolFromUri( throw new Error(`Failed to call tool: ${toolName}`); } - 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".`, - ); + const contextItems: ContextItem[] = []; + return (response.content as any).forEach((item: any) => { + if (item.type === "text") { + contextItems.push({ + name: extras.tool.displayTitle, + description: "Tool output", + content: item.text, + icon: extras.tool.faviconUrl, + }); + } else if (item.type === "resource") { + // TODO resource change subscribers https://modelcontextprotocol.io/docs/concepts/resources + if (item.resource?.blob) { + contextItems.push({ + name: extras.tool.displayTitle, + description: "MCP Item Error", + content: + "Error: tool call received unsupported blob resource item", + icon: extras.tool.faviconUrl, + }); + } + // TODO account for mimetype? // const mimeType = item.resource.mimeType + // const uri = item.resource.uri; + contextItems.push({ + name: extras.tool.displayTitle, + description: "Tool output", + content: item.resource.text, + icon: extras.tool.faviconUrl, + }); + } else { + contextItems.push({ + name: extras.tool.displayTitle, + description: "MCP Item Error", + content: `Error: tool call received unsupported item of type "${item.type}"`, + icon: extras.tool.faviconUrl, + }); } - return { - name: extras.tool.displayTitle, - description: "Tool output", - content: item.text, - icon: extras.tool.faviconUrl, - }; }); default: diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index a2492d0c8..d39bb87a3 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.11", + "version": "1.1.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.11", + "version": "1.1.12", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.60", + "@continuedev/config-yaml": "^1.0.61", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/src/pages/config-error/index.tsx b/gui/src/pages/config-error/index.tsx index 3efad9d30..7bd3a3050 100644 --- a/gui/src/pages/config-error/index.tsx +++ b/gui/src/pages/config-error/index.tsx @@ -33,7 +33,7 @@ export default function ConfigErrorPage() {

Config Errors

- Please resolve the following errors in your config.json file. + Please resolve the following errors in your assistant configuration.

{sortedErrors.length > 0 ? ( diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 75b075288..ac931f9cb 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -30,7 +30,7 @@ export const callTool = createAsyncThunk( } dispatch(setCalling()); - + debugger; const result = await extra.ideMessenger.request("tools/call", { toolCall: toolCallState.toolCall, selectedModelTitle: defaultModel.title, From 7ab4f1d42210abe07089ada687d5ba4b09e71377 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 17 Mar 2025 15:36:11 -0700 Subject: [PATCH 2/4] restorepackagelock --- extensions/vscode/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index d39bb87a3..a2492d0c8 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.12", + "version": "1.1.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.12", + "version": "1.1.11", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.61", + "@continuedev/config-yaml": "^1.0.60", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", From 7a79473417531c676aedb1e23ca3496b5dd3da67 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 17 Mar 2025 15:37:05 -0700 Subject: [PATCH 3/4] fix return --- core/tools/callTool.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 5c1b0a1e7..8d4b1f1b3 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -87,7 +87,7 @@ async function callToolFromUri( } const contextItems: ContextItem[] = []; - return (response.content as any).forEach((item: any) => { + (response.content as any).forEach((item: any) => { if (item.type === "text") { contextItems.push({ name: extras.tool.displayTitle, @@ -123,7 +123,7 @@ async function callToolFromUri( }); } }); - + return contextItems; default: throw new Error(`Unsupported protocol: ${parsedUri?.protocol}`); } From aa8d964d60cfe6ac3dda4daea90560b4ba206dfd Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 17 Mar 2025 15:37:35 -0700 Subject: [PATCH 4/4] cleanup --- gui/src/redux/thunks/callTool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index ac931f9cb..75b075288 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -30,7 +30,7 @@ export const callTool = createAsyncThunk( } dispatch(setCalling()); - debugger; + const result = await extra.ideMessenger.request("tools/call", { toolCall: toolCallState.toolCall, selectedModelTitle: defaultModel.title,