Skip to content

Commit 260accb

Browse files
committed
fix: improve MCP tool prompt clarity to prevent format confusion
- Added explicit warnings about NOT using direct tool name format - Added clear examples showing incorrect vs correct usage - Emphasized the requirement to always use use_mcp_tool wrapper - Updated MCP servers section to reinforce proper format This should help prevent AI models from forgetting to wrap MCP tool calls in the proper use_mcp_tool format, addressing issue #8507
1 parent 97f9686 commit 260accb

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ The Model Context Protocol (MCP) enables communication between the system and MC
5858
5959
# Connected MCP Servers
6060
61-
When a server is connected, you can use the server's tools via the \`use_mcp_tool\` tool, and access the server's resources via the \`access_mcp_resource\` tool.
61+
When a server is connected, you MUST use the server's tools via the \`use_mcp_tool\` wrapper, and access the server's resources via the \`access_mcp_resource\` wrapper.
62+
63+
**CRITICAL**: Never call MCP tools directly by their tool name. Always use the \`use_mcp_tool\` wrapper format:
64+
- ❌ WRONG: \`<tool_name>...\</tool_name>\`
65+
- ✅ CORRECT: \`<use_mcp_tool><server_name>...\</server_name><tool_name>...\</tool_name><arguments>...\</arguments>\</use_mcp_tool>\`
6266
6367
${connectedServers}`
6468

src/core/prompts/tools/use-mcp-tool.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,58 @@ export function getUseMcpToolDescription(args: ToolArgs): string | undefined {
66
}
77
return `## use_mcp_tool
88
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.
9+
10+
**IMPORTANT**: You MUST always use the \`use_mcp_tool\` wrapper format shown below. Do NOT call MCP tools directly by their tool name.
11+
912
Parameters:
1013
- server_name: (required) The name of the MCP server providing the tool
1114
- tool_name: (required) The name of the tool to execute
1215
- arguments: (required) A JSON object containing the tool's input parameters, following the tool's input schema
13-
Usage:
16+
17+
Correct Usage Format:
1418
<use_mcp_tool>
1519
<server_name>server name here</server_name>
1620
<tool_name>tool name here</tool_name>
1721
<arguments>
1822
{
19-
"param1": "value1",
20-
"param2": "value2"
23+
"param1": "value1",
24+
"param2": "value2"
2125
}
2226
</arguments>
2327
</use_mcp_tool>
2428
25-
Example: Requesting to use an MCP tool
29+
❌ INCORRECT - Do NOT use this format:
30+
<get_pull_request>
31+
<owner>username</owner>
32+
<repo>repository</repo>
33+
<pullNumber>123</pullNumber>
34+
</get_pull_request>
35+
36+
✅ CORRECT - Always use this format:
37+
<use_mcp_tool>
38+
<server_name>github</server_name>
39+
<tool_name>get_pull_request</tool_name>
40+
<arguments>
41+
{
42+
"owner": "username",
43+
"repo": "repository",
44+
"pullNumber": 123
45+
}
46+
</arguments>
47+
</use_mcp_tool>
48+
49+
Example: Using a weather MCP tool
2650
2751
<use_mcp_tool>
2852
<server_name>weather-server</server_name>
2953
<tool_name>get_forecast</tool_name>
3054
<arguments>
3155
{
32-
"city": "San Francisco",
33-
"days": 5
56+
"city": "San Francisco",
57+
"days": 5
3458
}
3559
</arguments>
36-
</use_mcp_tool>`
60+
</use_mcp_tool>
61+
62+
Remember: ALWAYS wrap MCP tool calls in the \`use_mcp_tool\` format, never call them directly by their tool name.`
3763
}

0 commit comments

Comments
 (0)