Skip to main content

objectiveai_sdk/cli/command/development/plugins/mcp/list/
mod.rs

1//! `development plugins mcp list` — every plugin currently registered
2//! for development, and the directory each builds from.
3//!
4//! Streaming, one item per registration. Empty output is the normal
5//! state: nothing is registered until someone runs `create`, and
6//! registrations do not survive a daemon restart.
7
8use 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/// One registration: the canonical coordinates an agent's declaration
36/// is matched against, and the directory its image builds from.
37#[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    /// Emit the JSON Schema for this leaf's `Request` type and exit.
64    RequestSchema(request_schema::Args),
65    /// Emit the JSON Schema for this leaf's `ResponseItem` type and exit.
66    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/// One `/listen` broadcast run of `development plugins mcp list`. See
112/// [`crate::daemon::command_listener`].
113#[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}