Skip to main content

Crate brontes

Crate brontes 

Source
Expand description

brontes: transform clap CLIs into MCP servers.

brontes walks a clap::Command tree, exposes every reachable command as an MCP tool, and ships a complete MCP server runtime over stdio so the resulting agent surface plugs straight into Claude Desktop, Cursor, and VSCode.

§Two-line quick start

use clap::Command;

#[tokio::main]
async fn main() -> brontes::Result<()> {
    let cli = Command::new("my-cli")
        .version("0.1.0")
        .subcommand(Command::new("greet").about("Say hi"))
        .subcommand(brontes::command(None));            // [1] mount

    let matches = cli.clone().get_matches();
    match matches.subcommand() {
        Some(("mcp", sub)) => brontes::handle(sub, &cli, None).await,  // [2] dispatch
        Some(("greet", _)) => { println!("hi"); Ok(()) }
        _ => Ok(()),
    }
}

For tiny CLIs whose only purpose is the MCP server, collapse the ceremony into one line with run:

use clap::Command;

#[tokio::main]
async fn main() -> brontes::Result<()> {
    brontes::run(Command::new("my-cli").version("0.1.0"), None).await
}

§Capabilities

  • generate_tools — walk a clap::Command tree into a Vec<rmcp::model::Tool> for offline inspection, editor-config generation, or hand-rolled server wiring.
  • command, handle, run — mount the mcp subtree and serve the generated tool list over stdio (mcp start) or streamable HTTP (mcp stream --host <addr> --port <num>).
  • Config — selectors, annotations, per-flag schema overrides, default environment variables, server identity overrides, per-command description mode and full-text override.
  • Selector, Middleware — first-match-wins routing rules and an async middleware boundary for wrapping tool execution.

Bug reports and feature requests: https://github.com/tj-smith47/brontes/issues.

Modules§

selectors
Built-in factory functions for CmdMatcher and FlagMatcher.

Structs§

Config
User-facing configuration for the mcp subtree.
MiddlewareCtx
Per-call context handed to Middleware.
Selector
Filtering rules that decide which commands become MCP tools and which flags those tools expose.
ToolAnnotations
Annotation hints attached to an MCP tool.
ToolInput
Request payload for a tool invocation.
ToolOutput
Response payload from a tool invocation.

Enums§

DescriptionMode
Which clap field provides the primary text for an MCP tool description.
Error
Errors produced by brontes.
SchemaType
Coarse JSON Schema type for a clap flag.

Functions§

command
Build the mcp subcommand subtree, ready to mount on a parent CLI.
generate_tools
Walk root, apply safety filters, apply first-match-wins selectors, and produce the MCP tool list ready to register with a server.
handle
Dispatch an mcp subcommand match.
run
One-call sugar: mount the mcp subtree, parse argv, dispatch.

Type Aliases§

BoxedNext
One-shot async callable that runs the wrapped exec step.
CmdMatcher
Match a command by its space-joined path (e.g., "my-cli sub leaf").
FlagMatcher
Match a flag by inspecting its clap::Arg descriptor.
Middleware
Wrap tool-call execution with custom async logic.
MiddlewareResult
What a middleware (and the underlying exec step) ultimately produces.
Result
Result alias for fallible brontes operations.