Skip to main content

parse_request

Function parse_request 

Source
pub fn parse_request(args: &[String]) -> Result<Request, ParseError>
Expand description

Parse an argv slice into a typed Request. Accepts either shape:

  • With a program-name prefix (["objectiveai", "agents", "list"]) — matches std::env::args() and binary entry-point usage.
  • Without one (["agents", "list"]) — matches super::CommandRequest::into_command’s output shape and the “command-only” shape MCP callers send.

If args[0] is "objectiveai" we pass it straight through; otherwise we prepend so clap (which always treats argv[0] as the program name) sees a well-formed argv. Hides clap behind the SDK boundary so downstream crates can dispatch arbitrary argv without taking a clap dep themselves.