phoebus_os/installer-rs/crates/phoebus-mcp/src/main.rs
Phoebus 6d48ad38fc feat(stability): add boot assessment, preflight storage gates, tiered channels and userspace agent framework
- systemd Automatic Boot Assessment: BLS +<tries> parsing/formatting and phoebus-boot-confirm.service
- Preflight safety gates: 10 GiB storage preflight check and atomic @ and @var pre-update snapshots
- Tiered update channels: Core, Proven (default), Edge
- Userspace AI agent framework: agent_jail Bubblewrap isolation, desktop_config undoable mutations, phoebus-mcp server, sys propose staging bridge
- Fixed parent directory creation race condition in personal storage
- Verified with cargo fmt, clippy, and full workspace test suite
2026-09-30 03:40:41 -07:00

50 lines
1.3 KiB
Rust

//! Model Context Protocol (MCP) server executable for Phoebus OS.
//!
//! Speaks JSON-RPC 2.0 over standard I/O, conforming to the MCP specification.
//! Used by Claude Code, Cursor, OpenCode, and Zed.
use std::io::{self, BufRead, Write};
use std::path::PathBuf;
use clap::Parser;
use phoebus_mcp::handle_mcp_message;
#[derive(Parser, Debug)]
#[command(
name = "phoebus-mcp",
about = "Model Context Protocol server for Phoebus OS desktop & developer agents"
)]
struct Cli {
/// Override the user's home directory (useful for testing or isolation).
#[arg(long)]
home: Option<PathBuf>,
}
fn main() {
let cli = Cli::parse();
let home = cli.home.unwrap_or_else(|| {
std::env::var("HOME")
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from("."))
});
let stdin = io::stdin();
let mut stdout = io::stdout();
for line in stdin.lock().lines() {
let line = match line {
Ok(l) => l,
Err(_) => break,
};
let trimmed = line.trim();
if trimmed.is_empty() {
continue;
}
if let Some(response) = handle_mcp_message(trimmed, &home) {
let _ = writeln!(stdout, "{response}");
let _ = stdout.flush();
}
}
}