objectiveai_cli/command/agents/mcp/tools/
list.rs1use objectiveai_sdk::cli::command::agents::mcp::tools::list::{Request, Response};
7
8use crate::context::Context;
9use crate::error::Error;
10use crate::websockets::mcp_listener::{SocketRequest, SocketResponse, call_socket};
11
12pub async fn execute(ctx: &Context, request: Request) -> Result<Response, Error> {
13 let state_dir = ctx.filesystem.state_dir();
14 let socket_request = SocketRequest::ListTools {
15 params: request.params,
16 name: request.name,
17 };
18 let response: SocketResponse<Response> =
19 call_socket(&state_dir, &request.response_id, &socket_request)
20 .await
21 .map_err(|e| Error::Instance(format!("mcp socket: {e}")))?;
22 match response {
23 SocketResponse::Ok(result) => Ok(result),
24 SocketResponse::Err(e) => {
25 Err(Error::Instance(format!("mcp error {}: {}", e.code, e.message)))
26 }
27 }
28}
29
30pub mod request_schema {
31 use objectiveai_sdk::cli::command::agents::mcp::tools::list as sdk;
32 use objectiveai_sdk::cli::command::agents::mcp::tools::list::request_schema::{
33 Request, Response,
34 };
35
36 use crate::context::Context;
37 use crate::error::Error;
38
39 pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
40 Ok(objectiveai_sdk::cli::command::ResponseSchema(
41 schemars::schema_for!(sdk::Request),
42 ))
43 }
44}
45
46pub mod response_schema {
47 use objectiveai_sdk::cli::command::agents::mcp::tools::list as sdk;
48 use objectiveai_sdk::cli::command::agents::mcp::tools::list::response_schema::{
49 Request, Response,
50 };
51
52 use crate::context::Context;
53 use crate::error::Error;
54
55 pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
56 Ok(objectiveai_sdk::cli::command::ResponseSchema(
57 schemars::schema_for!(sdk::Response),
58 ))
59 }
60}