Merge pull request #4 from evan-fannin/add-disable-MCP-setting

Add disable mcp setting
This commit is contained in:
Evan Fannin 2025-01-22 20:47:35 +08:00 committed by GitHub
commit edda72110e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 14 deletions

View file

@ -49,7 +49,7 @@
"configuration": {
"title": "Cline",
"properties": {
"cline.mcp.includeInPrompt": {
"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."

View file

@ -178,7 +178,7 @@ Usage:
}
${
mcpHub.shouldIncludeInPrompt()
mcpHub.isMcpEnabled()
? `
## 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 (
</diff>
</replace_in_file>
${
mcpHub.shouldIncludeInPrompt()
mcpHub.isMcpEnabled()
? `
## 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.shouldIncludeInPrompt()
mcpHub.isMcpEnabled()
? `
====
@ -881,7 +881,7 @@ CAPABILITIES
: ""
}
${
mcpHub.shouldIncludeInPrompt()
mcpHub.isMcpEnabled()
? `
- 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 +907,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.shouldIncludeInPrompt() ? "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.isMcpEnabled() ? "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 +923,7 @@ RULES
: ""
}
${
mcpHub.shouldIncludeInPrompt()
mcpHub.isMcpEnabled()
? `
- MCP operations should be used one at a time, similar to other tool usage. Wait for confirmation of success before proceeding with additional operations.
`

View file

@ -59,8 +59,8 @@ export class McpHub {
return this.connections.filter((conn) => !conn.server.disabled).map((conn) => conn.server)
}
shouldIncludeInPrompt(): boolean {
return vscode.workspace.getConfiguration("cline.mcp").get("includeInPrompt") ?? true
isMcpEnabled(): boolean {
return vscode.workspace.getConfiguration("cline.mcp").get("enabled") ?? true
}
async getMcpServersPath(): Promise<string> {

View file

@ -12,6 +12,7 @@ type McpViewProps = {
const McpView = ({ onDone }: McpViewProps) => {
const { mcpServers: servers } = useExtensionState()
// const [servers, setServers] = useState<McpServer[]>([
// // Add some mock servers for testing
// {
@ -100,7 +101,7 @@ const McpView = ({ onDone }: McpViewProps) => {
style={{
color: "var(--vscode-foreground)",
fontSize: "13px",
marginBottom: "20px",
marginBottom: "16px",
marginTop: "5px",
}}>
The{" "}
@ -118,7 +119,6 @@ const McpView = ({ onDone }: McpViewProps) => {
</VSCodeLink>
</div>
{/* Server List */}
{servers.length > 0 && (
<div
style={{
@ -132,7 +132,8 @@ const McpView = ({ onDone }: McpViewProps) => {
</div>
)}
{/* Edit Settings Button */}
{/* Server Configuration Button */}
<div style={{ marginTop: "10px", width: "100%" }}>
<VSCodeButton
appearance="secondary"
@ -140,11 +141,25 @@ const McpView = ({ onDone }: McpViewProps) => {
onClick={() => {
vscode.postMessage({ type: "openMcpSettings" })
}}>
<span className="codicon codicon-edit" style={{ marginRight: "6px" }}></span>
Edit MCP Settings
<span className="codicon codicon-server" style={{ marginRight: "6px" }}></span>
Configure MCP Servers
</VSCodeButton>
</div>
{/* Advanced Settings Link */}
<div style={{ textAlign: "center", marginTop: "5px" }}>
<VSCodeLink
onClick={() => {
vscode.postMessage({
type: "openExtensionSettings",
text: "cline.mcp",
})
}}
style={{ fontSize: "12px" }}>
Edit Advanced MCP Settings...
</VSCodeLink>
</div>
{/* Bottom padding */}
<div style={{ height: "20px" }} />
</div>