58 lines
1.8 KiB
Markdown
58 lines
1.8 KiB
Markdown
---
|
|
name: ck-use-mcp
|
|
description: Execute operations via Model Context Protocol (MCP) servers. Use for MCP tool calls, resource access, prompt execution, integrating external services, or offloading tasks to preserve context budget.
|
|
---
|
|
|
|
# Use MCP — Execute MCP Operations
|
|
|
|
Executes MCP operations via Gemini CLI to preserve context budget, with fallback to direct MCP tool use.
|
|
|
|
## When to Use
|
|
|
|
- Executing tools from connected MCP servers
|
|
- Accessing MCP resources or prompts
|
|
- Offloading external service calls to preserve main context budget
|
|
- Integrating third-party services via MCP protocol
|
|
|
|
## Don't Use When
|
|
|
|
- Task can be done directly without MCP (no external service needed)
|
|
- No MCP servers are configured
|
|
|
|
## Primary: Gemini CLI Execution
|
|
|
|
Execute via stdin pipe (NOT `-p` flag — deprecated, skips MCP init):
|
|
|
|
```bash
|
|
echo "<task>. Return JSON only per GEMINI.md instructions." | gemini -y -m <gemini.model>
|
|
```
|
|
|
|
Read model from `$HOME/.claude/.ck.json`: `gemini.model` (default: `gemini-2.5-flash-preview`)
|
|
|
|
Use `-y` flag to auto-approve tool execution.
|
|
|
|
**Expected output format:**
|
|
```json
|
|
{"server": "name", "tool": "name", "success": true, "result": <data>, "error": null}
|
|
```
|
|
|
|
## Anti-Pattern (Never Use)
|
|
|
|
```bash
|
|
# BROKEN — -p flag skips MCP server connections
|
|
gemini -y -m model -p "..."
|
|
```
|
|
|
|
## Fallback: Direct MCP Tool Use
|
|
|
|
If Gemini CLI is unavailable:
|
|
1. Discover available MCP tools from connected servers
|
|
2. Execute the appropriate tool directly
|
|
3. If no suitable tool found, report back and move on — do not create new scripts
|
|
|
|
## Notes
|
|
|
|
- `GEMINI.md` is auto-loaded from project root, enforcing JSON-only response format
|
|
- Use `ck-mcp-builder` skill if MCP server scripts have issues
|
|
- Sub-process can only use existing MCP tools — never create new scripts as fallback
|