Skip to main content

objectiveai_sdk/cli/command/mcp/kill/
mod.rs

1//! `mcp kill` — async handler stub.
2
3use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.mcp.kill.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub jq: Option<String>,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.mcp.kill.Path")]
14pub enum Path {
15    #[serde(rename = "mcp/kill")]
16    McpKill,
17}
18impl CommandRequest for Request {
19    fn into_command(&self) -> Vec<String> {
20        let mut argv = vec!["mcp".to_string(), "kill".to_string()];
21        if let Some(jq) = &self.jq {
22            argv.push("--jq".to_string());
23            argv.push(jq.clone());
24        }
25        argv
26    }
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
30#[schemars(rename = "cli.command.mcp.kill.Response")]
31pub struct Response {
32    pub killed: usize,
33}
34
35#[derive(clap::Args)]
36pub struct Args {
37    /// jq filter applied to the JSON output.
38    #[arg(long)]
39    pub jq: Option<String>,
40}
41
42#[derive(clap::Args)]
43#[command(args_conflicts_with_subcommands = true)]
44pub struct Command {
45    #[command(flatten)]
46    pub args: Args,
47    #[command(subcommand)]
48    pub schema: Option<Schema>,
49}
50
51#[derive(clap::Subcommand)]
52pub enum Schema {
53    /// Emit the JSON Schema for this leaf's `Request` type and exit.
54    RequestSchema(request_schema::Args),
55    /// Emit the JSON Schema for this leaf's `Response` type and exit.
56    ResponseSchema(response_schema::Args),
57}
58
59impl TryFrom<Args> for Request {
60    type Error = crate::cli::command::FromArgsError;
61    fn try_from(args: Args) -> Result<Self, Self::Error> {
62        Ok(Self { path_type: Path::McpKill, jq: args.jq })
63    }
64}
65
66#[cfg(feature = "cli-executor")]
67pub async fn execute<E: crate::cli::command::CommandExecutor>(
68    executor: &E,
69    mut request: Request,
70
71        agent_arguments: Option<&crate::cli::command::AgentArguments>,
72    ) -> Result<Response, E::Error> {
73    request.jq = None;
74    executor.execute_one(request, agent_arguments).await
75}
76
77#[cfg(feature = "cli-executor")]
78pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
79    executor: &E,
80    mut request: Request,
81    jq: String,
82
83        agent_arguments: Option<&crate::cli::command::AgentArguments>,
84    ) -> Result<serde_json::Value, E::Error> {
85    request.jq = Some(jq);
86    executor.execute_one(request, agent_arguments).await
87}
88
89#[cfg(feature = "mcp")]
90impl crate::cli::command::CommandResponse for Response {
91    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
92        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
93    }
94}
95
96pub mod request_schema;
97
98pub mod response_schema;