Skip to main content

mcp_utils/
status.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
4pub enum McpServerStatus {
5    Connecting,
6    Connected { tool_count: usize },
7    Authenticating,
8    Failed { error: String },
9    NeedsOAuth,
10}
11
12#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
13pub enum McpServerAuthCapability {
14    #[default]
15    Unavailable,
16    OAuth,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
20pub struct McpServerStatusEntry {
21    pub name: String,
22    pub status: McpServerStatus,
23    pub auth_capability: McpServerAuthCapability,
24    #[serde(default)]
25    pub proxied: bool,
26}
27
28impl McpServerStatusEntry {
29    pub fn new(name: impl Into<String>, status: McpServerStatus) -> Self {
30        Self { name: name.into(), status, auth_capability: McpServerAuthCapability::Unavailable, proxied: false }
31    }
32
33    pub fn with_auth_capability(mut self, auth: McpServerAuthCapability) -> Self {
34        self.auth_capability = auth;
35        self
36    }
37
38    pub fn with_proxied(mut self, proxied: bool) -> Self {
39        self.proxied = proxied;
40        self
41    }
42
43    pub fn can_authenticate(&self) -> bool {
44        self.auth_capability == McpServerAuthCapability::OAuth
45    }
46}