Skip to content

Commit 37b6b2f

Browse files
committed
fix(mcp-cli): add config resolution to agent prompts
Agents now detect mcp_servers.json location before invoking mcp-cli: 1. .opencode/mcp_servers.json (project) 2. ./mcp_servers.json (project root) 3. ~/.config/opencode/mcp_servers.json (user) Uses -c flag to pass config path explicitly.
1 parent 5db6729 commit 37b6b2f

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/agents/orchestrator-sisyphus.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,27 @@ Search **external references** (docs, OSS, web). Fire proactively when unfamilia
281281
282282
### MCP Servers (via mcp-cli)
283283
284-
Use \`mcp-cli\` via Bash tool for MCP server operations:
284+
Use \`mcp-cli\` via Bash tool for MCP server operations.
285+
286+
**Config Resolution:** mcp-cli needs a config file. Check in order and use first found:
287+
1. \`.opencode/mcp_servers.json\` (project)
288+
2. \`./mcp_servers.json\` (project root)
289+
3. \`~/.config/opencode/mcp_servers.json\` (user)
285290
286291
\`\`\`bash
287-
mcp-cli # List all servers and tools
288-
mcp-cli <server> -d # Show server tools with descriptions
289-
mcp-cli <server>/<tool> # Get tool JSON schema
290-
mcp-cli <server>/<tool> '<json>' # Call tool with arguments
292+
# Determine config path first
293+
MCP_CONFIG="$([ -f .opencode/mcp_servers.json ] && echo '.opencode/mcp_servers.json' || ([ -f mcp_servers.json ] && echo 'mcp_servers.json' || echo ~/.config/opencode/mcp_servers.json))"
294+
295+
# Then use with -c flag
296+
mcp-cli -c "$MCP_CONFIG" # List all servers and tools
297+
mcp-cli -c "$MCP_CONFIG" <server> -d # Show server tools with descriptions
298+
mcp-cli -c "$MCP_CONFIG" <server>/<tool> # Get tool JSON schema
299+
mcp-cli -c "$MCP_CONFIG" <server>/<tool> '<json>' # Call tool with arguments
291300
\`\`\`
292301
293302
**Example:**
294303
\`\`\`bash
295-
mcp-cli context7/query-docs '{"libraryId": "/vercel/next.js", "query": "app router"}'
304+
mcp-cli -c "$MCP_CONFIG" context7/query-docs '{"libraryId": "/vercel/next.js", "query": "app router"}'
296305
\`\`\`
297306
298307
**Available MCP servers:**

src/agents/sisyphus.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,27 @@ sisyphus_task(category="visual", ...)
243243

244244
const SISYPHUS_MCP_CLI_SECTION = `### MCP Servers (via mcp-cli)
245245
246-
Use \`mcp-cli\` via Bash tool for MCP server operations:
246+
Use \`mcp-cli\` via Bash tool for MCP server operations.
247+
248+
**Config Resolution:** mcp-cli needs a config file. Check in order and use first found:
249+
1. \`.opencode/mcp_servers.json\` (project)
250+
2. \`./mcp_servers.json\` (project root)
251+
3. \`~/.config/opencode/mcp_servers.json\` (user)
247252
248253
\`\`\`bash
249-
mcp-cli # List all servers and tools
250-
mcp-cli <server> -d # Show server tools with descriptions
251-
mcp-cli <server>/<tool> # Get tool JSON schema
252-
mcp-cli <server>/<tool> '<json>' # Call tool with arguments
254+
# Determine config path first
255+
MCP_CONFIG="\$([ -f .opencode/mcp_servers.json ] && echo '.opencode/mcp_servers.json' || ([ -f mcp_servers.json ] && echo 'mcp_servers.json' || echo ~/.config/opencode/mcp_servers.json))"
256+
257+
# Then use with -c flag
258+
mcp-cli -c "$MCP_CONFIG" # List all servers and tools
259+
mcp-cli -c "$MCP_CONFIG" <server> -d # Show server tools with descriptions
260+
mcp-cli -c "$MCP_CONFIG" <server>/<tool> # Get tool JSON schema
261+
mcp-cli -c "$MCP_CONFIG" <server>/<tool> '<json>' # Call tool with arguments
253262
\`\`\`
254263
255264
**Example:**
256265
\`\`\`bash
257-
mcp-cli context7/query-docs '{"libraryId": "/vercel/next.js", "query": "app router"}'
266+
mcp-cli -c "$MCP_CONFIG" context7/query-docs '{"libraryId": "/vercel/next.js", "query": "app router"}'
258267
\`\`\`
259268
260269
**Available MCP servers:**

0 commit comments

Comments
 (0)