api-mcp
Source: crates/lvcs/src/api/mcp/mod.rs.
/// One `lvcs mcp` run: the participant it says `hello` as (`--as`, else
/// `LVCS_PARTICIPANT`, never an owner default; with neither, `lvcs mcp`
/// exits 2 with `lvcs: no participant`) and the project root (`--root`,
/// else the current directory).
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct McpOptions {
pub(crate) participant: String,
pub(crate) root: Option<PathBuf>,
}
/// Serve MCP on stdin and stdout until stdin ends, then exit 0. With no
/// daemon on this user's socket, or a `hello` the daemon refuses, it
/// prints `lvcs: <reason>` on stderr and exits 1 before reading stdin; it
/// does the same when stdin or stdout fails.
pub(crate) fn serve(options: &McpOptions) -> ExitCode {
match run(options) {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
let _ = writeln!(std::io::stderr(), "lvcs: {err}");
ExitCode::FAILURE
}
}
}