home / skills / duc01226 / easyplatform / use-mcp

use-mcp skill

/.claude/skills/use-mcp

This skill executes MCP operations through the Gemini CLI using stdin piping to preserve context budget and ensure JSON responses.

npx playbooks add skill duc01226/easyplatform --skill use-mcp

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.7 KB
---
name: use-mcp
description: "[Tooling & Meta] Utilize tools of Model Context Protocol (MCP) servers"
argument-hint: [task]
infer: true
---

Execute MCP operations via **Gemini CLI** to preserve context budget.

## Execution Steps

1. **Execute task via Gemini CLI** (using stdin pipe for MCP support):

   ```bash
   # IMPORTANT: Use stdin piping, NOT -p flag (deprecated, skips MCP init)
   echo "$ARGUMENTS. Return JSON only per GEMINI.md instructions." | gemini -y -m gemini-2.5-flash
   ```

2. **Fallback to mcp-manager subagent** (if Gemini CLI unavailable):
   - Use `mcp-manager` subagent to discover and execute tools
   - If the subagent got issues with the scripts of `mcp-management` skill, use `mcp-builder` skill to fix them
   - **DO NOT** create ANY new scripts
   - The subagent can only use MCP tools if any to achieve this task
   - If the subagent can't find any suitable tools, just report it back to the main agent to move on to the next step

## IMPORTANT Task Planning Notes

- Always plan and break many small todo tasks
- Always add a final review todo task to review the works done at the end to find any fix or enhancement needed

## Anti-Pattern (DO NOT USE)

```bash
# BROKEN - deprecated -p flag skips MCP server connections!
gemini -y -m gemini-2.5-flash -p "..."
```

## Important Notes

- **MUST use stdin piping** - the deprecated `-p` flag skips MCP initialization
- Use `-y` flag to auto-approve tool execution
- **GEMINI.md auto-loaded**: Gemini CLI automatically loads `GEMINI.md` from project root, enforcing JSON-only response format
- **Parseable output**: Responses are structured JSON: `{"server":"name","tool":"name","success":true,"result":<data>,"error":null}`

Overview

This skill provides a concise workflow for executing Model Context Protocol (MCP) operations using the Gemini CLI while preserving context budget. It emphasizes using stdin piping, automatic JSON-only responses, and a fallback through the mcp-manager subagent when the CLI is unavailable. The goal is predictable, parseable tool execution and clear task planning.

How this skill works

Commands are executed by piping arguments into the Gemini CLI so the MCP initialization runs and the CLI enforces JSON-only output. If the Gemini CLI cannot be used, the mcp-manager subagent is invoked to discover and run available MCP tools; if that subagent has script issues, mcp-builder is used to repair them. Every execution uses the -y flag to auto-approve tool runs and returns a structured JSON object for downstream parsing.

When to use it

  • Run MCP tools while preserving model context and minimizing token usage.
  • Automate tool execution in a pipeline that requires strict JSON output for parsing.
  • Fallback to subagent discovery when the Gemini CLI is not installed or fails.
  • When you need to break tasks into many small steps and include a final review.
  • Enforce reproducible, machine-readable results from tool executions.

Best practices

  • Always pipe input via stdin; never use the deprecated -p flag.
  • Include clear, single-line instructions in the piped input and request JSON-only output.
  • Use the -y flag to avoid interactive confirmations in automated flows.
  • Plan work as many small todo tasks and add a final review task to verify outcomes.
  • If mcp-manager reports script errors, use mcp-builder to fix scripts instead of creating new ones.

Example use cases

  • Invoke a tool to fetch context-relevant data and return machine-readable results to the main agent.
  • Run a repair sequence via mcp-manager when the CLI is not present on a worker node.
  • Execute repeated MCP operations in CI/CD while ensuring each step returns consistent JSON.
  • Orchestrate multi-step workflows where each small task's output feeds the next task.

FAQ

Why must I use stdin piping instead of the -p flag?

The -p flag is deprecated and bypasses MCP initialization. Stdin piping ensures the MCP server is initialized and context is preserved.

What does the Gemini CLI return?

Gemini CLI auto-loads project guidance and returns a structured JSON object like {"server":"name","tool":"name","success":true,"result":...,"error":null} for predictable parsing.