diff --git a/src/mcp/tool-bridge.ts b/src/mcp/tool-bridge.ts index 3d4f249..613f2ae 100644 --- a/src/mcp/tool-bridge.ts +++ b/src/mcp/tool-bridge.ts @@ -4,6 +4,8 @@ import type { McpClientManager } from "./client-manager.js"; const log = createLogger("mcp:tool-bridge"); +export const MCP_TOOL_PREFIX = "mcp__"; + interface DiscoveredMcpTool { name: string; serverName: string; @@ -79,7 +81,7 @@ export function buildMcpToolDefinitions(tools: DiscoveredMcpTool[]): any[] { function namespaceMcpTool(serverName: string, toolName: string): string { const sanitizedServer = serverName.replace(/[^a-zA-Z0-9]/g, "_"); const sanitizedTool = toolName.replace(/[^a-zA-Z0-9]/g, "_"); - return `mcp__${sanitizedServer}__${sanitizedTool}`; + return `${MCP_TOOL_PREFIX}${sanitizedServer}__${sanitizedTool}`; } function mcpSchemaToZod(inputSchema: Record | undefined, z: any): any { diff --git a/src/plugin.ts b/src/plugin.ts index 4a174bc..0ef2c7e 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -33,6 +33,7 @@ import { SkillResolver } from "./tools/skills/resolver.js"; import { autoRefreshModels } from "./models/sync.js"; import { readMcpConfigs, readSubagentNames } from "./mcp/config.js"; import { McpClientManager } from "./mcp/client-manager.js"; +import { MCP_TOOL_PREFIX } from "./mcp/tool-bridge.js"; import { buildMcpToolHookEntries, buildMcpToolDefinitions } from "./mcp/tool-bridge.js"; import { createOpencodeClient } from "@opencode-ai/sdk"; import { ToolRegistry as CoreRegistry } from "./tools/core/registry.js"; @@ -93,8 +94,8 @@ export function buildAvailableToolsSystemMessage( } const lines: string[] = [ - "MCP TOOLS — Use via Shell with the `mcptool` CLI.", - "Syntax: mcptool call [json-args]", + `MCP TOOLS — Use via direct tool calls (\`${MCP_TOOL_PREFIX}__\`).`, + "These tools are exposed as first-class tool calls (e.g. mcp__filesystem__read_file).", "", ]; @@ -104,11 +105,6 @@ export function buildAvailableToolsSystemMessage( const paramHint = t.params?.length ? ` (params: ${t.params.join(", ")})` : ""; lines.push(` - ${t.toolName}${paramHint}${t.description ? " — " + t.description : ""}`); } - if (tools.length > 0) { - const ex = tools[0]; - const exArgs = ex.params?.length ? ` '{"${ex.params[0]}":"..."}'` : ""; - lines.push(` Example: mcptool call ${server} ${ex.toolName}${exArgs}`); - } lines.push(""); } diff --git a/tests/unit/plugin-mcp-system-transform.test.ts b/tests/unit/plugin-mcp-system-transform.test.ts index 84e92df..cff0d97 100644 --- a/tests/unit/plugin-mcp-system-transform.test.ts +++ b/tests/unit/plugin-mcp-system-transform.test.ts @@ -12,7 +12,7 @@ describe("Plugin MCP system transform", () => { expect(systemMessage).toContain("skill_search -> search"); }); - it("includes mcptool Shell instructions when summaries provided", () => { + it("includes direct MCP tool call instructions when summaries provided", () => { const systemMessage = buildAvailableToolsSystemMessage( ["read", "write"], [], @@ -37,15 +37,15 @@ describe("Plugin MCP system transform", () => { ], ); - expect(systemMessage).toContain("mcptool call"); + expect(systemMessage).toContain("direct tool calls"); + expect(systemMessage).toContain("mcp__"); expect(systemMessage).toContain("hybrid-memory"); expect(systemMessage).toContain("memory_search"); expect(systemMessage).toContain("memory_stats"); expect(systemMessage).toContain("query, limit"); - expect(systemMessage).toContain("Shell"); }); - it("includes multiple servers in Shell instructions", () => { + it("includes multiple servers in MCP tool instructions", () => { const systemMessage = buildAvailableToolsSystemMessage( [], [],