cli-mcp-mapper 1.0.0 → 1.0.2
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/.github/workflows/publish.yml +55 -0
- package/README.md +699 -1
- package/commands.schema.json +92 -0
- package/examples/basic-commands.json +189 -0
- package/examples/file-operations.json +208 -0
- package/examples/git-commands.json +198 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1,699 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CLI MCP Mapper
|
|
2
|
+
|
|
3
|
+
[](https://raw.githubusercontent.com/SteffenBlake/cli-mcp-mapper/refs/heads/main/LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/cli-mcp-mapper)
|
|
5
|
+
|
|
6
|
+
**Transform any CLI command into a Model Context Protocol (MCP) tool with simple JSON configuration.**
|
|
7
|
+
|
|
8
|
+
CLI MCP Mapper is a powerful MCP server that dynamically exposes command-line tools as MCP tools. This allows AI assistants and other MCP clients to safely execute system commands, scripts, and tools through a declarative JSON configuration—no code required.
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Why CLI MCP Mapper?](#why-cli-mcp-mapper)
|
|
13
|
+
- [Features](#features)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Configuration](#configuration)
|
|
16
|
+
- [Environment Variable](#environment-variable)
|
|
17
|
+
- [Default Location](#default-location)
|
|
18
|
+
- [Configuration File Format](#configuration-file-format)
|
|
19
|
+
- [JSON Specification](#json-specification)
|
|
20
|
+
- [Schema Reference](#schema-reference)
|
|
21
|
+
- [Command Definition](#command-definition)
|
|
22
|
+
- [Parameter Definition](#parameter-definition)
|
|
23
|
+
- [Parameter Types](#parameter-types)
|
|
24
|
+
- [Usage Examples](#usage-examples)
|
|
25
|
+
- [Basic Commands Example](#basic-commands-example)
|
|
26
|
+
- [Git Operations Example](#git-operations-example)
|
|
27
|
+
- [Complex Parameters Example](#complex-parameters-example)
|
|
28
|
+
- [MCP Client Configuration](#mcp-client-configuration)
|
|
29
|
+
- [Claude Desktop](#claude-desktop)
|
|
30
|
+
- [Other MCP Clients](#other-mcp-clients)
|
|
31
|
+
- [Example Configuration Files](#example-configuration-files)
|
|
32
|
+
- [Troubleshooting](#troubleshooting)
|
|
33
|
+
- [Security Considerations](#security-considerations)
|
|
34
|
+
- [Contributing](#contributing)
|
|
35
|
+
- [License](#license)
|
|
36
|
+
|
|
37
|
+
## Why CLI MCP Mapper?
|
|
38
|
+
|
|
39
|
+
The Model Context Protocol (MCP) enables AI assistants to interact with external tools and systems. However, creating MCP servers for every command-line tool can be time-consuming and requires coding expertise. CLI MCP Mapper solves this by:
|
|
40
|
+
|
|
41
|
+
- **No Coding Required**: Define tools using simple JSON configuration
|
|
42
|
+
- **Universal Compatibility**: Works with any CLI tool (git, npm, docker, custom scripts, etc.)
|
|
43
|
+
- **Type Safety**: JSON schema validation ensures configuration correctness
|
|
44
|
+
- **Flexible Parameter Handling**: Supports positional arguments, named flags, booleans, enums, and more
|
|
45
|
+
- **Reusable Configurations**: Share and version control your tool definitions
|
|
46
|
+
- **Rapid Prototyping**: Test MCP tool ideas without writing server code
|
|
47
|
+
|
|
48
|
+
### Use Cases
|
|
49
|
+
|
|
50
|
+
- **DevOps Automation**: Expose docker, kubectl, terraform commands to AI assistants
|
|
51
|
+
- **Development Workflows**: Make build tools, linters, and test runners available as MCP tools
|
|
52
|
+
- **System Administration**: Safely expose system commands with controlled parameters
|
|
53
|
+
- **Custom Scripts**: Wrap your own scripts and make them AI-accessible
|
|
54
|
+
- **Git Operations**: Provide version control capabilities to AI assistants
|
|
55
|
+
- **File Management**: Enable AI to perform file operations with safety guardrails
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
✨ **Dynamic Tool Generation**: Automatically creates MCP tools from JSON definitions
|
|
60
|
+
🎯 **Flexible Parameters**: Supports positional args, named flags, booleans, enums, and required/optional parameters
|
|
61
|
+
📝 **Type System**: String, boolean, and number parameter types with validation
|
|
62
|
+
🔒 **Schema Validation**: JSON schema for validating your command configurations
|
|
63
|
+
🚀 **Zero Dependencies**: Minimal runtime footprint (only @modelcontextprotocol/sdk)
|
|
64
|
+
🔧 **Easy Configuration**: Environment variable or default path configuration
|
|
65
|
+
📚 **Rich Examples**: Comprehensive example configurations included
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
Install CLI MCP Mapper globally from NPM:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm i -g cli-mcp-mapper
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Verify the installation:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
which cli-mcp-mapper
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
CLI MCP Mapper requires a JSON configuration file that defines which commands to expose as MCP tools.
|
|
84
|
+
|
|
85
|
+
### Environment Variable
|
|
86
|
+
|
|
87
|
+
You can specify a custom configuration path using the `CLI_MCP_MAPPER_CONFIG` environment variable:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
export CLI_MCP_MAPPER_CONFIG=/path/to/your/commands.json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
For persistent configuration, add this to your shell profile (`~/.bashrc`, `~/.zshrc`, etc.):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Add to ~/.bashrc or ~/.zshrc
|
|
97
|
+
export CLI_MCP_MAPPER_CONFIG="$HOME/my-mcp-configs/commands.json"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Default Location
|
|
101
|
+
|
|
102
|
+
If no environment variable is set, CLI MCP Mapper looks for the configuration at:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
~/.config/cli-mcp-mapper/commands.json
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
On different systems:
|
|
109
|
+
- **Linux/macOS**: `~/.config/cli-mcp-mapper/commands.json`
|
|
110
|
+
- **Windows**: `%USERPROFILE%\.config\cli-mcp-mapper\commands.json`
|
|
111
|
+
|
|
112
|
+
To create the default configuration directory:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
mkdir -p ~/.config/cli-mcp-mapper
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Then copy one of the example configurations or create your own:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Copy a basic example
|
|
122
|
+
cp examples/basic-commands.json ~/.config/cli-mcp-mapper/commands.json
|
|
123
|
+
|
|
124
|
+
# Or create your own
|
|
125
|
+
cat > ~/.config/cli-mcp-mapper/commands.json << 'EOF'
|
|
126
|
+
{
|
|
127
|
+
"commands": {
|
|
128
|
+
"hello": {
|
|
129
|
+
"description": "Say hello",
|
|
130
|
+
"command": "echo",
|
|
131
|
+
"baseArgs": [],
|
|
132
|
+
"parameters": {
|
|
133
|
+
"name": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"description": "Name to greet",
|
|
136
|
+
"required": true,
|
|
137
|
+
"position": 0
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
EOF
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Configuration File Format
|
|
147
|
+
|
|
148
|
+
The configuration file is a JSON object with a single `commands` property containing a map of command definitions:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"commands": {
|
|
153
|
+
"command_name": {
|
|
154
|
+
"description": "What this command does",
|
|
155
|
+
"command": "base-command",
|
|
156
|
+
"baseArgs": ["--static", "args"],
|
|
157
|
+
"parameters": {
|
|
158
|
+
"param_name": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"description": "Parameter description",
|
|
161
|
+
"required": false,
|
|
162
|
+
"position": 0
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## JSON Specification
|
|
171
|
+
|
|
172
|
+
### Schema Reference
|
|
173
|
+
|
|
174
|
+
A JSON Schema is provided for validating your configuration files. Reference it in your JSON:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"$schema": "./commands.schema.json",
|
|
179
|
+
"commands": { ... }
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
This enables autocompletion and validation in editors that support JSON Schema (VS Code, IntelliJ, etc.).
|
|
184
|
+
|
|
185
|
+
### Command Definition
|
|
186
|
+
|
|
187
|
+
Each command in the `commands` object has the following structure:
|
|
188
|
+
|
|
189
|
+
| Property | Type | Required | Description |
|
|
190
|
+
|----------|------|----------|-------------|
|
|
191
|
+
| `description` | string | ✅ Yes | Human-readable description shown to MCP clients |
|
|
192
|
+
| `command` | string | ✅ Yes | Base command to execute (e.g., `"git"`, `"npm"`, `"docker"`) |
|
|
193
|
+
| `baseArgs` | string[] | No | Static arguments always passed to the command (e.g., `["build", "--quiet"]`) |
|
|
194
|
+
| `parameters` | object | No | Map of parameter names to parameter definitions |
|
|
195
|
+
|
|
196
|
+
**Example:**
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"git_status": {
|
|
201
|
+
"description": "Show the working tree status",
|
|
202
|
+
"command": "git",
|
|
203
|
+
"baseArgs": ["status"],
|
|
204
|
+
"parameters": {
|
|
205
|
+
"short": {
|
|
206
|
+
"type": "boolean",
|
|
207
|
+
"description": "Give output in short format",
|
|
208
|
+
"argName": "-s"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Parameter Definition
|
|
216
|
+
|
|
217
|
+
Each parameter in the `parameters` object defines how the parameter is passed to the command:
|
|
218
|
+
|
|
219
|
+
| Property | Type | Required | Description |
|
|
220
|
+
|----------|------|----------|-------------|
|
|
221
|
+
| `type` | string | ✅ Yes | Parameter type: `"string"`, `"boolean"`, or `"number"` |
|
|
222
|
+
| `description` | string | ✅ Yes | Human-readable parameter description |
|
|
223
|
+
| `required` | boolean | No | Whether the parameter must be provided (default: `false`) |
|
|
224
|
+
| `position` | number | No | For positional arguments: 0-based position in command line |
|
|
225
|
+
| `argName` | string | No | For named arguments: the flag to use (e.g., `"--output"`, `"-v"`) |
|
|
226
|
+
| `argValue` | string | No | Static value to pass after `argName` (rarely used) |
|
|
227
|
+
| `enum` | string[] | No | List of allowed values |
|
|
228
|
+
| `default` | any | No | Default value if not provided |
|
|
229
|
+
|
|
230
|
+
**Parameter Processing Rules:**
|
|
231
|
+
|
|
232
|
+
1. **Positional Parameters** (`position` is set):
|
|
233
|
+
- Added to command line in position order (0, 1, 2, ...)
|
|
234
|
+
- No `argName` needed
|
|
235
|
+
- If parameter is not provided and not required, it's omitted
|
|
236
|
+
|
|
237
|
+
2. **Named Parameters** (`argName` is set):
|
|
238
|
+
- For `boolean` type: If `true`, adds `argName` to command
|
|
239
|
+
- For `string` or `number` type: Adds `argName` followed by the value
|
|
240
|
+
- If parameter is not provided, it's omitted
|
|
241
|
+
|
|
242
|
+
3. **Required Parameters** (`required: true`):
|
|
243
|
+
- MCP clients must provide these parameters
|
|
244
|
+
- Validation happens before command execution
|
|
245
|
+
|
|
246
|
+
### Parameter Types
|
|
247
|
+
|
|
248
|
+
#### String Parameters
|
|
249
|
+
|
|
250
|
+
Used for text values, file paths, URLs, etc.
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"file_path": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"description": "Path to the file",
|
|
257
|
+
"required": true,
|
|
258
|
+
"position": 0
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
With enum for limited choices:
|
|
264
|
+
|
|
265
|
+
```json
|
|
266
|
+
{
|
|
267
|
+
"log_level": {
|
|
268
|
+
"type": "string",
|
|
269
|
+
"description": "Logging level",
|
|
270
|
+
"enum": ["debug", "info", "warn", "error"],
|
|
271
|
+
"argName": "--log-level"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Boolean Parameters
|
|
277
|
+
|
|
278
|
+
Used for flags/switches. When `true`, the `argName` is added to the command.
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"verbose": {
|
|
283
|
+
"type": "boolean",
|
|
284
|
+
"description": "Enable verbose output",
|
|
285
|
+
"argName": "-v"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Multiple boolean flags can be combined:
|
|
291
|
+
|
|
292
|
+
```json
|
|
293
|
+
{
|
|
294
|
+
"force": {
|
|
295
|
+
"type": "boolean",
|
|
296
|
+
"description": "Force operation",
|
|
297
|
+
"argName": "-f"
|
|
298
|
+
},
|
|
299
|
+
"recursive": {
|
|
300
|
+
"type": "boolean",
|
|
301
|
+
"description": "Recursive operation",
|
|
302
|
+
"argName": "-r"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
When both are true, command becomes: `command -f -r`
|
|
308
|
+
|
|
309
|
+
#### Number Parameters
|
|
310
|
+
|
|
311
|
+
Used for numeric values (counts, limits, sizes, etc.).
|
|
312
|
+
|
|
313
|
+
```json
|
|
314
|
+
{
|
|
315
|
+
"max_count": {
|
|
316
|
+
"type": "number",
|
|
317
|
+
"description": "Maximum number of results",
|
|
318
|
+
"argName": "-n"
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Usage Examples
|
|
324
|
+
|
|
325
|
+
### Basic Commands Example
|
|
326
|
+
|
|
327
|
+
Simple file system operations:
|
|
328
|
+
|
|
329
|
+
```json
|
|
330
|
+
{
|
|
331
|
+
"commands": {
|
|
332
|
+
"ls": {
|
|
333
|
+
"description": "List directory contents",
|
|
334
|
+
"command": "ls",
|
|
335
|
+
"baseArgs": ["-lah"],
|
|
336
|
+
"parameters": {
|
|
337
|
+
"path": {
|
|
338
|
+
"type": "string",
|
|
339
|
+
"description": "Directory path",
|
|
340
|
+
"position": 0
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
"mkdir": {
|
|
345
|
+
"description": "Create a directory",
|
|
346
|
+
"command": "mkdir",
|
|
347
|
+
"baseArgs": [],
|
|
348
|
+
"parameters": {
|
|
349
|
+
"path": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"description": "Directory to create",
|
|
352
|
+
"required": true,
|
|
353
|
+
"position": 0
|
|
354
|
+
},
|
|
355
|
+
"parents": {
|
|
356
|
+
"type": "boolean",
|
|
357
|
+
"description": "Create parent directories",
|
|
358
|
+
"argName": "-p"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Usage in MCP client:**
|
|
367
|
+
- `ls()` → executes `ls -lah`
|
|
368
|
+
- `ls({ path: "/tmp" })` → executes `ls -lah /tmp`
|
|
369
|
+
- `mkdir({ path: "/tmp/test", parents: true })` → executes `mkdir -p /tmp/test`
|
|
370
|
+
|
|
371
|
+
### Git Operations Example
|
|
372
|
+
|
|
373
|
+
Version control commands:
|
|
374
|
+
|
|
375
|
+
```json
|
|
376
|
+
{
|
|
377
|
+
"commands": {
|
|
378
|
+
"git_commit": {
|
|
379
|
+
"description": "Commit changes with a message",
|
|
380
|
+
"command": "git",
|
|
381
|
+
"baseArgs": ["commit"],
|
|
382
|
+
"parameters": {
|
|
383
|
+
"message": {
|
|
384
|
+
"type": "string",
|
|
385
|
+
"description": "Commit message",
|
|
386
|
+
"required": true,
|
|
387
|
+
"argName": "-m"
|
|
388
|
+
},
|
|
389
|
+
"all": {
|
|
390
|
+
"type": "boolean",
|
|
391
|
+
"description": "Stage all modified files",
|
|
392
|
+
"argName": "-a"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
"git_status": {
|
|
397
|
+
"description": "Show repository status",
|
|
398
|
+
"command": "git",
|
|
399
|
+
"baseArgs": ["status"],
|
|
400
|
+
"parameters": {}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Usage in MCP client:**
|
|
407
|
+
- `git_status()` → executes `git status`
|
|
408
|
+
- `git_commit({ message: "Fix bug", all: true })` → executes `git commit -m "Fix bug" -a`
|
|
409
|
+
|
|
410
|
+
### Complex Parameters Example
|
|
411
|
+
|
|
412
|
+
Advanced parameter handling with mixed positional and named arguments:
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"commands": {
|
|
417
|
+
"find_files": {
|
|
418
|
+
"description": "Search for files",
|
|
419
|
+
"command": "find",
|
|
420
|
+
"baseArgs": [],
|
|
421
|
+
"parameters": {
|
|
422
|
+
"path": {
|
|
423
|
+
"type": "string",
|
|
424
|
+
"description": "Starting directory",
|
|
425
|
+
"position": 0,
|
|
426
|
+
"default": "."
|
|
427
|
+
},
|
|
428
|
+
"name": {
|
|
429
|
+
"type": "string",
|
|
430
|
+
"description": "File name pattern",
|
|
431
|
+
"argName": "-name"
|
|
432
|
+
},
|
|
433
|
+
"type": {
|
|
434
|
+
"type": "string",
|
|
435
|
+
"description": "File type",
|
|
436
|
+
"enum": ["f", "d", "l"],
|
|
437
|
+
"argName": "-type"
|
|
438
|
+
},
|
|
439
|
+
"max_depth": {
|
|
440
|
+
"type": "number",
|
|
441
|
+
"description": "Maximum search depth",
|
|
442
|
+
"argName": "-maxdepth"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Usage in MCP client:**
|
|
451
|
+
- `find_files({ name: "*.js", type: "f" })` → executes `find . -name "*.js" -type f`
|
|
452
|
+
- `find_files({ path: "/src", name: "*.ts", max_depth: 3 })` → executes `find /src -name "*.ts" -maxdepth 3`
|
|
453
|
+
|
|
454
|
+
## MCP Client Configuration
|
|
455
|
+
|
|
456
|
+
### Claude Desktop
|
|
457
|
+
|
|
458
|
+
To use CLI MCP Mapper with Claude Desktop, add it to your MCP configuration file.
|
|
459
|
+
|
|
460
|
+
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
461
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
462
|
+
**Linux:** `~/.config/Claude/claude_desktop_config.json`
|
|
463
|
+
|
|
464
|
+
Add the following to the `mcpServers` section:
|
|
465
|
+
|
|
466
|
+
```json
|
|
467
|
+
{
|
|
468
|
+
"mcpServers": {
|
|
469
|
+
"cli-mcp-mapper": {
|
|
470
|
+
"type": "local",
|
|
471
|
+
"command": "cli-mcp-mapper",
|
|
472
|
+
"args": [],
|
|
473
|
+
"tools": ["*"]
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**With custom configuration path:**
|
|
480
|
+
|
|
481
|
+
```json
|
|
482
|
+
{
|
|
483
|
+
"mcpServers": {
|
|
484
|
+
"cli-mcp-mapper": {
|
|
485
|
+
"type": "local",
|
|
486
|
+
"command": "cli-mcp-mapper",
|
|
487
|
+
"args": [],
|
|
488
|
+
"env": {
|
|
489
|
+
"CLI_MCP_MAPPER_CONFIG": "/path/to/your/commands.json"
|
|
490
|
+
},
|
|
491
|
+
"tools": ["*"]
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
After updating the configuration:
|
|
498
|
+
|
|
499
|
+
1. Save the file
|
|
500
|
+
2. Restart Claude Desktop
|
|
501
|
+
3. Your configured commands will appear as available tools
|
|
502
|
+
|
|
503
|
+
### Other MCP Clients
|
|
504
|
+
|
|
505
|
+
For other MCP clients, refer to their documentation for adding MCP servers. The general pattern is:
|
|
506
|
+
|
|
507
|
+
```json
|
|
508
|
+
{
|
|
509
|
+
"command": "cli-mcp-mapper",
|
|
510
|
+
"args": [],
|
|
511
|
+
"env": {
|
|
512
|
+
"CLI_MCP_MAPPER_CONFIG": "/path/to/commands.json"
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## Example Configuration Files
|
|
518
|
+
|
|
519
|
+
The repository includes several example configuration files in the `examples/` directory:
|
|
520
|
+
|
|
521
|
+
### `basic-commands.json`
|
|
522
|
+
Common Unix/Linux commands: `ls`, `cat`, `mkdir`, `rm`, `pwd`, `echo`, `find`, `grep`
|
|
523
|
+
|
|
524
|
+
Use this to give AI assistants basic file system capabilities.
|
|
525
|
+
|
|
526
|
+
### `git-commands.json`
|
|
527
|
+
Git operations: `git status`, `git commit`, `git push`, `git pull`, `git log`, etc.
|
|
528
|
+
|
|
529
|
+
Enable version control operations for AI-assisted development.
|
|
530
|
+
|
|
531
|
+
### `file-operations.json`
|
|
532
|
+
File manipulation: `cp`, `mv`, `touch`, `chmod`, `chown`, `tar`, `wc`
|
|
533
|
+
|
|
534
|
+
Advanced file and archive operations.
|
|
535
|
+
|
|
536
|
+
### Using Examples
|
|
537
|
+
|
|
538
|
+
To use an example configuration:
|
|
539
|
+
|
|
540
|
+
```bash
|
|
541
|
+
# Copy to default location
|
|
542
|
+
cp examples/basic-commands.json ~/.config/cli-mcp-mapper/commands.json
|
|
543
|
+
|
|
544
|
+
# Or use with environment variable
|
|
545
|
+
export CLI_MCP_MAPPER_CONFIG="$PWD/examples/git-commands.json"
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
You can also merge multiple examples into a single configuration:
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
# Combine multiple configurations
|
|
552
|
+
jq -s '{"commands": (map(.commands) | add)}' \
|
|
553
|
+
examples/basic-commands.json \
|
|
554
|
+
examples/git-commands.json \
|
|
555
|
+
> ~/.config/cli-mcp-mapper/commands.json
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
## Troubleshooting
|
|
559
|
+
|
|
560
|
+
### Configuration File Not Found
|
|
561
|
+
|
|
562
|
+
**Error:** `Cannot find module '/path/to/commands.json'`
|
|
563
|
+
|
|
564
|
+
**Solutions:**
|
|
565
|
+
1. Verify the file exists: `ls -la ~/.config/cli-mcp-mapper/commands.json`
|
|
566
|
+
2. Create the directory: `mkdir -p ~/.config/cli-mcp-mapper`
|
|
567
|
+
3. Check environment variable: `echo $CLI_MCP_MAPPER_CONFIG`
|
|
568
|
+
4. Ensure JSON file is valid: `cat ~/.config/cli-mcp-mapper/commands.json | jq`
|
|
569
|
+
|
|
570
|
+
### Invalid JSON Syntax
|
|
571
|
+
|
|
572
|
+
**Error:** `Unexpected token` or `JSON Parse error`
|
|
573
|
+
|
|
574
|
+
**Solutions:**
|
|
575
|
+
1. Validate JSON syntax: `cat commands.json | jq`
|
|
576
|
+
2. Use an editor with JSON validation (VS Code, etc.)
|
|
577
|
+
3. Check for missing commas, brackets, or quotes
|
|
578
|
+
4. Validate against schema: Use the provided `commands.schema.json`
|
|
579
|
+
|
|
580
|
+
### Command Not Executing
|
|
581
|
+
|
|
582
|
+
**Error:** Command returns error or unexpected output
|
|
583
|
+
|
|
584
|
+
**Solutions:**
|
|
585
|
+
1. Test command manually: Run the generated command in your terminal
|
|
586
|
+
2. Check `baseArgs`: Ensure they're valid for your command
|
|
587
|
+
3. Verify `argName` matches command's expected flags
|
|
588
|
+
4. Check positional argument order
|
|
589
|
+
5. Review command's help: `command --help`
|
|
590
|
+
|
|
591
|
+
### Permission Denied
|
|
592
|
+
|
|
593
|
+
**Error:** `EACCES` or `Permission denied`
|
|
594
|
+
|
|
595
|
+
**Solutions:**
|
|
596
|
+
1. Ensure command is in PATH: `which command-name`
|
|
597
|
+
2. Check file permissions: `ls -la $(which command-name)`
|
|
598
|
+
3. Use absolute path in `command` field
|
|
599
|
+
4. For scripts, ensure execute permission: `chmod +x script.sh`
|
|
600
|
+
|
|
601
|
+
### Tool Not Appearing in MCP Client
|
|
602
|
+
|
|
603
|
+
**Solutions:**
|
|
604
|
+
1. Restart MCP client (e.g., Claude Desktop)
|
|
605
|
+
2. Check MCP client logs for errors
|
|
606
|
+
3. Verify `commands.json` is valid
|
|
607
|
+
4. Ensure CLI MCP Mapper is installed: `which cli-mcp-mapper`
|
|
608
|
+
5. Check client configuration file syntax
|
|
609
|
+
|
|
610
|
+
### Commands Execute but Return No Output
|
|
611
|
+
|
|
612
|
+
**Issue:** Command executes successfully but returns empty string
|
|
613
|
+
|
|
614
|
+
**Explanation:** Some commands output to stderr instead of stdout. CLI MCP Mapper captures both but only returns stdout by default on success.
|
|
615
|
+
|
|
616
|
+
**Solutions:**
|
|
617
|
+
1. Check if command writes to stderr
|
|
618
|
+
2. Use command flags to redirect output to stdout
|
|
619
|
+
3. This is often expected behavior for commands that only show errors
|
|
620
|
+
|
|
621
|
+
## Security Considerations
|
|
622
|
+
|
|
623
|
+
⚠️ **Important Security Notes:**
|
|
624
|
+
|
|
625
|
+
1. **Command Injection Risk**: CLI MCP Mapper executes real system commands. Only expose commands you trust.
|
|
626
|
+
|
|
627
|
+
2. **Access Control**: MCP clients that connect to CLI MCP Mapper will have the same permissions as the user running it.
|
|
628
|
+
|
|
629
|
+
3. **Validate Parameters**: Use `enum` to restrict parameter values when possible.
|
|
630
|
+
|
|
631
|
+
4. **Avoid Dangerous Commands**: Be cautious about exposing commands like:
|
|
632
|
+
- `rm -rf` without proper constraints
|
|
633
|
+
- `chmod` with unrestricted modes
|
|
634
|
+
- Commands that can execute arbitrary code
|
|
635
|
+
- Network commands that could expose sensitive data
|
|
636
|
+
|
|
637
|
+
5. **Read-Only Operations**: Consider starting with read-only commands (ls, cat, git status) before exposing write operations.
|
|
638
|
+
|
|
639
|
+
6. **Configuration Security**:
|
|
640
|
+
- Don't commit sensitive configurations to version control
|
|
641
|
+
- Use environment-specific configuration files
|
|
642
|
+
- Review configurations before deploying
|
|
643
|
+
|
|
644
|
+
7. **Least Privilege**: Only grant the minimum necessary commands for your use case.
|
|
645
|
+
|
|
646
|
+
**Best Practices:**
|
|
647
|
+
|
|
648
|
+
```json
|
|
649
|
+
{
|
|
650
|
+
"commands": {
|
|
651
|
+
"safe_delete": {
|
|
652
|
+
"description": "Delete files (safe - no recursive)",
|
|
653
|
+
"command": "rm",
|
|
654
|
+
"baseArgs": ["-i"], // Interactive mode for safety
|
|
655
|
+
"parameters": {
|
|
656
|
+
"file": {
|
|
657
|
+
"type": "string",
|
|
658
|
+
"description": "Single file to delete",
|
|
659
|
+
"required": true,
|
|
660
|
+
"position": 0
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
## Contributing
|
|
669
|
+
|
|
670
|
+
Contributions are welcome! Here's how you can help:
|
|
671
|
+
|
|
672
|
+
1. **Report Issues**: Found a bug? Open an issue on GitHub
|
|
673
|
+
2. **Submit PRs**: Fix bugs, add features, improve documentation
|
|
674
|
+
3. **Share Examples**: Create and share useful command configurations
|
|
675
|
+
4. **Improve Documentation**: Help make the docs clearer and more comprehensive
|
|
676
|
+
|
|
677
|
+
### Development Setup
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
# Clone the repository
|
|
681
|
+
git clone https://github.com/SteffenBlake/cli-mcp-mapper.git
|
|
682
|
+
cd cli-mcp-mapper
|
|
683
|
+
|
|
684
|
+
# Install dependencies
|
|
685
|
+
npm install
|
|
686
|
+
|
|
687
|
+
# Test locally
|
|
688
|
+
node index.js
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
## License
|
|
692
|
+
|
|
693
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
694
|
+
|
|
695
|
+
---
|
|
696
|
+
|
|
697
|
+
**Made with ❤️ for the MCP community**
|
|
698
|
+
|
|
699
|
+
For issues, questions, or contributions, visit: https://github.com/SteffenBlake/cli-mcp-mapper
|