objectiveai_cli/filesystem/config/
mcp.rs1use serde::{Deserialize, Serialize};
2
3#[derive(
4 Debug, Clone, Default, Serialize, Deserialize, schemars::JsonSchema,
5)]
6#[schemars(rename = "filesystem.config.McpConfig")]
7pub struct McpConfig {
8 #[serde(default, skip_serializing_if = "Option::is_none")]
9 #[schemars(extend("omitempty" = true))]
10 pub address: Option<String>,
11 #[serde(default, skip_serializing_if = "Option::is_none")]
12 #[schemars(extend("omitempty" = true))]
13 pub port: Option<u16>,
14}
15
16impl McpConfig {
17 pub fn is_empty(&self) -> bool {
18 self.address.is_none() && self.port.is_none()
19 }
20
21 pub fn is_none(this: &Option<Self>) -> bool {
22 this.as_ref().is_none_or(|cfg| cfg.is_empty())
23 }
24
25 pub fn get_address(&self) -> Option<&str> {
26 self.address.as_deref()
27 }
28
29 pub fn set_address(&mut self, value: impl Into<String>) {
30 self.address = Some(value.into());
31 }
32
33 pub fn get_port(&self) -> Option<u16> {
34 self.port
35 }
36
37 pub fn set_port(&mut self, value: u16) {
38 self.port = Some(value);
39 }
40
41 pub fn jq(
42 &self,
43 filter: &str,
44 ) -> Result<Vec<serde_json::Value>, super::super::Error> {
45 super::super::run_jq(self, filter)
46 }
47}