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 /helloDevTools 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_withmounts, and when.
Enums§
- DevMcp
- An app with the dev MCP endpoint in front of it (
DevMcp::On), or the app alone (DevMcp::Off) — whatDevMcpExt::dev_mcpreturns. AnApplicationeither way. - RwsEnv
- The environment kind named by
RWS_ENV.
Constants§
- DEFAULT_
TOKEN_ ENV - The environment variable a token is read from unless
DevTools::tokenorDevTools::token_envsays otherwise — the one therwsbinary’s/mcpuses. - DEV_
WRITE_ TOOLS - The tools that change something, besides
OPS_WRITE_TOOLS: the migration runners (with amodel-*feature and a migrations directory). - OPS_
WRITE_ TOOLS - The operations tools that change the running server. They are what
crate::admin::access::McpAuditLayerrecords, and whatsuper::DevTools::read_onlyleaves out.
Traits§
- DevMcp
Ext .dev_mcp()on everyApplication—AppWithState,App,WithMiddleware,AsyncAppWithStateand the rest.
Functions§
- masked
valueasconfigshows 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— therwsbinary’s set: configuration, metrics, routes (routesas(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 carriesToolAnnotations: read-only, or changing (destructive exceptunblock_ip).