pub fn ops_tools(
mcp: McpServer,
routes: Vec<(String, String)>,
cache: Option<CacheLayer>,
) -> McpServerAvailable on non-WebAssembly only.
Expand description
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).
No gating here: put it behind a token
(McpServer::require_bearer), or use super::DevTools::with_ops,
which mounts it only in development or with a token.
use rust_web_server::app::App;
use rust_web_server::cache::CacheLayer;
use rust_web_server::dev_mcp::ops_tools;
let app = App::with_state(());
let routes: Vec<(String, String)> = app.route_entries().into_iter().map(|r| (r.method, r.pattern)).collect();
let cache = CacheLayer::memory(500).ttl(60);
let mcp = ops_tools(app.wrap(cache.clone()).mcp("rws", "1.0").require_bearer("secret"), routes, Some(cache));