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 #[serde(default, skip_serializing_if = "Option::is_none")]
17 #[schemars(extend("omitempty" = true))]
18 pub response_id: Option<String>,
19 #[serde(flatten)]
20 pub base: crate::cli::command::RequestBase,
21}
22
23#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
24#[schemars(rename = "cli.command.agents.mcp.servers.list.Path")]
25pub enum Path {
26 #[serde(rename = "agents/mcp/servers/list")]
27 AgentsMcpServersList,
28}
29
30impl CommandRequest for Request {
31 fn request_base(&self) -> &crate::cli::command::RequestBase {
32 &self.base
33 }
34
35 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
36 Some(&mut self.base)
37 }
38}
39
40pub type Response = crate::mcp::server::ListServersResult;
41
42#[derive(clap::Args)]
43pub struct Args {
44 #[arg(long)]
49 pub response_id: Option<String>,
50 #[command(flatten)]
51 pub base: crate::cli::command::RequestBaseArgs,
52}
53
54#[derive(clap::Args)]
55#[command(args_conflicts_with_subcommands = true)]
56pub struct Command {
57 #[command(flatten)]
58 pub args: Args,
59 #[command(subcommand)]
60 pub schema: Option<Schema>,
61}
62
63#[derive(clap::Subcommand)]
64pub enum Schema {
65 RequestSchema(request_schema::Args),
67 ResponseSchema(response_schema::Args),
69}
70
71impl TryFrom<Args> for Request {
72 type Error = crate::cli::command::FromArgsError;
73 fn try_from(args: Args) -> Result<Self, Self::Error> {
74 Ok(Self {
75 path_type: Path::AgentsMcpServersList,
76 response_id: args.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::broadcast_listener::UnaryResponse<Response>,
123}