diff --git a/package.json b/package.json index d88d82305c..ad74d725b5 100644 --- a/package.json +++ b/package.json @@ -142,10 +142,20 @@ }, "description": "Settings for VSCode Language Model API" }, - "cline.mcp.enabled": { - "type": "boolean", - "default": true, - "description": "Include MCP server functionality in AI prompts. When disabled, the AI will not be aware of MCP capabilities. This saves context window tokens." + "cline.mcp.mode": { + "type": "string", + "enum": [ + "enabled", + "mcp-tools-only", + "disabled" + ], + "enumDescriptions": [ + "Full MCP functionality including server use and build instructions", + "Enable MCP server use but exclude build instructions from AI prompts to save tokens", + "Disable all MCP functionality" + ], + "default": "enabled", + "description": "Control MCP server functionality and its inclusion in AI prompts. When disabled, Cline will not be aware of MCP capabilities, saving model context window tokens." } } } diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts index af3d9b9f46..213ce107a3 100644 --- a/src/core/prompts/system.ts +++ b/src/core/prompts/system.ts @@ -178,7 +178,7 @@ Usage: } ${ - mcpHub.isMcpEnabled() + mcpHub.getMode() !== "disabled" ? ` ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. @@ -310,7 +310,7 @@ return ( ${ - mcpHub.isMcpEnabled() + mcpHub.getMode() !== "disabled" ? ` ## Example 4: Requesting to use an MCP tool @@ -357,7 +357,7 @@ It is crucial to proceed step-by-step, waiting for the user's message after each By waiting for and carefully considering the user's response after each tool use, you can react accordingly and make informed decisions about how to proceed with the task. This iterative process helps ensure the overall success and accuracy of your work. ${ - mcpHub.isMcpEnabled() + mcpHub.getMode() !== "disabled" ? ` ==== @@ -405,8 +405,13 @@ ${ }) .join("\n\n")}` : "(No MCP servers currently connected)" +}` + : "" } +${ + mcpHub.getMode() === "enabled" + ? ` ## Creating an MCP Server The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. You have the ability to create an MCP server and add it to a configuration file that will then expose the tools and resources for you to use with \`use_mcp_tool\` and \`access_mcp_resource\`. @@ -769,6 +774,7 @@ Remember: The MCP documentation and example provided above are to help you under ` : "" } + ==== EDITING FILES @@ -881,7 +887,7 @@ CAPABILITIES : "" } ${ - mcpHub.isMcpEnabled() + mcpHub.getMode() !== "disabled" ? ` - You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively. ` @@ -907,7 +913,7 @@ RULES - The user may provide a file's contents directly in their message, in which case you shouldn't use the read_file tool to get the file contents again since you already have it. - Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.${ supportsComputerUse - ? `\n- The user may ask generic non-development tasks, such as "what\'s the latest news" or "look up the weather in San Diego", in which case you might use the browser_action tool to complete the task if it makes sense to do so, rather than trying to create a website or using curl to answer the question.${mcpHub.isMcpEnabled() ? "However, if an available MCP server tool or resource can be used instead, you should prefer to use it over browser_action." : ""}` + ? `\n- The user may ask generic non-development tasks, such as "what\'s the latest news" or "look up the weather in San Diego", in which case you might use the browser_action tool to complete the task if it makes sense to do so, rather than trying to create a website or using curl to answer the question.${mcpHub.getMode() !== "disabled" ? "However, if an available MCP server tool or resource can be used instead, you should prefer to use it over browser_action." : ""}` : "" } - NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user. @@ -923,7 +929,7 @@ RULES : "" } ${ - mcpHub.isMcpEnabled() + mcpHub.getMode() !== "disabled" ? ` - MCP operations should be used one at a time, similar to other tool usage. Wait for confirmation of success before proceeding with additional operations. ` diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index dba50d54f6..ab58b18582 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -15,7 +15,15 @@ import * as path from "path" import * as vscode from "vscode" import { z } from "zod" import { ClineProvider, GlobalFileNames } from "../../core/webview/ClineProvider" -import { McpResource, McpResourceResponse, McpResourceTemplate, McpServer, McpTool, McpToolCallResponse } from "../../shared/mcp" +import { + McpMode, + McpResource, + McpResourceResponse, + McpResourceTemplate, + McpServer, + McpTool, + McpToolCallResponse, +} from "../../shared/mcp" import { fileExistsAtPath } from "../../utils/fs" import { arePathsEqual } from "../../utils/path" @@ -59,8 +67,8 @@ export class McpHub { return this.connections.filter((conn) => !conn.server.disabled).map((conn) => conn.server) } - isMcpEnabled(): boolean { - return vscode.workspace.getConfiguration("cline.mcp").get("enabled") ?? true + getMode(): McpMode { + return vscode.workspace.getConfiguration("cline.mcp").get("mode", "enabled") } async getMcpServersPath(): Promise { diff --git a/src/shared/mcp.ts b/src/shared/mcp.ts index b84f33d21a..863a93201b 100644 --- a/src/shared/mcp.ts +++ b/src/shared/mcp.ts @@ -1,3 +1,5 @@ +export type McpMode = "enabled" | "mcp-tools-only" | "disabled" + export type McpServer = { name: string config: string