Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/prompts/sections/mcp-servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ The Model Context Protocol (MCP) enables communication between the system and MC

# Connected MCP Servers

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.
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.

**CRITICAL**: Never call MCP tools directly by their tool name. Always use the \`use_mcp_tool\` wrapper format:
- ❌ WRONG: \`<tool_name>...\</tool_name>\`
- ✅ CORRECT: \`<use_mcp_tool><server_name>...\</server_name><tool_name>...\</tool_name><arguments>...\</arguments>\</use_mcp_tool>\`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The inline example uses backslashes before closing XML tags (e.g., </server_name>). Within code spans, the backslash will be literal and may lead models to emit a backslash in their tool calls. Remove the backslashes so the example shows proper tags: </server_name>, </tool_name>, , </use_mcp_tool>. This also aligns with the examples in use-mcp-tool.ts.


${connectedServers}`

Expand Down
40 changes: 33 additions & 7 deletions src/core/prompts/tools/use-mcp-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,58 @@ export function getUseMcpToolDescription(args: ToolArgs): string | undefined {
}
return `## 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.

**IMPORTANT**: You MUST always use the \`use_mcp_tool\` wrapper format shown below. Do NOT call MCP tools directly by their tool name.

Parameters:
- server_name: (required) The name of the MCP server providing the tool
- tool_name: (required) The name of the tool to execute
- arguments: (required) A JSON object containing the tool's input parameters, following the tool's input schema
Usage:

Correct Usage Format:
<use_mcp_tool>
<server_name>server name here</server_name>
<tool_name>tool name here</tool_name>
<arguments>
{
"param1": "value1",
"param2": "value2"
"param1": "value1",
"param2": "value2"
}
</arguments>
</use_mcp_tool>

Example: Requesting to use an MCP tool
❌ INCORRECT - Do NOT use this format:
<get_pull_request>
<owner>username</owner>
<repo>repository</repo>
<pullNumber>123</pullNumber>
</get_pull_request>

✅ CORRECT - Always use this format:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>get_pull_request</tool_name>
<arguments>
{
"owner": "username",
"repo": "repository",
"pullNumber": 123
}
</arguments>
</use_mcp_tool>

Example: Using a weather MCP tool

<use_mcp_tool>
<server_name>weather-server</server_name>
<tool_name>get_forecast</tool_name>
<arguments>
{
"city": "San Francisco",
"days": 5
"city": "San Francisco",
"days": 5
}
</arguments>
</use_mcp_tool>`
</use_mcp_tool>

Remember: ALWAYS wrap MCP tool calls in the \`use_mcp_tool\` format, never call them directly by their tool name.`
}
Loading