Skip to main content

SqliteServerTool

Trait SqliteServerTool 

Source
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§

Source

const NAME: &str

The tool name advertised to MCP clients (e.g. "execute").

Required Associated Types§

Source

type Context

The server type passed to the handler on each invocation, typically McpServerSqlite.

Source

type Error: IntoContents

The error type returned by the handler. Must implement IntoContents so rmcp can render it as error content.

Source

type Input: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static

The deserialized input parameters received from the MCP client.

Source

type Output: Serialize + for<'de> Deserialize<'de> + JsonSchema + 'static

The structured output returned to the MCP client on success.

Required Methods§

Source

fn handle( ctx: &Self::Context, input: Self::Input, ) -> Result<Self::Output, Self::Error>

Executes the tool’s logic against the given context and input. Called synchronously on the tokio blocking thread pool.

Provided Methods§

Source

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.

Source

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.

Implementors§

Source§

impl SqliteServerTool for BackupTool

Source§

impl SqliteServerTool for CreateFtsIndexTool

Source§

impl SqliteServerTool for DatabaseInfoTool

Source§

impl SqliteServerTool for DescribeTableTool

Source§

impl SqliteServerTool for ExecuteTool

Source§

impl SqliteServerTool for ExplainQueryTool

Source§

impl SqliteServerTool for ListForeignKeysTool

Source§

impl SqliteServerTool for ListIndexesTool

Source§

impl SqliteServerTool for ListTablesTool

Source§

impl SqliteServerTool for ListTriggersTool

Source§

impl SqliteServerTool for ListViewsTool

Source§

impl SqliteServerTool for SearchFtsTool

Source§

impl SqliteServerTool for VacuumTool