Skip to main content

objectiveai_cli/command/api/config/mcp_timeout_ms/
set.rs

1//! `config api mcp-timeout-ms set` — write `api.mcp_timeout_ms` to on-disk config.
2//!
3//! The value is a millisecond integer; we parse it to a `u64` here (so a
4//! non-numeric value fails the `set` with a clear error rather than
5//! landing on disk) before persisting it.
6
7use objectiveai_sdk::cli::command::api::config::mcp_timeout_ms::set::{Request, Response};
8
9use crate::context::Context;
10use crate::error::Error;
11
12pub async fn execute(ctx: &Context, request: Request) -> Result<Response, Error> {
13    let timeout_ms: u64 = {
14        let mut de = serde_json::Deserializer::from_str(&request.value);
15        serde_path_to_error::deserialize(&mut de).map_err(Error::InlineDeserialize)?
16    };
17    let mut config = ctx.filesystem.read_config_at(request.scope).await?;
18    config.api().set_mcp_timeout_ms(timeout_ms);
19    ctx.filesystem.write_config_at(request.scope, &config).await?;
20    Ok(Response::Ok)
21}
22
23pub mod request_schema {
24    use objectiveai_sdk::cli::command::api::config::mcp_timeout_ms::set as sdk;
25    use objectiveai_sdk::cli::command::api::config::mcp_timeout_ms::set::request_schema::{Request, Response};
26
27    use crate::context::Context;
28    use crate::error::Error;
29
30    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
31        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Request)))
32    }
33}
34
35pub mod response_schema {
36    use objectiveai_sdk::cli::command::api::config::mcp_timeout_ms::set as sdk;
37    use objectiveai_sdk::cli::command::api::config::mcp_timeout_ms::set::response_schema::{Request, Response};
38
39    use crate::context::Context;
40    use crate::error::Error;
41
42    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
43        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Response)))
44    }
45}