MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / parse_command_and_args

Function parse_command_and_args

crates/opencode-server/src/routes.rs:2755–2792  ·  view source on GitHub ↗
(
    command: Option<McpCommandInput>,
    extra_args: Vec<String>,
)

Source from the content-addressed store, hash-verified

2753}
2754
2755fn parse_command_and_args(
2756 command: Option<McpCommandInput>,
2757 extra_args: Vec<String>,
2758) -> Result<(String, Vec<String>)> {
2759 match command {
2760 Some(McpCommandInput::String(cmd)) => {
2761 if cmd.trim().is_empty() {
2762 return Err(ApiError::BadRequest(
2763 "MCP local config `command` cannot be empty".to_string(),
2764 ));
2765 }
2766 Ok((cmd, extra_args))
2767 }
2768 Some(McpCommandInput::Array(parts)) => {
2769 let mut iter = parts.into_iter();
2770 let cmd = iter
2771 .next()
2772 .ok_or_else(|| {
2773 ApiError::BadRequest(
2774 "MCP local config `command` array cannot be empty".to_string(),
2775 )
2776 })?
2777 .trim()
2778 .to_string();
2779 if cmd.is_empty() {
2780 return Err(ApiError::BadRequest(
2781 "MCP local config `command` cannot be empty".to_string(),
2782 ));
2783 }
2784 let mut args: Vec<String> = iter.collect();
2785 args.extend(extra_args);
2786 Ok((cmd, args))
2787 }
2788 None => Err(ApiError::BadRequest(
2789 "MCP local config requires `command`".to_string(),
2790 )),
2791 }
2792}
2793
2794fn parse_runtime_from_loaded_config(
2795 config: LoadedMcpServerConfig,

Callers 1

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected