Skip to main content

DevTools

Struct DevTools 

Source
pub struct DevTools { /* private fields */ }
Available on non-WebAssembly only.
Expand description

What DevMcpExt::dev_mcp_with mounts, and when.

use rust_web_server::app::App;
use rust_web_server::dev_mcp::{DevMcpExt, DevTools};

let app = App::with_state(()).dev_mcp_with(
    DevTools::new()
        .token_env("APP_DEV_TOKEN") // instead of MCP_TOKEN
        .with_ops()                 // the rws binary's 25 tools too
        .read_only(),               // but nothing that changes state
);

Implementations§

Source§

impl DevTools

Source

pub fn new() -> DevTools

The defaults: server rws-dev, endpoint /mcp, RWS_ENV and MCP_TOKEN from the environment, changing tools included, requests recorded for recent_requests, no operations tools, no database.

Source

pub fn server_info( self, name: impl Into<String>, version: impl Into<String>, ) -> DevTools

serverInfo the endpoint reports (default rws-dev and the rws version).

Source

pub fn at(self, path: impl Into<String>) -> DevTools

The endpoint’s path (default /mcp) — for an app that serves its own MCP server there.

Source

pub fn env(self, env: RwsEnv) -> DevTools

Decide as if RWS_ENV were env instead of reading it.

Source

pub fn token(self, token: impl Into<String>) -> DevTools

Require this bearer token (and mount the endpoint in any environment). An empty or blank token counts as none.

Source

pub fn token_env(self, name: impl Into<String>) -> DevTools

Read the token from this environment variable instead of MCP_TOKEN (DEFAULT_TOKEN_ENV); Self::token wins over it.

Source

pub fn read_only(self) -> DevTools

Leave out every tool that changes something (OPS_WRITE_TOOLS, DEV_WRITE_TOOLS): the agent can look, not act.

Source

pub fn with_ops(self) -> DevTools

Mount the rws binary’s operations tools as well (ops_tools): metrics, rate limits, CORS, static files, maintenance mode, the IP blocklist, feature flags, authorization, traffic, config reload.

Source

pub fn cache(self, cache: CacheLayer) -> DevTools

The response cache for the cache_stats / cache_clear operations tools (a clone of the layer the app wraps; clones share the store). Implies Self::with_ops.

Source

pub fn record_requests(self, record: bool) -> DevTools

Whether requests to the app are recorded into the request log that recent_requests / recent_errors read (default true). Turn it off when the app already has a crate::request_log::LogLayer, or each request is listed twice.

Source

pub fn allowed_origins<I, S>(self, origins: I) -> DevTools
where I: IntoIterator<Item = S>, S: Into<String>,

Browser origins allowed to call the endpoint (McpServer::allowed_origins); desktop and CLI clients send no Origin and need none.

Source

pub fn database(self, pool: DbPool) -> DevTools

Available on crate features model-mysql or model-postgres or model-sqlite only.

The database db_schema and the migration tools use.

Source

pub fn migrations(self, dir: impl Into<String>) -> DevTools

Available on crate features model-mysql or model-postgres or model-sqlite only.

The directory of *.sql migrations (crate::model::DbPool::migrate) for migrations (status), migrations_run and migrations_rollback_last. Needs Self::database.

Source

pub fn model<T>(self) -> DevTools
where T: Model,

Available on crate features model-mysql or model-postgres or model-sqlite only.

Report the #[derive(Model)] type T in models: its table, columns and primary key (crate::model::ModelInfo), compared with the database’s table when Self::database is set. Rust can’t list a program’s models at run time, so each is named once; registering one twice lists it once.

Source

pub fn app_dir(self, dir: impl Into<PathBuf>) -> DevTools

The project root layout reads rws.app.toml and the conventional paths from (default: the working directory when the tools are installed). env!("CARGO_MANIFEST_DIR") is the project’s own root in cargo run and cargo test, whatever the working directory — the starters pass it, since they serve static files from another directory.

Source

pub fn enabled(&self) -> bool

Whether Self::mount mounts the endpoint: RWS_ENV=dev, or a token configured.

Source

pub fn register(&self, mcp: McpServer) -> McpServer

Register the tools on mcp, ungated: routes, config, layout, recent_requests, recent_errors, with a model-* feature models, with a database db_schema, with migrations migrations (and migrations_run, migrations_rollback_last unless Self::read_only), and the operations tools with Self::with_ops. The routes are those of the app mcp wraps (McpServer::wrap). For an app that builds its own MCP server and gates it itself; Self::mount is the gated form.

Source

pub fn mount<A>(self, app: A) -> DevMcp<A>
where A: Application + Send + Sync + 'static,

app with the endpoint in front of it when Self::enabled; otherwise app alone, and a one-line notice on stdout.

Trait Implementations§

Source§

impl Clone for DevTools

Source§

fn clone(&self) -> DevTools

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DevTools

Source§

fn default() -> DevTools

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ServiceExt for T

Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Available on crate feature map-response-body only.
Apply a transformation to the response body. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

Available on crate feature trace only.
High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

Available on crate feature trace only.
High level tracing that classifies responses using gRPC headers. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more