use anyhow::Result;
#[derive(clap::Args)]
pub struct Args {
#[command(subcommand)]
pub command: McpCommand,
}
#[derive(clap::Subcommand)]
pub enum McpCommand {
#[command(
long_about = "Starts the MCP (Model Context Protocol) server on stdio.\n\
The server reads JSON-RPC requests from stdin and writes responses\n\
to stdout. This allows AI coding tools like Claude Code to query\n\
Lore session data.\n\n\
Available tools:\n \
- lore_search: Search session messages\n \
- lore_get_session: Get full session details\n \
- lore_list_sessions: List recent sessions\n \
- lore_get_context: Get repository context\n \
- lore_get_linked_sessions: Get sessions linked to a commit"
)]
Serve,
}
pub fn run(args: Args) -> Result<()> {
match args.command {
McpCommand::Serve => run_serve(),
}
}
fn run_serve() -> Result<()> {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(crate::mcp::run_server())
}