mcp-wrap
README.md
# mcp-wrap
**Wrap any command-line tool as an [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server — offline, zero dependencies.**
You have scripts and CLI tools that already do useful work. AI clients like Claude Desktop or Cursor can only call them if they speak MCP. mcp-wrap is the bridge: declare your tools in one JSON file, and mcp-wrap serves them over stdio as JSON-RPC 2.0 — no SDK, no build step, no network, nothing to install beyond Node.js.
## Install
Requires Node.js ≥ 18. No dependencies.
```bash
# from a clone of this repository
npm install -g . # or: npm link
# or run it in place
node src/cli.js --help
```
## Quick start
```bash
mcp-wrap init # writes mcp-wrap.config.json (a sample)
mcp-wrap check mcp-wrap.config.json
mcp-wrap serve mcp-wrap.config.json
```
`serve` speaks MCP on stdin/stdout, so it is normally launched by an MCP client, not run by hand.
## Config format
```json
{
"name": "my-tools",
"version": "1.0.0",
"timeoutMs": 30000,
"maxOutputBytes": 65536,
"tools": [
{
"name": "echo",
"description": "Echo the given text back, unchanged.",
"command": "echo",
"args": ["{text}"],
"arguments": {
"text": { "type": "string", "required": true, "description": "Text to echo" }
}
},
{
"name": "disk-usage",
"description": "Show disk usage for a path.",
"command": "df",
"args": ["-h", "{path}"],
"timeoutMs": 5000,
"arguments": {
"path": { "type": "string", "required": false, "default": "." }
}
}
]
}
```
- `name` / `version` — reported to clients as the server identity.
- `timeoutMs` — default per-call timeout (30 s). A tool may override it with its own `timeoutMs`.
- `maxOutputBytes` — per-call output cap for stdout and stderr (64 KiB default). Output past the cap is truncated and the call is reported as an error.
- Each tool has a `name`, a `description`, a `command`, and an `args` template array. `{name}` placeholders in `args` are replaced with the string form of the matching call argument.
- `arguments` declares each argument's `type` (`string`, `number`, or `boolean`), whether it is `required`, an optional `description`, and an optional `default`. mcp-wrap generates the tool's `inputSchema` from this declaration, validates every call against it, and rejects undeclared placeholders at load time.
## Safety model
Commands are spawned with an **argv array and no shell** (`shell: false`). Argument values reach the operating system as single argv entries, so values containing `;`, `$()`, backticks or pipes are inert data — they cannot inject extra commands. Combined with the timeout and output caps, a wrapped tool cannot hang the client or flood it.
## Connect it to Claude Desktop
Add the server to your `claude_desktop_config.json`:
```json
{
"mcpServers": {
"my-tools": {
"command": "node",
"args": ["/path/to/mcp-wrap/src/cli.js", "serve", "/path/to/mcp-wrap.config.json"]
}
}
}
```
Restart the client; the declared tools appear alongside the built-in ones. The same `command`/`args` shape works for Cursor and other stdio MCP clients.
## Commands
| Command | What it does |
| --- | --- |
| `mcp-wrap serve <config.json>` | Run the MCP server on stdio until stdin closes |
| `mcp-wrap init [file]` | Write a sample config (default `mcp-wrap.config.json`); refuses to overwrite |
| `mcp-wrap check <config.json>` | Validate a config and list the tools it will expose (no server started) |
## Protocol coverage
Implements the core MCP method set over the stdio transport (newline-delimited JSON-RPC 2.0): `initialize` (echoes the client's requested protocol version), `notifications/initialized` (accepted silently), `ping`, `tools/list`, and `tools/call`. Results use the standard MCP `content: [{ "type": "text", ... }]` shape with `isError` for failed commands. Malformed requests get proper JSON-RPC errors: `-32700` parse error, `-32600` invalid request, `-32601` method not found, `-32602` invalid params (including unknown tools and missing/mistyped arguments).
## Limitations
Honest list — mcp-wrap is deliberately small:
- **stdio transport only.** No HTTP, SSE, or WebSocket transport, so it cannot serve remote or multi-client setups.
- **Argument schemas are a simple subset of JSON Schema**: flat objects with `string` / `number` / `boolean` properties, `required`, `description`, and `default`. No nested objects, arrays, enums, or string formats.
- Placeholders are substituted into argument strings only — a tool's `command` itself is fixed by the config, by design.
- No support yet for MCP resources, prompts, sampling, roots, progress notifications, or cancellation of an in-flight call (a call still ends at its timeout).
- Tool output is returned as a single text block; binary output is decoded as UTF-8 text.
## Development
```bash
npm test # node --test: config validation, CLI, and live protocol tests over stdio
```
## License
MIT — see [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues