@weibaohui/mcp2cli 0.2.8
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/LICENSE +21 -0
- package/README.md +234 -0
- 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/install.js +51 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 weibaohui
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# mcp2cli
|
|
2
|
+
|
|
3
|
+
> A powerful CLI tool for interacting with MCP (Model Context Protocol) servers
|
|
4
|
+
|
|
5
|
+
[](https://golang.org)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Quick Usage
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# Install
|
|
12
|
+
go install github.com/weibaohui/mcp2cli@latest
|
|
13
|
+
|
|
14
|
+
# Rename to mcp for convenience
|
|
15
|
+
mv $(go env GOPATH)/bin/mcp2cli $(go env GOPATH)/bin/mcp
|
|
16
|
+
|
|
17
|
+
# List configured servers (no server connection)
|
|
18
|
+
mcp
|
|
19
|
+
|
|
20
|
+
# Inspect a server's available tools
|
|
21
|
+
mcp openDeepWiki
|
|
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
|
|
28
|
+
|
|
29
|
+
# Call with typed arguments (recommended)
|
|
30
|
+
mcp openDeepWiki list_repositories limit:number=3 enabled:bool=true
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Argument Format
|
|
34
|
+
|
|
35
|
+
Arguments can be in two formats:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Simple key=value (string type by default)
|
|
39
|
+
mcp server tool name=John age=30
|
|
40
|
+
|
|
41
|
+
# Typed key:type=value (recommended for precision)
|
|
42
|
+
mcp server tool name:string=John age:number=30 enabled:bool=true
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Supported types:** `string`, `number`, `int`, `float`, `bool`
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **🔍 Discover Servers** - List all configured MCP servers without connecting
|
|
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
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### Binary (latest release)
|
|
61
|
+
|
|
62
|
+
Download from [GitHub Releases](https://github.com/weibaohui/mcp2cli/releases/latest)
|
|
63
|
+
|
|
64
|
+
### From source
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
go install github.com/weibaohui/mcp2cli@latest
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Build from source
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/weibaohui/mcp2cli.git
|
|
74
|
+
cd mcp2cli
|
|
75
|
+
make build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
Create `~/.config/mcp/config.json`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"mcpServers": {
|
|
85
|
+
"openDeepWiki": {
|
|
86
|
+
"url": "https://opendeepwiki.k8m.site/mcp/streamable",
|
|
87
|
+
"timeout": 30000
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Config File Search Paths
|
|
94
|
+
|
|
95
|
+
| Platform | Priority Order |
|
|
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` |
|
|
99
|
+
|
|
100
|
+
### Config File Format
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"mcpServers": {
|
|
105
|
+
"serverName": {
|
|
106
|
+
"transport": "streamable",
|
|
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
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Authentication
|
|
122
|
+
|
|
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
|
+
```
|
|
137
|
+
|
|
138
|
+
Supports `${VAR}` and `$VAR` environment variable substitution.
|
|
139
|
+
|
|
140
|
+
**OAuth 2.1 with Static Access Token:**
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"mcpServers": {
|
|
144
|
+
"oauth-server": {
|
|
145
|
+
"url": "https://api.example.com/mcp",
|
|
146
|
+
"auth": {
|
|
147
|
+
"oauth": {
|
|
148
|
+
"accessToken": "${OAUTH_ACCESS_TOKEN}"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Transport Types:**
|
|
157
|
+
| Type | Description |
|
|
158
|
+
|------|-------------|
|
|
159
|
+
| `streamable` | Modern streaming HTTP (default) |
|
|
160
|
+
| `sse` | Server-Sent Events over HTTP |
|
|
161
|
+
| `stdio` | Local subprocess communication |
|
|
162
|
+
|
|
163
|
+
## Command Reference
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# List all configured servers
|
|
167
|
+
mcp
|
|
168
|
+
|
|
169
|
+
# Get server info with tools list
|
|
170
|
+
mcp <server_name>
|
|
171
|
+
|
|
172
|
+
# Get tool details with parameter examples
|
|
173
|
+
mcp <server_name> <tool_name>
|
|
174
|
+
|
|
175
|
+
# Call a tool with arguments
|
|
176
|
+
mcp <server_name> <tool_name> <key=value> [key2=value2]...
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Output Format
|
|
180
|
+
|
|
181
|
+
All commands return unified JSON:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"success": true,
|
|
186
|
+
"data": {
|
|
187
|
+
"configFiles": ["/home/user/.config/mcp/config.json"],
|
|
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
|
+
```
|
|
202
|
+
|
|
203
|
+
## Architecture
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
cmd/mcp/main.go # CLI entry point, argument routing
|
|
207
|
+
internal/mcp/
|
|
208
|
+
├── types.go # Error codes, shared types
|
|
209
|
+
├── config.go # Config loading & merging
|
|
210
|
+
├── config_paths.go # Platform-specific paths
|
|
211
|
+
├── client.go # MCP server client
|
|
212
|
+
├── dispatcher.go # Multi-server coordination
|
|
213
|
+
└── formatter.go # Schema formatting, arg parsing
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Development
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Build for current platform
|
|
220
|
+
make build
|
|
221
|
+
|
|
222
|
+
# Build for all platforms
|
|
223
|
+
make build-all
|
|
224
|
+
|
|
225
|
+
# Run tests
|
|
226
|
+
make test
|
|
227
|
+
|
|
228
|
+
# Lint code
|
|
229
|
+
make lint
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/install.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const platform = process.platform;
|
|
7
|
+
const arch = process.arch;
|
|
8
|
+
|
|
9
|
+
// Map platform names
|
|
10
|
+
const platformMap = {
|
|
11
|
+
'darwin': 'darwin',
|
|
12
|
+
'linux': 'linux',
|
|
13
|
+
'win32': 'windows'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Map arch names - npm uses x64, Go uses amd64
|
|
17
|
+
const archMap = {
|
|
18
|
+
'x64': 'amd64',
|
|
19
|
+
'arm64': 'arm64'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const npmPlatform = platformMap[platform];
|
|
23
|
+
const npmArch = archMap[arch];
|
|
24
|
+
|
|
25
|
+
if (!npmPlatform || !npmArch) {
|
|
26
|
+
console.error(`Unsupported platform/architecture: ${platform}/${arch}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const binaryName = `mcp2cli-${npmPlatform}-${npmArch}`;
|
|
31
|
+
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;
|
|
36
|
+
|
|
37
|
+
if (!fs.existsSync(binaryPath)) {
|
|
38
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
39
|
+
console.error('Please report this issue at: https://github.com/weibaohui/mcp2cli/issues');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Copy binary to target location
|
|
44
|
+
fs.copyFileSync(binaryPath, exeTargetPath);
|
|
45
|
+
|
|
46
|
+
// Make executable on Unix systems
|
|
47
|
+
if (platform !== 'win32') {
|
|
48
|
+
fs.chmodSync(exeTargetPath, 0o755);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(`Installed mcp2cli ${npmPlatform}/${npmArch} successfully`);
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@weibaohui/mcp2cli",
|
|
3
|
+
"version": "0.2.8",
|
|
4
|
+
"description": "CLI tool for interacting with MCP (Model Context Protocol) Servers",
|
|
5
|
+
"author": "weibaohui",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/weibaohui/mcp2cli",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/weibaohui/mcp2cli.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mcp",
|
|
14
|
+
"model-context-protocol",
|
|
15
|
+
"cli",
|
|
16
|
+
"tool"
|
|
17
|
+
],
|
|
18
|
+
"os": [
|
|
19
|
+
"linux",
|
|
20
|
+
"darwin",
|
|
21
|
+
"win32"
|
|
22
|
+
],
|
|
23
|
+
"cpu": [
|
|
24
|
+
"x64",
|
|
25
|
+
"arm64"
|
|
26
|
+
],
|
|
27
|
+
"main": "index.js",
|
|
28
|
+
"bin": {
|
|
29
|
+
"mcp": "./install.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist/",
|
|
33
|
+
"index.js",
|
|
34
|
+
"install.js",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"postinstall": "node install.js"
|
|
42
|
+
}
|
|
43
|
+
}
|