Skip to main content

shell_is_all_you_need/
lib.rs

1//! A dependency-free MCP 2026-07-28 server that exposes fixed process
2//! invocations as tools over stdio.
3
4mod cli;
5mod config;
6mod json;
7mod limits;
8mod path_policy;
9mod process;
10mod protocol;
11mod schema;
12mod server;
13mod sys;
14mod task;
15mod template;
16mod tool;
17
18#[cfg(test)]
19mod test_support;
20
21use std::process::ExitCode;
22
23/// Parses `args` (without the program name), then serves or prints help.
24///
25/// Errors are reported on stderr. Exit code 2 means invalid configuration and
26/// 1 means a runtime failure.
27pub fn main(args: impl IntoIterator<Item = String>) -> ExitCode {
28    let command = match cli::parse(args) {
29        Ok(command) => command,
30        Err(error) => {
31            eprintln!("shell-is-all-you-need: {error}");
32            return ExitCode::from(2);
33        }
34    };
35    match command {
36        cli::Command::Help => println!("{}", cli::USAGE),
37        cli::Command::Version => println!("shell-is-all-you-need {}", env!("CARGO_PKG_VERSION")),
38        cli::Command::Serve(config) => {
39            if let Err(error) = server::serve(config) {
40                eprintln!("shell-is-all-you-need: {error}");
41                return ExitCode::FAILURE;
42            }
43        }
44    }
45    ExitCode::SUCCESS
46}