use reqwest::Method;
use serde::{Deserialize, Serialize};
use crate::client::Client;
use crate::error::BoxxkiteError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum McpCatalogId {
Slack,
Notion,
Linear,
Github,
}
#[derive(Debug, Clone, Deserialize)]
pub struct McpConnection {
pub id: String,
pub label: String,
pub catalog_id: String,
pub host: String,
pub created_at: String,
pub last_used_at: Option<String>,
}
impl Client {
pub async fn create_mcp_connection(
&self,
label: &str,
catalog_id: McpCatalogId,
) -> Result<McpConnection, BoxxkiteError> {
#[derive(Serialize)]
struct Body<'a> {
label: &'a str,
catalog_id: McpCatalogId,
}
let body = Body { label, catalog_id };
let builder = self
.request(Method::POST, "/v1/mcp-connections")
.json(&body);
self.send(builder).await
}
pub async fn list_mcp_connections(&self) -> Result<Vec<McpConnection>, BoxxkiteError> {
let builder = self.request(Method::GET, "/v1/mcp-connections");
self.send_or_default(builder).await
}
pub async fn delete_mcp_connection(&self, connection_id: &str) -> Result<(), BoxxkiteError> {
let builder = self.request(
Method::DELETE,
&format!("/v1/mcp-connections/{connection_id}"),
);
self.send_no_content(builder).await
}
}