Skip to content

Commit 8c256a6

Browse files
authored
Merge pull request RooCodeInc#1419 from evan-fannin/partially-enable-mcp
Add server use only MCP setting
2 parents 66dd2e1 + b1bcbfe commit 8c256a6

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,20 @@
142142
},
143143
"description": "Settings for VSCode Language Model API"
144144
},
145-
"cline.mcp.enabled": {
146-
"type": "boolean",
147-
"default": true,
148-
"description": "Include MCP server functionality in AI prompts. When disabled, the AI will not be aware of MCP capabilities. This saves context window tokens."
145+
"cline.mcp.mode": {
146+
"type": "string",
147+
"enum": [
148+
"enabled",
149+
"mcp-tools-only",
150+
"disabled"
151+
],
152+
"enumDescriptions": [
153+
"Full MCP functionality including server use and build instructions",
154+
"Enable MCP server use but exclude build instructions from AI prompts to save tokens",
155+
"Disable all MCP functionality"
156+
],
157+
"default": "enabled",
158+
"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."
149159
}
150160
}
151161
}

src/core/prompts/system.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Usage:
178178
}
179179
180180
${
181-
mcpHub.isMcpEnabled()
181+
mcpHub.getMode() !== "disabled"
182182
? `
183183
## use_mcp_tool
184184
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 (
310310
</diff>
311311
</replace_in_file>
312312
${
313-
mcpHub.isMcpEnabled()
313+
mcpHub.getMode() !== "disabled"
314314
? `
315315
316316
## 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
357357
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.
358358
359359
${
360-
mcpHub.isMcpEnabled()
360+
mcpHub.getMode() !== "disabled"
361361
? `
362362
====
363363
@@ -405,8 +405,13 @@ ${
405405
})
406406
.join("\n\n")}`
407407
: "(No MCP servers currently connected)"
408+
}`
409+
: ""
408410
}
409411
412+
${
413+
mcpHub.getMode() === "enabled"
414+
? `
410415
## Creating an MCP Server
411416
412417
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
769774
`
770775
: ""
771776
}
777+
772778
====
773779
774780
EDITING FILES
@@ -881,7 +887,7 @@ CAPABILITIES
881887
: ""
882888
}
883889
${
884-
mcpHub.isMcpEnabled()
890+
mcpHub.getMode() !== "disabled"
885891
? `
886892
- 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.
887893
`
@@ -907,7 +913,7 @@ RULES
907913
- 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.
908914
- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.${
909915
supportsComputerUse
910-
? `\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." : ""}`
916+
? `\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." : ""}`
911917
: ""
912918
}
913919
- 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
923929
: ""
924930
}
925931
${
926-
mcpHub.isMcpEnabled()
932+
mcpHub.getMode() !== "disabled"
927933
? `
928934
- MCP operations should be used one at a time, similar to other tool usage. Wait for confirmation of success before proceeding with additional operations.
929935
`

src/services/mcp/McpHub.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ import * as path from "path"
1515
import * as vscode from "vscode"
1616
import { z } from "zod"
1717
import { ClineProvider, GlobalFileNames } from "../../core/webview/ClineProvider"
18-
import { McpResource, McpResourceResponse, McpResourceTemplate, McpServer, McpTool, McpToolCallResponse } from "../../shared/mcp"
18+
import {
19+
McpMode,
20+
McpResource,
21+
McpResourceResponse,
22+
McpResourceTemplate,
23+
McpServer,
24+
McpTool,
25+
McpToolCallResponse,
26+
} from "../../shared/mcp"
1927
import { fileExistsAtPath } from "../../utils/fs"
2028
import { arePathsEqual } from "../../utils/path"
2129

@@ -59,8 +67,8 @@ export class McpHub {
5967
return this.connections.filter((conn) => !conn.server.disabled).map((conn) => conn.server)
6068
}
6169

62-
isMcpEnabled(): boolean {
63-
return vscode.workspace.getConfiguration("cline.mcp").get("enabled") ?? true
70+
getMode(): McpMode {
71+
return vscode.workspace.getConfiguration("cline.mcp").get<McpMode>("mode", "enabled")
6472
}
6573

6674
async getMcpServersPath(): Promise<string> {

src/shared/mcp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export type McpMode = "enabled" | "mcp-tools-only" | "disabled"
2+
13
export type McpServer = {
24
name: string
35
config: string

0 commit comments

Comments
 (0)