Skip to content

Commit 1b57b87

Browse files
committed
feat(mcp): omit mcp prompt when no servers
1 parent 38d8edf commit 1b57b87

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/core/prompts/sections/capabilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CAPABILITIES
3333
? "\n- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.\n - For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser."
3434
: ""
3535
}${
36-
mcpHub
36+
mcpHub && mcpHub.getAllServers().length > 0
3737
? `
3838
- 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.
3939
`

src/core/prompts/sections/mcp-servers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export async function getMcpServersSection(
66
diffStrategy?: DiffStrategy,
77
enableMcpServerCreation?: boolean,
88
): Promise<string> {
9-
if (!mcpHub) {
9+
if (!mcpHub || mcpHub.getAllServers().length === 0) {
1010
return ""
1111
}
1212

src/core/task/Task.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,8 @@ export class Task extends EventEmitter<ClineEvents> {
16081608
})
16091609
}
16101610

1611+
const hasMcpServers = (mcpHub?.getAllServers().length ?? 0) > 0
1612+
16111613
const rooIgnoreInstructions = this.rooIgnoreController?.getInstructions()
16121614

16131615
const state = await this.providerRef.deref()?.getState()
@@ -1637,7 +1639,7 @@ export class Task extends EventEmitter<ClineEvents> {
16371639
provider.context,
16381640
this.cwd,
16391641
(this.api.getModel().info.supportsComputerUse ?? false) && (browserToolEnabled ?? true),
1640-
mcpHub,
1642+
hasMcpServers ? mcpHub : undefined,
16411643
this.diffStrategy,
16421644
browserViewportSize,
16431645
mode,

src/core/webview/generateSystemPrompt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ export const generateSystemPrompt = async (provider: ClineProvider, message: Web
6363
// and browser tools are enabled in settings
6464
const canUseBrowserTool = modelSupportsComputerUse && modeSupportsBrowser && (browserToolEnabled ?? true)
6565

66+
const mcpHub = provider.getMcpHub()
67+
const hasMcpServers = (mcpHub?.getAllServers().length ?? 0) > 0
68+
6669
const systemPrompt = await SYSTEM_PROMPT(
6770
provider.context,
6871
cwd,
6972
canUseBrowserTool,
70-
mcpEnabled ? provider.getMcpHub() : undefined,
73+
mcpEnabled && hasMcpServers ? mcpHub : undefined,
7174
diffStrategy,
7275
browserViewportSize ?? "900x600",
7376
mode,

0 commit comments

Comments
 (0)