nestrs-mcp is the Model Context Protocol server for the nestrs framework. It exposes project structure, live runtime state, scaffolding actions, and docs search to MCP-aware clients (Claude Code, Cursor, VS Code, Codex CLI).
The full narrative guide — install, client wiring for each editor, live-runtime setup — lives on the Connect an AI editor to your nestrs project page. This page is the API reference.
Features
CLI
Thenestrs-mcp binary runs as either a server (no subcommand, with a --transport flag) or as a setup wizard (init / setup subcommand). --transport defaults to stdio; --http-addr is required when --transport http is set on the server path.
Tool surface
The server is armcp ServerHandler with a #[tool_router] macro that declares each tool. Tools are aggregated into a single NestrsMcpServer struct.
Introspection (read-only, read_only_hint = true)
Every tool takes workspace_path: String as its first argument so one server instance can serve multiple projects over a long session.
Runtime (requires a running app with admin feature)
Backed by an
AdminClient (reqwest + rustls-tls) hitting the app’s localhost-only admin port. Token auth via Authorization: Bearer <token>.
Scaffolding (write actions, destructive_hint = true)
All write actions return
{ files_created: [..], files_modified: [..] } so the model can show the user exactly what changed before any irreversible step. Scaffolding actions check that the target path is inside a Cargo.toml workspace before any write to defend against path = "../../" footguns.
Docs search (read-only, read_only_hint = true)
AdminClient
base_url (no trailing /__nestrs/*) and an optional bearer token. All three methods apply the token if present. Request timeout is 5 seconds; no retries — the model decides whether to re-invoke.
Error conventions
- Tool-level failure (operation ran but failed): the tool returns a
CallToolResult::errorso the model can see the message and recover. Examples: file not found, parse error, app not reachable. - Protocol-level failure (bad params, server can’t process): the tool returns
Err(McpError::invalid_params(...)).
Embedding in another binary
nestrs-mcp is a library as well as a binary. Embedders (e.g. a future nestrs mcp subcommand in the CLI) can mount NestrsMcpServer directly without spawning a subprocess:
nestrs-cli Cargo manifest already has nestrs-mcp as an optional dep behind an mcp feature so the subcommand is a one-file follow-up.