@weibaohui/mcp2cli 0.2.8 → 0.4.0
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 +157 -157
- 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 +5 -6
- package/{install.js → postinstall.js} +3 -12
- package/run.js +14 -0
package/README.md
CHANGED
|
@@ -1,234 +1,234 @@
|
|
|
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
|
-
##
|
|
11
|
+
## Why mcp2cli?
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
mv $(go env GOPATH)/bin/mcp2cli $(go env GOPATH)/bin/mcp
|
|
18
|
+
**mcp2cli compresses that into one bash command:**
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# View tool details with parameter examples
|
|
24
|
-
mcp openDeepWiki list_repositories
|
|
25
|
-
|
|
26
|
-
# Call a tool
|
|
27
|
-
mcp openDeepWiki list_repositories limit=3
|
|
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
|
|
28
25
|
|
|
29
|
-
#
|
|
30
|
-
mcp openDeepWiki
|
|
26
|
+
# mcp2cli: 1 bash call, ~200 tokens
|
|
27
|
+
mcp openDeepWiki get_repo_structure repoOwner=github repoName=vscode
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
**Result: 80-90% fewer tokens per tool interaction.**
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
## Quick Start
|
|
36
33
|
|
|
37
34
|
```bash
|
|
38
|
-
#
|
|
39
|
-
|
|
35
|
+
# Install
|
|
36
|
+
npm install -g @weibaohui/mcp2cli
|
|
40
37
|
|
|
41
|
-
#
|
|
42
|
-
mcp
|
|
43
|
-
```
|
|
38
|
+
# List servers
|
|
39
|
+
mcp
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
# Explore tools on a server
|
|
42
|
+
mcp openDeepWiki
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
# View tool details + param examples
|
|
45
|
+
mcp openDeepWiki get_repo_structure
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
# Call a tool
|
|
48
|
+
mcp openDeepWiki get_repo_structure repoOwner=github repoName=vscode
|
|
49
|
+
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
- **📋 Explore Tools** - View detailed tool information with formatted parameters
|
|
53
|
-
- **🚀 Invoke Tools** - Call tools directly with type-safe arguments
|
|
54
|
-
- **🔌 Multiple Transports** - Support for SSE, Streamable HTTP, and Stdio
|
|
55
|
-
- **📁 Smart Config** - Auto-detects and merges configs from standard locations
|
|
56
|
-
- **📤 Unified JSON Output** - Machine-readable output for scripting
|
|
51
|
+
## How It Saves Tokens
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
### Before: Direct MCP (verbose)
|
|
59
54
|
|
|
60
|
-
|
|
55
|
+
Every MCP interaction requires the LLM to maintain tool schemas in context:
|
|
61
56
|
|
|
62
|
-
|
|
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
|
+
```
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
Multiply this by **every tool on every server** — a server with 20 tools = ~10,000 tokens permanently in context.
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
go install github.com/weibaohui/mcp2cli@latest
|
|
68
|
-
```
|
|
76
|
+
### After: mcp2cli (lean)
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
The LLM only needs a short bash command. No schemas, no tool definitions, no protocol overhead:
|
|
71
79
|
|
|
72
80
|
```bash
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
make build
|
|
81
|
+
# Token cost: just the command string (~30 tokens)
|
|
82
|
+
mcp openDeepWiki get_repo_structure repoOwner=github repoName=vscode
|
|
76
83
|
```
|
|
77
84
|
|
|
78
|
-
## Configuration
|
|
79
|
-
|
|
80
|
-
Create `~/.config/mcp/config.json`:
|
|
81
|
-
|
|
82
85
|
```json
|
|
86
|
+
// Output is concise JSON (~100 tokens)
|
|
83
87
|
{
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"timeout": 30000
|
|
88
|
-
}
|
|
89
|
-
}
|
|
88
|
+
"success": true,
|
|
89
|
+
"data": { "server": "openDeepWiki", "method": "get_repo_structure", "result": "..." },
|
|
90
|
+
"meta": { "timestamp": "2026-03-28T10:00:00Z", "version": "v0.3.0" }
|
|
90
91
|
}
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
###
|
|
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% |
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
|----------|---------------|
|
|
97
|
-
| macOS/Linux | `~/.config/modelcontextprotocol/mcp.json` → `~/.config/mcp/config.json` → `./mcp.json` → `./.mcp/config.json` → `/etc/mcp/config.json` |
|
|
98
|
-
| 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
|
|
99
104
|
|
|
100
|
-
|
|
105
|
+
Add to your project's MCP config (e.g. `.mcp/config.json` or `~/.config/mcp/config.json`):
|
|
101
106
|
|
|
102
107
|
```json
|
|
103
108
|
{
|
|
104
109
|
"mcpServers": {
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"url": "https://example.com/mcp",
|
|
108
|
-
"command": "npx",
|
|
109
|
-
"args": ["-y", "@server/mcp"],
|
|
110
|
-
"env": {"KEY": "value"},
|
|
111
|
-
"timeout": 30000,
|
|
112
|
-
"headers": {
|
|
113
|
-
"Authorization": "Bearer ${API_TOKEN}",
|
|
114
|
-
"X-API-Key": "${API_KEY}"
|
|
115
|
-
}
|
|
110
|
+
"openDeepWiki": {
|
|
111
|
+
"url": "https://opendeepwiki.k8m.site/mcp/streamable"
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
```
|
|
120
116
|
|
|
121
|
-
|
|
117
|
+
Then in your AI tool, just run bash commands:
|
|
122
118
|
|
|
123
|
-
**HTTP Headers (API Key / Bearer Token):**
|
|
124
|
-
```json
|
|
125
|
-
{
|
|
126
|
-
"mcpServers": {
|
|
127
|
-
"secure-server": {
|
|
128
|
-
"url": "https://api.example.com/mcp",
|
|
129
|
-
"headers": {
|
|
130
|
-
"Authorization": "Bearer ${API_TOKEN}",
|
|
131
|
-
"X-API-Key": "${API_KEY}"
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
119
|
```
|
|
120
|
+
# The LLM can explore and call tools in one step
|
|
121
|
+
$ mcp openDeepWiki list_repositories limit=3
|
|
137
122
|
|
|
138
|
-
|
|
123
|
+
# No need to load tool schemas — just call
|
|
124
|
+
$ mcp openDeepWiki get_repo_structure repoOwner=weibaohui repoName=mcp2cli
|
|
125
|
+
```
|
|
139
126
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
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
|
|
154
137
|
```
|
|
155
138
|
|
|
156
|
-
**
|
|
157
|
-
| Type | Description |
|
|
158
|
-
|------|-------------|
|
|
159
|
-
| `streamable` | Modern streaming HTTP (default) |
|
|
160
|
-
| `sse` | Server-Sent Events over HTTP |
|
|
161
|
-
| `stdio` | Local subprocess communication |
|
|
139
|
+
**Supported types:** `string`, `number`, `int`, `float`, `bool`
|
|
162
140
|
|
|
163
|
-
|
|
141
|
+
### YAML Input (for complex parameters)
|
|
142
|
+
|
|
143
|
+
For complex parameters (objects, arrays, multi-line text), use YAML format:
|
|
164
144
|
|
|
165
145
|
```bash
|
|
166
|
-
#
|
|
167
|
-
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'
|
|
168
149
|
|
|
169
|
-
#
|
|
170
|
-
mcp
|
|
150
|
+
# Multi-line YAML
|
|
151
|
+
mcp server tool --yaml 'limit: 10
|
|
152
|
+
offset: 5
|
|
153
|
+
status: "ready"'
|
|
171
154
|
|
|
172
|
-
#
|
|
173
|
-
mcp
|
|
155
|
+
# Read from file (like kubectl apply -f)
|
|
156
|
+
mcp server tool -f params.yaml
|
|
174
157
|
|
|
175
|
-
#
|
|
176
|
-
|
|
158
|
+
# Pipe YAML to stdin
|
|
159
|
+
cat params.yaml | mcp server tool
|
|
177
160
|
```
|
|
178
161
|
|
|
179
|
-
|
|
162
|
+
**Priority:** `-f` > `--yaml/-y` > stdin pipe > `key=value`
|
|
180
163
|
|
|
181
|
-
|
|
164
|
+
### Output Format
|
|
182
165
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
"servers": [
|
|
189
|
-
{
|
|
190
|
-
"name": "openDeepWiki",
|
|
191
|
-
"transport": "streamable",
|
|
192
|
-
"url": "https://opendeepwiki.k8m.site/mcp/streamable"
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
|
-
"meta": {
|
|
197
|
-
"timestamp": "2026-03-24T10:00:00Z",
|
|
198
|
-
"version": "v0.2.8"
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
```
|
|
166
|
+
Control output format with `--output` / `-o`:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# JSON (default, human-readable with indentation)
|
|
170
|
+
mcp server tool
|
|
202
171
|
|
|
203
|
-
|
|
172
|
+
# YAML output
|
|
173
|
+
mcp --output yaml server tool
|
|
204
174
|
|
|
175
|
+
# Text output (compact JSON, good for piping)
|
|
176
|
+
mcp -o text server tool
|
|
205
177
|
```
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
178
|
+
|
|
179
|
+
| Format | Description | Use Case |
|
|
180
|
+
|--------|-------------|----------|
|
|
181
|
+
| `json` | Pretty-printed JSON | Default, debugging |
|
|
182
|
+
| `yaml` | YAML format | Config files, readability |
|
|
183
|
+
| `text` | Compact JSON | Piping, scripts |
|
|
184
|
+
|
|
185
|
+
## Installation
|
|
186
|
+
|
|
187
|
+
### npm (recommended)
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm install -g @weibaohui/mcp2cli
|
|
214
191
|
```
|
|
215
192
|
|
|
216
|
-
|
|
193
|
+
Supports Linux, macOS, Windows on amd64/arm64. `mcp` command ready immediately.
|
|
194
|
+
|
|
195
|
+
### Go install
|
|
217
196
|
|
|
218
197
|
```bash
|
|
219
|
-
|
|
220
|
-
|
|
198
|
+
go install github.com/weibaohui/mcp2cli@latest
|
|
199
|
+
mv $(go env GOPATH)/bin/mcp2cli $(go env GOPATH)/bin/mcp
|
|
200
|
+
```
|
|
221
201
|
|
|
222
|
-
|
|
223
|
-
make build-all
|
|
202
|
+
### Binary download
|
|
224
203
|
|
|
225
|
-
|
|
226
|
-
make test
|
|
204
|
+
Download from [GitHub Releases](https://github.com/weibaohui/mcp2cli/releases/latest):
|
|
227
205
|
|
|
228
|
-
|
|
229
|
-
|
|
206
|
+
```bash
|
|
207
|
+
# macOS / Linux
|
|
208
|
+
mv mcp2cli-darwin-arm64 mcp && chmod +x mcp && sudo mv mcp /usr/local/bin/
|
|
209
|
+
|
|
210
|
+
# Windows
|
|
211
|
+
ren mcp2cli-windows-amd64.exe mcp.exe
|
|
230
212
|
```
|
|
231
213
|
|
|
214
|
+
## Command Reference
|
|
215
|
+
|
|
216
|
+
| Command | Description |
|
|
217
|
+
|---------|-------------|
|
|
218
|
+
| `mcp` | List configured servers |
|
|
219
|
+
| `mcp <server>` | List tools on a server |
|
|
220
|
+
| `mcp <server> <tool>` | Show tool details + param examples |
|
|
221
|
+
| `mcp <server> <tool> key=value ...` | Call a tool |
|
|
222
|
+
|
|
223
|
+
### Global Flags
|
|
224
|
+
|
|
225
|
+
| Flag | Short | Description | Default |
|
|
226
|
+
|------|-------|-------------|---------|
|
|
227
|
+
| `--output` | `-o` | Output format (json\|yaml\|text) | `json` |
|
|
228
|
+
| `--yaml` | `-y` | YAML parameters (inline) | |
|
|
229
|
+
| `--file` | `-f` | YAML file with parameters | |
|
|
230
|
+
| `--stream` | `-s` | Enable streaming output | `false` |
|
|
231
|
+
|
|
232
232
|
## License
|
|
233
233
|
|
|
234
234
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weibaohui/mcp2cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI tool for interacting with MCP (Model Context Protocol) Servers",
|
|
5
5
|
"author": "weibaohui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,20 +24,19 @@
|
|
|
24
24
|
"x64",
|
|
25
25
|
"arm64"
|
|
26
26
|
],
|
|
27
|
-
"main": "index.js",
|
|
28
27
|
"bin": {
|
|
29
|
-
"mcp": "./
|
|
28
|
+
"mcp": "./run.js"
|
|
30
29
|
},
|
|
31
30
|
"files": [
|
|
32
31
|
"dist/",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
32
|
+
"run.js",
|
|
33
|
+
"postinstall.js",
|
|
35
34
|
"README.md"
|
|
36
35
|
],
|
|
37
36
|
"engines": {
|
|
38
37
|
"node": ">=18.0.0"
|
|
39
38
|
},
|
|
40
39
|
"scripts": {
|
|
41
|
-
"postinstall": "node
|
|
40
|
+
"postinstall": "node postinstall.js"
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -6,14 +6,12 @@ const path = require('path');
|
|
|
6
6
|
const platform = process.platform;
|
|
7
7
|
const arch = process.arch;
|
|
8
8
|
|
|
9
|
-
// Map platform names
|
|
10
9
|
const platformMap = {
|
|
11
10
|
'darwin': 'darwin',
|
|
12
11
|
'linux': 'linux',
|
|
13
12
|
'win32': 'windows'
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
// Map arch names - npm uses x64, Go uses amd64
|
|
17
15
|
const archMap = {
|
|
18
16
|
'x64': 'amd64',
|
|
19
17
|
'arm64': 'arm64'
|
|
@@ -29,10 +27,7 @@ if (!npmPlatform || !npmArch) {
|
|
|
29
27
|
|
|
30
28
|
const binaryName = `mcp2cli-${npmPlatform}-${npmArch}`;
|
|
31
29
|
const binaryPath = path.join(__dirname, 'dist', binaryName);
|
|
32
|
-
const targetPath = path.join(__dirname, 'mcp2cli');
|
|
33
|
-
|
|
34
|
-
// Add .exe on Windows
|
|
35
|
-
const exeTargetPath = platform === 'win32' ? targetPath + '.exe' : targetPath;
|
|
30
|
+
const targetPath = path.join(__dirname, platform === 'win32' ? 'mcp2cli.exe' : 'mcp2cli');
|
|
36
31
|
|
|
37
32
|
if (!fs.existsSync(binaryPath)) {
|
|
38
33
|
console.error(`Binary not found: ${binaryPath}`);
|
|
@@ -40,12 +35,8 @@ if (!fs.existsSync(binaryPath)) {
|
|
|
40
35
|
process.exit(1);
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
fs.copyFileSync(binaryPath, exeTargetPath);
|
|
38
|
+
fs.copyFileSync(binaryPath, targetPath);
|
|
45
39
|
|
|
46
|
-
// Make executable on Unix systems
|
|
47
40
|
if (platform !== 'win32') {
|
|
48
|
-
fs.chmodSync(
|
|
41
|
+
fs.chmodSync(targetPath, 0o755);
|
|
49
42
|
}
|
|
50
|
-
|
|
51
|
-
console.log(`Installed mcp2cli ${npmPlatform}/${npmArch} successfully`);
|
package/run.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const binary = process.platform === 'win32'
|
|
7
|
+
? path.join(__dirname, 'mcp2cli.exe')
|
|
8
|
+
: path.join(__dirname, 'mcp2cli');
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
execFileSync(binary, process.argv.slice(2), { stdio: 'inherit' });
|
|
12
|
+
} catch (e) {
|
|
13
|
+
process.exit(e.status || 1);
|
|
14
|
+
}
|