pub trait SqliteServerTool: JsonSchema {
type Context;
type Error: IntoContents;
type Input: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static;
type Output: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static;
const NAME: &str;
// Required method
fn handle(
ctx: &Self::Context,
input: Self::Input,
) -> Result<Self::Output, Self::Error>;
// Provided methods
fn tool() -> Tool { ... }
fn handler_func( ) -> fn(&<Self as SqliteServerTool>::Context, Parameters<<Self as SqliteServerTool>::Input>) -> Result<Json<<Self as SqliteServerTool>::Output>, <Self as SqliteServerTool>::Error> { ... }
}Expand description
A statically-typed MCP tool backed by a SQLite server. Each implementor
represents a single tool exposed to MCP clients. The trait derives the
tool’s JSON schema from its associated types and wires up a handler closure
compatible with the rmcp ToolRouter.
Required Associated Constants§
Required Associated Types§
Sourcetype Context
type Context
The server type passed to the handler on each invocation, typically
McpServerSqlite.
Sourcetype Error: IntoContents
type Error: IntoContents
The error type returned by the handler. Must implement IntoContents so
rmcp can render it as error content.
Sourcetype Input: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static
type Input: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static
The deserialized input parameters received from the MCP client.
Sourcetype Output: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static
type Output: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static
The structured output returned to the MCP client on success.
Required Methods§
Provided Methods§
Sourcefn tool() -> Tool
fn tool() -> Tool
Builds the rmcp Tool definition for this tool, including its name,
description (extracted from the JsonSchema derive), input schema, and
output schema.
Sourcefn handler_func() -> fn(&<Self as SqliteServerTool>::Context, Parameters<<Self as SqliteServerTool>::Input>) -> Result<Json<<Self as SqliteServerTool>::Output>, <Self as SqliteServerTool>::Error>
fn handler_func() -> fn(&<Self as SqliteServerTool>::Context, Parameters<<Self as SqliteServerTool>::Input>) -> Result<Json<<Self as SqliteServerTool>::Output>, <Self as SqliteServerTool>::Error>
Returns a closure that deserializes the input parameters, calls
handle, and wraps the output in Json for structured MCP responses.
Every invocation is automatically traced with the tool name, duration,
and outcome. The closure is compatible with ToolRouter::with_route.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.