MCP Server (AI agents)
@re-shell/mcp is a Model Context Protocol server that turns Re-Shell’s machine-readable commands into typed, validated tools, plus read-only resources and prompts, for AI agents. The source version for this release line is 0.3.1; the previous line used 0.3.0. Check the npm package and GitHub releases for publication evidence. Building or testing source does not publish it.
Because every Re-Shell data command emits a stable { ok, data, warnings } / { ok, error } envelope, defined once in @re-shell/contracts, it maps cleanly onto MCP tools an agent can call to inspect and reason about a workspace. Each result is validated against the exact wire schema the contract publishes for that command before the agent sees it.
Read-only tools (always registered):
workspace_summary,workspace_graph,workspace_healthtemplates_list,templates_show,templates_matrixdoctor,analyze,commands_list
Each wraps the corresponding re-shell ... --json command. Write tools are only registered when RE_SHELL_MCP_ALLOW_WRITE=1:
workspace_create(workspace init <name> --json)scaffold_service(generate service <name> --json; ifnameis missing it asks the host for it through MCP elicitation instead of failing)
Resources and prompts
Section titled “Resources and prompts”- Resources (read-only JSON):
reshell://workspace/summary,reshell://workspace/graph,reshell://workspace/health,reshell://scorecard,reshell://contracts/commands. - Prompts:
scaffold-service(a reviewable, dry-run plan of real commands) anddiagnose-drift(dependency drift and readiness gaps from the scorecard and health resources). Prompt arguments are treated as untrusted data.
Run it
Section titled “Run it”npx @re-shell/mcp@latest@re-shell/cli is a declared dependency of the package, so a standalone install is enough: you do not need to set RE_SHELL_BIN. The re-shell-mcp bin resolves symlinks, so it starts correctly through node_modules/.bin the way npx runs it. Wire it into an MCP client:
{ "mcpServers": { "re-shell": { "command": "npx", "args": ["-y", "@re-shell/mcp@latest"] } }}| Env var | Purpose |
|---|---|
RE_SHELL_BIN |
Optional override: a specific CLI entry (dist/index.js) instead of the installed @re-shell/cli |
RE_SHELL_MCP_ALLOW_WRITE |
1 to register the write tools (off by default) |
CLI resolution order: RE_SHELL_BIN, then require.resolve('@re-shell/cli'), then (in the monorepo) packages/cli/dist/index.js. The server runs inside the workspace directory you start it from.
Safety model
Section titled “Safety model”- Read-only by default; writes are opt-in.
- No shell: commands run via
spawnwith an argv array (nevershell: true), with an 8 MiB output cap and a 120 s backstop timeout. - Allow-listed: only the tools above are exposed, mirroring the dashboard hub’s command registry.
- Contract-validated: payloads are checked against
@re-shell/contractswire schemas before being returned; a CLI error envelope is passed through so the agent sees the realcodeandmessage.
What was tested
Section titled “What was tested”The package’s tests build dist/ and run the built bin through a symlink (as npx does) against the real CLI: the MCP initialize and tools/list handshake over stdio, every read-only tool and resource, and a check that the published tarball contains no test files. The repository’s node scripts/pack-smoke.mjs also packs the package together with the CLI and contracts, installs the tarballs in a clean directory outside the repo and runs the handshake against the installed re-shell-mcp.
See the JSON Contract and Secure Hub pages for the underlying design.