Skip to main content

Module dev_mcp

Module dev_mcp 

Source
Available on non-WebAssembly only.
Expand description

app.dev_mcp(): an MCP endpoint for a coding agent (18.28.0). app.dev_mcp(): an MCP endpoint that lets a coding agent look inside the application it is working on — its routes and the middleware around them, its effective configuration (secrets hidden), its layout and rws.app.toml (crate::app_manifest), the last requests and errors, and with a model-* feature its models, database schema and migrations. Since 18.28.0 (roadmap #85, #87).

Off unless the process runs with RWS_ENV=dev (RwsEnv) or a bearer token is configured (MCP_TOKEN by default, DevTools::token): in production without a token DevMcpExt::dev_mcp mounts nothing and the app is served as it is. With a token every request to the endpoint must carry Authorization: Bearer <token> (McpServer::require_bearer); in development without one the endpoint is open, so keep the port local or set a token.

use rust_web_server::app::App;
use rust_web_server::core::New;
use rust_web_server::dev_mcp::DevMcpExt;
use rust_web_server::response::Response;

let app = App::with_state(())
    .get("/hello", |_, _, _, _| Response::new())
    .dev_mcp(); // RWS_ENV=dev: /mcp lists GET /hello

DevTools chooses what is mounted: the operations tools of the rws binary too (DevTools::with_ops, also usable alone as ops_tools), a database, a migrations directory, read-only mode.

Structs§

DevTools
What DevMcpExt::dev_mcp_with mounts, and when.

Enums§

DevMcp
An app with the dev MCP endpoint in front of it (DevMcp::On), or the app alone (DevMcp::Off) — what DevMcpExt::dev_mcp returns. An Application either way.
RwsEnv
The environment kind named by RWS_ENV.

Constants§

DEFAULT_TOKEN_ENV
The environment variable a token is read from unless DevTools::token or DevTools::token_env says otherwise — the one the rws binary’s /mcp uses.
DEV_WRITE_TOOLS
The tools that change something, besides OPS_WRITE_TOOLS: the migration runners (with a model-* feature and a migrations directory).
OPS_WRITE_TOOLS
The operations tools that change the running server. They are what crate::admin::access::McpAuditLayer records, and what super::DevTools::read_only leaves out.

Traits§

DevMcpExt
.dev_mcp() on every Application — AppWithState, App, WithMiddleware, AsyncAppWithState and the rest.

Functions§

masked
value as config shows it: crate::entry_point::shown (secrets by name, PKCS#11 PINs), and a password in a URL’s user info (postgres://app:pw@db/app) hidden too.
ops_tools
Register the 25 operations tools on mcp — the rws binary’s set: configuration, metrics, routes (routes as (method, pattern)), the response cache (cache’s stats and purge; both tools are left out without one), rate limits, CORS, static files, config reload, maintenance mode, the IP blocklist, runtime feature flags, the request log, authorization tuples and checks, and the traffic summary. Each carries ToolAnnotations: read-only, or changing (destructive except unblock_ip).