Skip to main content
Glama

mcp-wrap

Wrap any command-line tool as an MCP (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.

# from a clone of this repository
npm install -g .        # or: npm link
# or run it in place
node src/cli.js --help

Related MCP server: cli2mcp

Quick start

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

{
  "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:

{
  "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

npm test   # node --test: config validation, CLI, and live protocol tests over stdio

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables turning any command-line tool into an MCP server with auto-generated JSON schema, supporting stdio, timeouts, and stderr capture.
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Enables exposing custom tools such as dice rolling and integer addition as MCP servers over stdio and HTTP transports.
      2
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables developers to expose any dev tool as a safe, audited MCP server with permission tiers, audit logging, and automatic argument validation.
      MIT