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
// SPDX-License-Identifier: GPL-3.0-only
//! `doctrine serve` — start the MCP stdio server.
use anyhow::Context;
use clap::Args;
use std::path::PathBuf;
/// Arguments for `doctrine serve`.
#[derive(Args)]
pub(crate) struct ServeArgs {
/// Start the MCP (Model Context Protocol) stdio server, exposing review
/// verbs as tools over JSON-RPC 2.0.
#[arg(long)]
pub(crate) mcp: bool,
/// Explicit project root (default: auto-detect).
#[arg(long)]
pub(crate) path: Option<PathBuf>,
}
/// Run `doctrine serve`.
///
/// With `--mcp`: starts the MCP stdio server in a tokio runtime.
/// Other serve modes are deferred (design D6).
pub(crate) fn run_serve(args: ServeArgs) -> anyhow::Result<()> {
if args.mcp {
let rt = tokio::runtime::Runtime::new().context("failed to create tokio runtime")?;
rt.block_on(crate::mcp_server::serve(crate::mcp_server::McpConfig {
path: args.path,
// fn-item → fn-ptr coercion supplies the corpus producer; the back
// edge into commands::prompt now lives here at the forward-edge
// source, not inside mcp_server (SL-203 D-B).
model_keys: crate::commands::prompt::model_keys,
}))
} else {
anyhow::bail!("`serve` requires --mcp (other serve modes not yet implemented)");
}
}