@weibaohui/mcp2cli 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -186
- package/dist/mcp2cli-darwin-amd64 +0 -0
- package/dist/mcp2cli-darwin-arm64 +0 -0
- package/dist/mcp2cli-linux-amd64 +0 -0
- package/dist/mcp2cli-linux-arm64 +0 -0
- package/dist/mcp2cli-windows-amd64.exe +0 -0
- package/dist/mcp2cli-windows-arm64.exe +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,265 +1,227 @@
|
|
|
1
1
|
# mcp2cli
|
|
2
2
|
|
|
3
|
-
> A
|
|
3
|
+
> A CLI-native MCP client that loads tool schemas on-demand and resolves discover-then-call into a single invocation — keeping tool definitions out of your context window.
|
|
4
|
+
|
|
5
|
+
**One bash command → tool discovery + schema resolution + precise invocation. No persistent tool definitions, no token waste.**
|
|
4
6
|
|
|
5
7
|
[](https://golang.org)
|
|
6
8
|
[](LICENSE)
|
|
9
|
+
[](https://www.npmjs.com/package/@weibaohui/mcp2cli)
|
|
7
10
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
# Install via npm (recommended)
|
|
12
|
-
npm install -g @weibaohui/mcp2cli
|
|
11
|
+
## Why mcp2cli?
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
When an LLM uses MCP tools directly, every call carries heavy overhead:
|
|
14
|
+
- Tool discovery: list tools → read schemas → understand parameters → construct call → parse response
|
|
15
|
+
- Each MCP tool definition (schema, descriptions, types) stays in context, consuming tokens for the **entire conversation**
|
|
16
|
+
- A single "search GitHub and summarize" task can burn thousands of tokens just on protocol overhead
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
mv $(go env GOPATH)/bin/mcp2cli $(go env GOPATH)/bin/mcp
|
|
18
|
+
**mcp2cli compresses that into one bash command:**
|
|
19
19
|
|
|
20
|
-
# List configured servers (no server connection)
|
|
21
|
-
mcp
|
|
22
|
-
|
|
23
|
-
# Inspect a server's available tools
|
|
24
|
-
mcp openDeepWiki
|
|
25
|
-
|
|
26
|
-
# View tool details with parameter examples
|
|
27
|
-
mcp openDeepWiki list_repositories
|
|
28
|
-
|
|
29
|
-
# Call a tool
|
|
30
|
-
mcp openDeepWiki list_repositories limit=3
|
|
31
|
-
|
|
32
|
-
# Call with typed arguments (recommended)
|
|
33
|
-
mcp openDeepWiki list_repositories limit:number=3 enabled:bool=true
|
|
34
20
|
```
|
|
21
|
+
# Direct MCP: 3 rounds, ~2000+ tokens of context
|
|
22
|
+
1. list_tools(server) → get all tool schemas
|
|
23
|
+
2. get_tool_details(server, tool) → read parameter definitions
|
|
24
|
+
3. call_tool(server, tool, args) → get result
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Arguments can be in two formats:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# Simple key=value (string type by default)
|
|
42
|
-
mcp server tool name=John age=30
|
|
43
|
-
|
|
44
|
-
# Typed key:type=value (recommended for precision)
|
|
45
|
-
mcp server tool name:string=John age:number=30 enabled:bool=true
|
|
26
|
+
# mcp2cli: 1 bash call, ~200 tokens
|
|
27
|
+
mcp openDeepWiki get_repo_structure repoOwner=github repoName=vscode
|
|
46
28
|
```
|
|
47
29
|
|
|
48
|
-
**
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Features
|
|
53
|
-
|
|
54
|
-
- **🔍 Discover Servers** - List all configured MCP servers without connecting
|
|
55
|
-
- **📋 Explore Tools** - View detailed tool information with formatted parameters
|
|
56
|
-
- **🚀 Invoke Tools** - Call tools directly with type-safe arguments
|
|
57
|
-
- **🔌 Multiple Transports** - Support for SSE, Streamable HTTP, and Stdio
|
|
58
|
-
- **📁 Smart Config** - Auto-detects and merges configs from standard locations
|
|
59
|
-
- **📤 Unified JSON Output** - Machine-readable output for scripting
|
|
30
|
+
**Result: 80-90% fewer tokens per tool interaction.**
|
|
60
31
|
|
|
61
|
-
##
|
|
62
|
-
|
|
63
|
-
### npm (multi-platform) - recommended
|
|
32
|
+
## Quick Start
|
|
64
33
|
|
|
65
34
|
```bash
|
|
35
|
+
# Install
|
|
66
36
|
npm install -g @weibaohui/mcp2cli
|
|
67
|
-
```
|
|
68
37
|
|
|
69
|
-
|
|
38
|
+
# List servers
|
|
39
|
+
mcp
|
|
70
40
|
|
|
71
|
-
|
|
41
|
+
# Explore tools on a server
|
|
42
|
+
mcp openDeepWiki
|
|
72
43
|
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
# View tool details + param examples
|
|
45
|
+
mcp openDeepWiki get_repo_structure
|
|
75
46
|
|
|
76
|
-
#
|
|
77
|
-
|
|
47
|
+
# Call a tool
|
|
48
|
+
mcp openDeepWiki get_repo_structure repoOwner=github repoName=vscode
|
|
78
49
|
```
|
|
79
50
|
|
|
80
|
-
|
|
51
|
+
## How It Saves Tokens
|
|
81
52
|
|
|
82
|
-
|
|
83
|
-
mv $(go env GOPATH)/bin/mcp2cli $(go env GOPATH)/bin/mcp
|
|
84
|
-
```
|
|
53
|
+
### Before: Direct MCP (verbose)
|
|
85
54
|
|
|
86
|
-
|
|
55
|
+
Every MCP interaction requires the LLM to maintain tool schemas in context:
|
|
87
56
|
|
|
88
|
-
|
|
57
|
+
```json
|
|
58
|
+
// Tool schema alone = ~500 tokens, stays in EVERY message
|
|
59
|
+
{
|
|
60
|
+
"name": "get_repo_structure",
|
|
61
|
+
"description": "Retrieves the complete file and directory structure of a Git repository...",
|
|
62
|
+
"inputSchema": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {
|
|
65
|
+
"repoOwner": {"type": "string", "description": "..."},
|
|
66
|
+
"repoName": {"type": "string", "description": "..."},
|
|
67
|
+
...
|
|
68
|
+
},
|
|
69
|
+
"required": ["repoOwner", "repoName"]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
89
73
|
|
|
90
|
-
|
|
91
|
-
# macOS / Linux
|
|
92
|
-
mv mcp2cli-darwin-arm64 mcp
|
|
93
|
-
chmod +x mcp
|
|
94
|
-
sudo mv mcp /usr/local/bin/
|
|
74
|
+
Multiply this by **every tool on every server** — a server with 20 tools = ~10,000 tokens permanently in context.
|
|
95
75
|
|
|
96
|
-
|
|
97
|
-
ren mcp2cli-windows-amd64.exe mcp.exe
|
|
98
|
-
```
|
|
76
|
+
### After: mcp2cli (lean)
|
|
99
77
|
|
|
100
|
-
|
|
78
|
+
The LLM only needs a short bash command. No schemas, no tool definitions, no protocol overhead:
|
|
101
79
|
|
|
102
80
|
```bash
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
make build
|
|
106
|
-
cp bin/mcp2cli /usr/local/bin/mcp
|
|
81
|
+
# Token cost: just the command string (~30 tokens)
|
|
82
|
+
mcp openDeepWiki get_repo_structure repoOwner=github repoName=vscode
|
|
107
83
|
```
|
|
108
84
|
|
|
109
|
-
## Configuration
|
|
110
|
-
|
|
111
|
-
Create `~/.config/mcp/config.json`:
|
|
112
|
-
|
|
113
85
|
```json
|
|
86
|
+
// Output is concise JSON (~100 tokens)
|
|
114
87
|
{
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"timeout": 30000
|
|
119
|
-
}
|
|
120
|
-
}
|
|
88
|
+
"success": true,
|
|
89
|
+
"data": { "server": "openDeepWiki", "method": "get_repo_structure", "result": "..." },
|
|
90
|
+
"meta": { "timestamp": "2026-03-28T10:00:00Z", "version": "v0.3.0" }
|
|
121
91
|
}
|
|
122
92
|
```
|
|
123
93
|
|
|
124
|
-
###
|
|
94
|
+
### Token Comparison
|
|
95
|
+
|
|
96
|
+
| Scenario | Direct MCP | mcp2cli | Saving |
|
|
97
|
+
|----------|-----------|---------|--------|
|
|
98
|
+
| Discover 1 tool | ~500 tokens (schema in context) | ~100 tokens (one bash call) | 80% |
|
|
99
|
+
| Call 1 tool | ~300 tokens (schema + call overhead) | ~130 tokens (command + output) | 57% |
|
|
100
|
+
| 10-tool server in context | ~10,000 tokens (persistent) | 0 tokens (loaded on demand) | 100% |
|
|
101
|
+
| Full workflow (discover + call) | ~2,000 tokens | ~230 tokens | 89% |
|
|
125
102
|
|
|
126
|
-
|
|
127
|
-
|----------|---------------|
|
|
128
|
-
| macOS/Linux | `~/.config/modelcontextprotocol/mcp.json` → `~/.config/mcp/config.json` → `./mcp.json` → `./.mcp/config.json` → `/etc/mcp/config.json` |
|
|
129
|
-
| Windows | `%APPDATA%\modelcontextprotocol\mcp.json` → `%APPDATA%\mcp\config.json` → `%USERPROFILE%\.mcp\config.json` → `.\mcp.json` → `.\.mcp\config.json` |
|
|
103
|
+
## Usage in Claude Code / Cursor / Windsurf
|
|
130
104
|
|
|
131
|
-
|
|
105
|
+
Add to your project's MCP config (e.g. `.mcp/config.json` or `~/.config/mcp/config.json`):
|
|
132
106
|
|
|
133
107
|
```json
|
|
134
108
|
{
|
|
135
109
|
"mcpServers": {
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"url": "https://example.com/mcp",
|
|
139
|
-
"command": "npx",
|
|
140
|
-
"args": ["-y", "@server/mcp"],
|
|
141
|
-
"env": {"KEY": "value"},
|
|
142
|
-
"timeout": 30000,
|
|
143
|
-
"headers": {
|
|
144
|
-
"Authorization": "Bearer ${API_TOKEN}",
|
|
145
|
-
"X-API-Key": "${API_KEY}"
|
|
146
|
-
}
|
|
110
|
+
"openDeepWiki": {
|
|
111
|
+
"url": "https://opendeepwiki.k8m.site/mcp/streamable"
|
|
147
112
|
}
|
|
148
113
|
}
|
|
149
114
|
}
|
|
150
115
|
```
|
|
151
116
|
|
|
152
|
-
|
|
117
|
+
Then in your AI tool, just run bash commands:
|
|
153
118
|
|
|
154
|
-
**HTTP Headers (API Key / Bearer Token):**
|
|
155
|
-
```json
|
|
156
|
-
{
|
|
157
|
-
"mcpServers": {
|
|
158
|
-
"secure-server": {
|
|
159
|
-
"url": "https://api.example.com/mcp",
|
|
160
|
-
"headers": {
|
|
161
|
-
"Authorization": "Bearer ${API_TOKEN}",
|
|
162
|
-
"X-API-Key": "${API_KEY}"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
119
|
```
|
|
120
|
+
# The LLM can explore and call tools in one step
|
|
121
|
+
$ mcp openDeepWiki list_repositories limit=3
|
|
168
122
|
|
|
169
|
-
|
|
123
|
+
# No need to load tool schemas — just call
|
|
124
|
+
$ mcp openDeepWiki get_repo_structure repoOwner=weibaohui repoName=mcp2cli
|
|
125
|
+
```
|
|
170
126
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
127
|
+
## Argument Format
|
|
128
|
+
|
|
129
|
+
### Simple Arguments (key=value)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Simple key=value (string by default)
|
|
133
|
+
mcp server tool name=John age=30
|
|
134
|
+
|
|
135
|
+
# Typed key:type=value (for precision)
|
|
136
|
+
mcp server tool name:string=John age:number=30 enabled:bool=true
|
|
185
137
|
```
|
|
186
138
|
|
|
187
|
-
**
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
| `streamable` | Modern streaming HTTP (default) |
|
|
191
|
-
| `sse` | Server-Sent Events over HTTP |
|
|
192
|
-
| `stdio` | Local subprocess communication |
|
|
139
|
+
**Supported types:** `string`, `number`, `int`, `float`, `bool`
|
|
140
|
+
|
|
141
|
+
### YAML Input (for complex parameters)
|
|
193
142
|
|
|
194
|
-
|
|
143
|
+
For complex parameters (objects, arrays, multi-line text), use YAML format:
|
|
195
144
|
|
|
196
145
|
```bash
|
|
197
|
-
#
|
|
198
|
-
mcp
|
|
146
|
+
# Inline YAML with --yaml or -y
|
|
147
|
+
mcp server tool --yaml 'name: John details: {age: 30, city: NYC}'
|
|
148
|
+
mcp server tool -y 'tags: [dev, ops] enabled: true'
|
|
199
149
|
|
|
200
|
-
#
|
|
201
|
-
mcp
|
|
150
|
+
# Multi-line YAML
|
|
151
|
+
mcp server tool --yaml 'limit: 10
|
|
152
|
+
offset: 5
|
|
153
|
+
status: "ready"'
|
|
202
154
|
|
|
203
|
-
#
|
|
204
|
-
mcp
|
|
155
|
+
# Read from file (like kubectl apply -f)
|
|
156
|
+
mcp server tool -f params.yaml
|
|
205
157
|
|
|
206
|
-
#
|
|
207
|
-
|
|
158
|
+
# Pipe YAML to stdin
|
|
159
|
+
cat params.yaml | mcp server tool
|
|
208
160
|
```
|
|
209
161
|
|
|
210
|
-
|
|
162
|
+
**Priority:** `-f` > `--yaml/-y` > stdin pipe > `key=value`
|
|
211
163
|
|
|
212
|
-
|
|
164
|
+
### Output Format
|
|
213
165
|
|
|
214
|
-
|
|
215
|
-
{
|
|
216
|
-
"success": true,
|
|
217
|
-
"data": {
|
|
218
|
-
"configFiles": ["/home/user/.config/mcp/config.json"],
|
|
219
|
-
"servers": [
|
|
220
|
-
{
|
|
221
|
-
"name": "openDeepWiki",
|
|
222
|
-
"transport": "streamable",
|
|
223
|
-
"url": "https://opendeepwiki.k8m.site/mcp/streamable"
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
},
|
|
227
|
-
"meta": {
|
|
228
|
-
"timestamp": "2026-03-24T10:00:00Z",
|
|
229
|
-
"version": "v0.2.8"
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
```
|
|
166
|
+
Control output format with `--output` / `-o`:
|
|
233
167
|
|
|
234
|
-
|
|
168
|
+
```bash
|
|
169
|
+
# Pretty JSON (default, human-readable with indentation)
|
|
170
|
+
mcp server tool
|
|
235
171
|
|
|
172
|
+
# YAML output
|
|
173
|
+
mcp --output yaml server tool
|
|
174
|
+
|
|
175
|
+
# Compact JSON (no indentation, good for piping)
|
|
176
|
+
mcp -o compact server tool
|
|
236
177
|
```
|
|
237
|
-
main.go # CLI entry point, argument routing
|
|
238
|
-
internal/mcp/
|
|
239
|
-
├── types.go # Error codes, shared types
|
|
240
|
-
├── config.go # Config loading & merging
|
|
241
|
-
├── config_paths.go # Platform-specific paths
|
|
242
|
-
├── client.go # MCP server client
|
|
243
|
-
├── dispatcher.go # Multi-server coordination
|
|
244
|
-
└── formatter.go # Schema formatting, arg parsing
|
|
245
|
-
```
|
|
246
178
|
|
|
247
|
-
|
|
179
|
+
| Format | Description | Use Case |
|
|
180
|
+
|--------|-------------|----------|
|
|
181
|
+
| `pretty` | Pretty-printed JSON (default) | Default, debugging |
|
|
182
|
+
| `compact` | Compact JSON (no indentation) | Piping, scripts |
|
|
183
|
+
| `yaml` | YAML format | Config files, readability |
|
|
184
|
+
|
|
185
|
+
## Installation
|
|
186
|
+
|
|
187
|
+
### npm (recommended)
|
|
248
188
|
|
|
249
189
|
```bash
|
|
250
|
-
|
|
251
|
-
|
|
190
|
+
npm install -g @weibaohui/mcp2cli
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Supports Linux, macOS, Windows on amd64/arm64. `mcp` command ready immediately.
|
|
252
194
|
|
|
253
|
-
|
|
254
|
-
|
|
195
|
+
### Binary download
|
|
196
|
+
|
|
197
|
+
Download from [GitHub Releases](https://github.com/weibaohui/mcp2cli/releases/latest):
|
|
255
198
|
|
|
256
|
-
|
|
257
|
-
|
|
199
|
+
```bash
|
|
200
|
+
# macOS / Linux
|
|
201
|
+
mv mcp2cli-darwin-arm64 mcp && chmod +x mcp && sudo mv mcp /usr/local/bin/
|
|
258
202
|
|
|
259
|
-
#
|
|
260
|
-
|
|
203
|
+
# Windows
|
|
204
|
+
ren mcp2cli-windows-amd64.exe mcp.exe
|
|
261
205
|
```
|
|
262
206
|
|
|
207
|
+
## Command Reference
|
|
208
|
+
|
|
209
|
+
| Command | Description |
|
|
210
|
+
|---------|-------------|
|
|
211
|
+
| `mcp` | List configured servers |
|
|
212
|
+
| `mcp <server>` | List tools on a server |
|
|
213
|
+
| `mcp <server> <tool>` | Show tool details + param examples |
|
|
214
|
+
| `mcp <server> <tool> key=value ...` | Call a tool |
|
|
215
|
+
|
|
216
|
+
### Global Flags
|
|
217
|
+
|
|
218
|
+
| Flag | Short | Description | Default |
|
|
219
|
+
|------|-------|-------------|---------|
|
|
220
|
+
| `--output` | `-o` | Output format (pretty\|compact\|yaml) | `pretty` |
|
|
221
|
+
| `--yaml` | `-y` | YAML parameters (inline) | |
|
|
222
|
+
| `--file` | `-f` | YAML file with parameters | |
|
|
223
|
+
| `--stream` | `-s` | Enable streaming output | `false` |
|
|
224
|
+
|
|
263
225
|
## License
|
|
264
226
|
|
|
265
227
|
MIT License - see [LICENSE](LICENSE) for details.
|
|
Binary file
|
|
Binary file
|
package/dist/mcp2cli-linux-amd64
CHANGED
|
Binary file
|
package/dist/mcp2cli-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|