$npx -y skills add obra/superpowers-lab --skill mcp-cliUse MCP servers on-demand via the mcp CLI tool - discover tools, resources, and prompts without polluting context with pre-loaded MCP integrations
| 1 | # MCP CLI: On-Demand MCP Server Usage |
| 2 | |
| 3 | Use the `mcp` CLI tool to dynamically discover and invoke MCP server capabilities without pre-configuring them as permanent integrations. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when you need to: |
| 8 | - Explore an MCP server's capabilities before deciding to use it |
| 9 | - Make one-off calls to an MCP server without permanent integration |
| 10 | - Access MCP functionality without polluting the context window |
| 11 | - Test or debug MCP servers |
| 12 | - Use MCP servers that aren't pre-configured |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | The `mcp` CLI must be installed at `~/.local/bin/mcp`. If not present: |
| 17 | |
| 18 | ```bash |
| 19 | # Clone and build |
| 20 | cd /tmp && git clone --depth 1 https://github.com/f/mcptools.git |
| 21 | cd mcptools && CGO_ENABLED=0 go build -o ~/.local/bin/mcp ./cmd/mcptools |
| 22 | ``` |
| 23 | |
| 24 | Always ensure PATH includes the binary: |
| 25 | ```bash |
| 26 | export PATH="$HOME/.local/bin:$PATH" |
| 27 | ``` |
| 28 | |
| 29 | ## Discovery Workflow |
| 30 | |
| 31 | ### Step 1: Discover Available Tools |
| 32 | |
| 33 | ```bash |
| 34 | mcp tools <server-command> |
| 35 | ``` |
| 36 | |
| 37 | **Examples:** |
| 38 | ```bash |
| 39 | # Filesystem server |
| 40 | mcp tools npx -y @modelcontextprotocol/server-filesystem /path/to/allow |
| 41 | |
| 42 | # Memory/knowledge graph server |
| 43 | mcp tools npx -y @modelcontextprotocol/server-memory |
| 44 | |
| 45 | # GitHub server (requires token) |
| 46 | mcp tools docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server |
| 47 | |
| 48 | # HTTP-based server |
| 49 | mcp tools https://example.com/mcp |
| 50 | ``` |
| 51 | |
| 52 | ### Step 2: Discover Resources (if supported) |
| 53 | |
| 54 | ```bash |
| 55 | mcp resources <server-command> |
| 56 | ``` |
| 57 | |
| 58 | Resources are data sources the server exposes (files, database entries, etc.). |
| 59 | |
| 60 | ### Step 3: Discover Prompts (if supported) |
| 61 | |
| 62 | ```bash |
| 63 | mcp prompts <server-command> |
| 64 | ``` |
| 65 | |
| 66 | Prompts are pre-defined prompt templates the server provides. |
| 67 | |
| 68 | ### Step 4: Get Detailed Info (JSON format) |
| 69 | |
| 70 | ```bash |
| 71 | # For full schema details including parameter types |
| 72 | mcp tools --format json <server-command> |
| 73 | mcp tools --format pretty <server-command> |
| 74 | ``` |
| 75 | |
| 76 | ## Making Tool Calls |
| 77 | |
| 78 | ### Basic Syntax |
| 79 | |
| 80 | ```bash |
| 81 | mcp call <tool_name> --params '<json>' <server-command> |
| 82 | ``` |
| 83 | |
| 84 | ### Examples |
| 85 | |
| 86 | **Read a file:** |
| 87 | ```bash |
| 88 | mcp call read_file --params '{"path": "/tmp/example.txt"}' \ |
| 89 | npx -y @modelcontextprotocol/server-filesystem /tmp |
| 90 | ``` |
| 91 | |
| 92 | **Write a file:** |
| 93 | ```bash |
| 94 | mcp call write_file --params '{"path": "/tmp/test.txt", "content": "Hello world"}' \ |
| 95 | npx -y @modelcontextprotocol/server-filesystem /tmp |
| 96 | ``` |
| 97 | |
| 98 | **List directory:** |
| 99 | ```bash |
| 100 | mcp call list_directory --params '{"path": "/tmp"}' \ |
| 101 | npx -y @modelcontextprotocol/server-filesystem /tmp |
| 102 | ``` |
| 103 | |
| 104 | **Create entities (memory server):** |
| 105 | ```bash |
| 106 | mcp call create_entities --params '{"entities": [{"name": "Project", "entityType": "Software", "observations": ["Uses TypeScript"]}]}' \ |
| 107 | npx -y @modelcontextprotocol/server-memory |
| 108 | ``` |
| 109 | |
| 110 | **Search (memory server):** |
| 111 | ```bash |
| 112 | mcp call search_nodes --params '{"query": "TypeScript"}' \ |
| 113 | npx -y @modelcontextprotocol/server-memory |
| 114 | ``` |
| 115 | |
| 116 | ### Complex Parameters |
| 117 | |
| 118 | For nested objects and arrays, ensure valid JSON: |
| 119 | |
| 120 | ```bash |
| 121 | mcp call edit_file --params '{ |
| 122 | "path": "/tmp/file.txt", |
| 123 | "edits": [ |
| 124 | {"oldText": "foo", "newText": "bar"}, |
| 125 | {"oldText": "baz", "newText": "qux"} |
| 126 | ] |
| 127 | }' npx -y @modelcontextprotocol/server-filesystem /tmp |
| 128 | ``` |
| 129 | |
| 130 | ### Output Formats |
| 131 | |
| 132 | ```bash |
| 133 | # Table (default, human-readable) |
| 134 | mcp call <tool> --params '{}' <server> |
| 135 | |
| 136 | # JSON (for parsing) |
| 137 | mcp call <tool> --params '{}' -f json <server> |
| 138 | |
| 139 | # Pretty JSON (readable JSON) |
| 140 | mcp call <tool> --params '{}' -f pretty <server> |
| 141 | ``` |
| 142 | |
| 143 | ## Reading Resources |
| 144 | |
| 145 | ```bash |
| 146 | # List available resources |
| 147 | mcp resources <server-command> |
| 148 | |
| 149 | # Read a specific resource |
| 150 | mcp read-resource <resource-uri> <server-command> |
| 151 | |
| 152 | # Alternative syntax |
| 153 | mcp call resource:<resource-uri> <server-command> |
| 154 | ``` |
| 155 | |
| 156 | ## Using Prompts |
| 157 | |
| 158 | ```bash |
| 159 | # List available prompts |
| 160 | mcp prompts <server-command> |
| 161 | |
| 162 | # Get a prompt (may require arguments) |
| 163 | mcp get-prompt <prompt-name> <server-command> |
| 164 | |
| 165 | # With parameters |
| 166 | mcp get-prompt <prompt-name> --params '{"arg": "value"}' <server-command> |
| 167 | ``` |
| 168 | |
| 169 | ## Server Aliases (for repeated use) |
| 170 | |
| 171 | If using a server frequently during a session: |
| 172 | |
| 173 | ```bash |
| 174 | # Create alias |
| 175 | mcp alias add fs npx -y @modelcontextprotocol/server-filesystem /home/user |
| 176 | |
| 177 | # Use alias |
| 178 | mcp tools fs |
| 179 | mcp call read_file --params '{"path": "README.md"}' fs |
| 180 | |
| 181 | # List aliases |
| 182 | mcp alias list |
| 183 | |
| 184 | # Remove when done |
| 185 | mcp alias remove fs |
| 186 | ``` |
| 187 | |
| 188 | Aliases are stored in `~/.mcpt/aliases.json`. |
| 189 | |
| 190 | ## Authentication |
| 191 | |
| 192 | ### HTTP Basic Auth |
| 193 | ```bash |
| 194 | mcp tools --auth-user "username:password" https://api.example.com/mcp |
| 195 | ``` |
| 196 | |
| 197 | ### Bearer Token |
| 198 | ```bash |
| 199 | mcp tools --auth-header "Bearer your-token-here" https://api.example.com/mcp |
| 200 | ``` |
| 201 | |
| 202 | ### Environment Variables (for Docker-based servers) |
| 203 | ```bash |
| 204 | mcp tools docker run -i --rm \ |
| 205 | -e GITHUB_PERSONAL_ACCESS_TOKEN="$GITHUB_TOKEN" \ |
| 206 | ghcr.io/github/github-mcp-server |
| 207 | ``` |
| 208 | |
| 209 | ## Transport Types |
| 210 | |
| 211 | ### Stdio (default for npx/node commands) |
| 212 | ```bash |
| 213 | mcp tools npx -y @modelcontextprotocol/server-filesystem /tmp |
| 214 | ``` |