rtb_mcp/lib.rs
1//! MCP server exposing tool commands as Model Context Protocol tools.
2//!
3//! A thin layer over the official [`rmcp`] SDK. Every
4//! [`rtb_app::command::Command`] in [`rtb_app::command::BUILTIN_COMMANDS`]
5//! that returns `true` from `Command::mcp_exposed()` is registered as
6//! an MCP tool on server start. The tool's `tools/call` invocation
7//! runs the underlying `Command::run` against a clone of the host
8//! `App`.
9//!
10//! # Quick start
11//!
12//! ```no_run
13//! use rtb_app::app::App;
14//! use rtb_mcp::{McpServer, Transport};
15//!
16//! # async fn run(app: App) -> Result<(), rtb_mcp::McpError> {
17//! McpServer::new(app, Transport::Stdio).serve().await
18//! # }
19//! ```
20//!
21//! See `docs/development/specs/2026-05-01-rtb-mcp-v0.1.md` for the
22//! authoritative contract.
23
24// `deny` (not `forbid`) so the CLI-command module can allow
25// `unsafe_code` for its `linkme::distributed_slice` registration —
26// same rationale as `rtb-update` / `rtb-vcs`. No hand-rolled
27// `unsafe` blocks exist in this crate.
28#![deny(unsafe_code)]
29
30mod command;
31mod error;
32mod server;
33mod transport;
34
35pub use command::McpCmd;
36pub use error::{McpError, Result};
37pub use server::McpServer;
38pub use transport::Transport;