objectiveai_sdk/cli/command/development/plugins/mcp/list/
mod.rs1use crate::cli::command::CommandRequest;
9
10#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
11#[schemars(rename = "cli.command.development.plugins.mcp.list.Request")]
12pub struct Request {
13 pub path_type: Path,
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.development.plugins.mcp.list.Path")]
20pub enum Path {
21 #[serde(rename = "development/plugins/mcp/list")]
22 DevelopmentPluginsMcpList,
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
35#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
38#[schemars(rename = "cli.command.development.plugins.mcp.list.ResponseItem")]
39pub struct ResponseItem {
40 pub owner: String,
41 pub name: String,
42 pub version: String,
43 pub path: String,
44}
45
46#[derive(clap::Args)]
47pub struct Args {
48 #[command(flatten)]
49 pub base: crate::cli::command::RequestBaseArgs,
50}
51
52#[derive(clap::Args)]
53#[command(args_conflicts_with_subcommands = true)]
54pub struct Command {
55 #[command(flatten)]
56 pub args: Args,
57 #[command(subcommand)]
58 pub schema: Option<Schema>,
59}
60
61#[derive(clap::Subcommand)]
62pub enum Schema {
63 RequestSchema(request_schema::Args),
65 ResponseSchema(response_schema::Args),
67}
68
69impl TryFrom<Args> for Request {
70 type Error = crate::cli::command::FromArgsError;
71 fn try_from(args: Args) -> Result<Self, Self::Error> {
72 Ok(Self {
73 path_type: Path::DevelopmentPluginsMcpList,
74 base: args.base.into(),
75 })
76 }
77}
78
79#[cfg(feature = "mcp")]
80impl crate::cli::command::CommandResponse for ResponseItem {
81 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
82 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
83 }
84}
85
86#[cfg(feature = "cli-executor")]
87pub async fn execute<E: crate::cli::command::CommandExecutor>(
88 executor: &E,
89 mut request: Request,
90 identity: Option<&crate::identity::Identity>,
91) -> Result<E::Stream<ResponseItem>, E::Error> {
92 request.base.clear_transform();
93 executor.execute(request, identity).await
94}
95
96#[cfg(feature = "cli-executor")]
97pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
98 executor: &E,
99 mut request: Request,
100 transform: crate::cli::command::Transform,
101 identity: Option<&crate::identity::Identity>,
102) -> Result<E::Stream<serde_json::Value>, E::Error> {
103 request.base.set_transform(transform);
104 executor.execute(request, identity).await
105}
106
107pub mod request_schema;
108
109pub mod response_schema;
110
111#[cfg(all(feature = "cli", feature = "daemon"))]
114pub struct ListenerExecution {
115 pub request: Request,
116 pub identity: crate::identity::Identity,
117 pub response: crate::daemon::command_listener::ResponseItemStream<ResponseItem>,
118}