faucet_cli/commands/
mcp.rs1use crate::cli::McpArgs;
12use crate::error::CliResult;
13use crate::mcp::{McpContext, serve_stdio};
14use tokio::io::BufReader;
15
16pub async fn run(args: McpArgs) -> CliResult<()> {
17 let cwd = std::env::current_dir()?;
18 let env_path =
19 crate::env_loader::resolve_env_file(args.env_file.as_deref(), args.no_env_file, &cwd)?;
20 crate::env_loader::load_env_file_if_present(env_path.as_deref())?;
21
22 let auth = crate::auth_catalog::build_auth_catalog(None)?;
25 let ctx = McpContext::new(auth, args.allow_mutations);
26
27 tracing::info!(
28 allow_mutations = args.allow_mutations,
29 "faucet mcp stdio server started"
30 );
31
32 let mut stdout = tokio::io::stdout();
33 serve_stdio(&ctx, BufReader::new(tokio::io::stdin()), &mut stdout).await?;
34
35 tracing::info!("faucet mcp stdio server stopped (stdin closed)");
36 Ok(())
37}