swarm repositories / source
aboutsummaryrefslogtreecommitdiff
path: root/crates/jira-at-home/src/main.rs
blob: 932bc6393db4c3cb51a8ec2d30742fc5c455dcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
mod mcp;
mod store;

use std::path::PathBuf;

use clap::{Args, Parser, Subcommand};
#[cfg(test)]
use libmcp_testkit as _;

#[derive(Parser)]
#[command(
    author,
    version,
    about = "Per-project issue notebook MCP with a hardened host/worker spine"
)]
struct Cli {
    #[command(subcommand)]
    command: Command,
}

#[derive(Subcommand)]
enum Command {
    /// Serve the stdio MCP host.
    Mcp {
        #[command(subcommand)]
        command: McpCommand,
    },
}

#[derive(Subcommand)]
enum McpCommand {
    /// Run the durable stdio host.
    Serve(McpServeArgs),
    /// Run the disposable worker process.
    Worker(McpWorkerArgs),
}

#[derive(Args)]
struct McpServeArgs {
    /// Optional project path to bind immediately on startup.
    #[arg(long)]
    project: Option<PathBuf>,
}

#[derive(Args)]
struct McpWorkerArgs {
    /// Bound project root.
    #[arg(long)]
    project: PathBuf,
    /// Logical worker generation assigned by the host.
    #[arg(long)]
    generation: u64,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cli = Cli::parse();
    match cli.command {
        Command::Mcp { command } => match command {
            McpCommand::Serve(args) => mcp::run_host(args.project)?,
            McpCommand::Worker(args) => mcp::run_worker(args.project, args.generation)?,
        },
    }
    Ok(())
}