git_iris/mcp/
config.rs

1//! Configuration for the MCP server
2
3use serde::{Deserialize, Serialize};
4
5/// Configuration options for the MCP server
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct MCPServerConfig {
8    /// Whether to enable development mode with more verbose logging
9    pub dev_mode: bool,
10    /// The transport type to use (stdio, sse)
11    pub transport: MCPTransportType,
12    /// Port to use for network transports
13    pub port: Option<u16>,
14    /// Listen address for network transports (e.g., "127.0.0.1", "0.0.0.0")
15    pub listen_address: Option<String>,
16}
17
18/// Types of transports supported by the MCP server
19#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
20pub enum MCPTransportType {
21    /// Standard input/output transport
22    StdIO,
23    /// Server-Sent Events transport
24    SSE,
25}
26
27impl Default for MCPServerConfig {
28    fn default() -> Self {
29        Self {
30            dev_mode: false,
31            transport: MCPTransportType::StdIO,
32            port: None,
33            listen_address: None,
34        }
35    }
36}
37
38impl MCPServerConfig {
39    /// Create a new configuration with development mode enabled
40    #[must_use]
41    pub fn with_dev_mode(mut self) -> Self {
42        self.dev_mode = true;
43        self
44    }
45
46    /// Create a new configuration with the specified transport
47    #[must_use]
48    pub fn with_transport(mut self, transport: MCPTransportType) -> Self {
49        self.transport = transport;
50        self
51    }
52
53    /// Create a new configuration with the specified port
54    #[must_use]
55    pub fn with_port(mut self, port: u16) -> Self {
56        self.port = Some(port);
57        self
58    }
59
60    /// Create a new configuration with the specified listen address
61    #[must_use]
62    pub fn with_listen_address(mut self, listen_address: impl Into<String>) -> Self {
63        self.listen_address = Some(listen_address.into());
64        self
65    }
66}