Skip to main content

mcp

Attribute Macro mcp 

Source
#[mcp]
Expand description

MCP metadata attribute for controlling how an endpoint is exposed as an MCP tool.

Supports:

  • #[mcp(skip)] — never expose this route as a tool
  • #[mcp(readonly)] — treat as read-only even if it’s a POST etc.
  • #[mcp(write)] — mark as a write operation
  • #[mcp(require = "confirm")] — agent should ask for confirmation

§Example

#[rustapi::get("/admin/secrets")]
#[rustapi::mcp(skip)]
async fn admin_secrets() -> &'static str { "secret" }

#[rustapi::post("/orders")]
#[rustapi::mcp(write, require = "confirm")]
async fn create_order(...) { ... }