objectiveai_sdk/cli/command/agents/mcp/servers/list/
mod.rs1use crate::cli::command::CommandRequest;
8
9#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
10#[schemars(rename = "cli.command.agents.mcp.servers.list.Request")]
11pub struct Request {
12 pub path_type: Path,
13 pub response_id: String,
14 #[serde(flatten)]
15 pub base: crate::cli::command::RequestBase,
16}
17
18#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
19#[schemars(rename = "cli.command.agents.mcp.servers.list.Path")]
20pub enum Path {
21 #[serde(rename = "agents/mcp/servers/list")]
22 AgentsMcpServersList,
23}
24
25impl CommandRequest for Request {
26 fn request_base(&self) -> &crate::cli::command::RequestBase {
27 &self.base
28 }
29
30 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
31 Some(&mut self.base)
32 }
33}
34
35pub type Response = crate::mcp::server::ListServersResult;
36
37#[derive(clap::Args)]
38#[command(group(clap::ArgGroup::new("response_id_required").required(true).args(["response_id"])))]
39pub struct Args {
40 #[arg(long)]
43 pub response_id: Option<String>,
44 #[command(flatten)]
45 pub base: crate::cli::command::RequestBaseArgs,
46}
47
48#[derive(clap::Args)]
49#[command(args_conflicts_with_subcommands = true)]
50pub struct Command {
51 #[command(flatten)]
52 pub args: Args,
53 #[command(subcommand)]
54 pub schema: Option<Schema>,
55}
56
57#[derive(clap::Subcommand)]
58pub enum Schema {
59 RequestSchema(request_schema::Args),
61 ResponseSchema(response_schema::Args),
63}
64
65impl TryFrom<Args> for Request {
66 type Error = crate::cli::command::FromArgsError;
67 fn try_from(args: Args) -> Result<Self, Self::Error> {
68 let response_id = args.response_id.ok_or_else(|| {
69 crate::cli::command::FromArgsError::path_parse(
70 "response_id",
71 "--response-id is required".to_string(),
72 )
73 })?;
74 Ok(Self {
75 path_type: Path::AgentsMcpServersList,
76 response_id,
77 base: args.base.into(),
78 })
79 }
80}
81
82#[cfg(feature = "cli-executor")]
83pub async fn execute<E: crate::cli::command::CommandExecutor>(
84 executor: &E,
85 mut request: Request,
86 agent_arguments: Option<&crate::cli::command::AgentArguments>,
87) -> Result<Response, E::Error> {
88 request.base.clear_transform();
89 executor.execute_one(request, agent_arguments).await
90}
91
92#[cfg(feature = "cli-executor")]
93pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
94 executor: &E,
95 mut request: Request,
96 transform: crate::cli::command::Transform,
97 agent_arguments: Option<&crate::cli::command::AgentArguments>,
98) -> Result<serde_json::Value, E::Error> {
99 request.base.set_transform(transform);
100 executor.execute_one(request, agent_arguments).await
101}
102
103#[cfg(feature = "mcp")]
104impl crate::cli::command::CommandResponse for Response {
105 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
106 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
107 }
108}
109
110pub mod request_schema;
111
112pub mod response_schema;
113
114#[cfg(feature = "cli-listener")]
119pub struct ListenerExecution {
120 pub request: Request,
121 pub agent_arguments: crate::cli::command::AgentArguments,
122 pub response: crate::cli::websocket_listener::UnaryResponse<Response>,
123}