objectiveai_sdk/cli/command/agents/mcp/resources/list/
mod.rs1use crate::cli::command::CommandRequest;
7
8#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
9#[schemars(rename = "cli.command.agents.mcp.resources.list.Request")]
10pub struct Request {
11 pub path_type: Path,
12 #[serde(default, skip_serializing_if = "Option::is_none")]
16 #[schemars(extend("omitempty" = true))]
17 pub response_id: Option<String>,
18 pub params: crate::mcp::resource::ListResourcesRequest,
19 #[serde(default, skip_serializing_if = "Option::is_none")]
23 #[schemars(extend("omitempty" = true))]
24 pub name: Option<String>,
25 #[serde(flatten)]
26 pub base: crate::cli::command::RequestBase,
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
30#[schemars(rename = "cli.command.agents.mcp.resources.list.Path")]
31pub enum Path {
32 #[serde(rename = "agents/mcp/resources/list")]
33 AgentsMcpResourcesList,
34}
35
36impl CommandRequest for Request {
37 fn request_base(&self) -> &crate::cli::command::RequestBase {
38 &self.base
39 }
40
41 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
42 Some(&mut self.base)
43 }
44}
45
46pub type Response = crate::mcp::resource::ListResourcesResult;
47
48#[derive(clap::Args)]
49#[command(group(clap::ArgGroup::new("params_required").required(true).args(["params"])))]
50pub struct Args {
51 #[arg(long)]
56 pub response_id: Option<String>,
57 #[arg(long)]
60 pub params: Option<String>,
61 #[arg(long)]
64 pub name: Option<String>,
65 #[command(flatten)]
66 pub base: crate::cli::command::RequestBaseArgs,
67}
68
69#[derive(clap::Args)]
70#[command(args_conflicts_with_subcommands = true)]
71pub struct Command {
72 #[command(flatten)]
73 pub args: Args,
74 #[command(subcommand)]
75 pub schema: Option<Schema>,
76}
77
78#[derive(clap::Subcommand)]
79pub enum Schema {
80 RequestSchema(request_schema::Args),
82 ResponseSchema(response_schema::Args),
84}
85
86impl TryFrom<Args> for Request {
87 type Error = crate::cli::command::FromArgsError;
88 fn try_from(args: Args) -> Result<Self, Self::Error> {
89 let params = {
90 let s = args.params.ok_or_else(|| {
91 crate::cli::command::FromArgsError::path_parse(
92 "params",
93 "--params is required".to_string(),
94 )
95 })?;
96 let mut de = serde_json::Deserializer::from_str(&s);
97 serde_path_to_error::deserialize(&mut de)
98 .map_err(|source| crate::cli::command::FromArgsError {
99 field: "params",
100 source: source.into(),
101 })?
102 };
103 Ok(Self {
104 path_type: Path::AgentsMcpResourcesList,
105 response_id: args.response_id,
106 params,
107 name: args.name,
108 base: args.base.into(),
109 })
110 }
111}
112
113#[cfg(feature = "cli-executor")]
114pub async fn execute<E: crate::cli::command::CommandExecutor>(
115 executor: &E,
116 mut request: Request,
117 agent_arguments: Option<&crate::cli::command::AgentArguments>,
118) -> Result<Response, E::Error> {
119 request.base.clear_transform();
120 executor.execute_one(request, agent_arguments).await
121}
122
123#[cfg(feature = "cli-executor")]
124pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
125 executor: &E,
126 mut request: Request,
127 transform: crate::cli::command::Transform,
128 agent_arguments: Option<&crate::cli::command::AgentArguments>,
129) -> Result<serde_json::Value, E::Error> {
130 request.base.set_transform(transform);
131 executor.execute_one(request, agent_arguments).await
132}
133
134#[cfg(feature = "mcp")]
135impl crate::cli::command::CommandResponse for Response {
136 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
137 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
138 }
139}
140
141pub mod request_schema;
142
143pub mod response_schema;
144
145#[cfg(feature = "cli-listener")]
150pub struct ListenerExecution {
151 pub request: Request,
152 pub agent_arguments: crate::cli::command::AgentArguments,
153 pub response: crate::cli::broadcast_listener::UnaryResponse<Response>,
154}