MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/optillm / ServerConfig

Class ServerConfig

optillm/plugins/mcp_plugin.py:119–162  ·  view source on GitHub ↗

Configuration for a single MCP server

Source from the content-addressed store, hash-verified

117
118@dataclass
119class ServerConfig:
120 """Configuration for a single MCP server"""
121 # Transport type: "stdio" (default), "sse", or "websocket"
122 transport: str = "stdio"
123
124 # For stdio transport
125 command: Optional[str] = None
126 args: List[str] = None
127
128 # For remote transports (SSE/WebSocket)
129 url: Optional[str] = None
130 headers: Dict[str, str] = None
131
132 # Common fields
133 env: Dict[str, str] = None
134 description: Optional[str] = None
135
136 # Timeout settings
137 timeout: float = 5.0
138 sse_read_timeout: float = 300.0
139
140 def __post_init__(self):
141 """Initialize default values for mutable fields"""
142 if self.args is None:
143 self.args = []
144 if self.headers is None:
145 self.headers = {}
146 if self.env is None:
147 self.env = {}
148
149 @classmethod
150 def from_dict(cls, config: Dict[str, Any]) -> 'ServerConfig':
151 """Create ServerConfig from a dictionary"""
152 return cls(
153 transport=config.get("transport", "stdio"),
154 command=config.get("command"),
155 args=config.get("args", []),
156 url=config.get("url"),
157 headers=config.get("headers", {}),
158 env=config.get("env", {}),
159 description=config.get("description"),
160 timeout=config.get("timeout", 5.0),
161 sse_read_timeout=config.get("sse_read_timeout", 300.0)
162 )
163
164class MCPConfigManager:
165 """Manages MCP configuration loading and validation"""

Calls

no outgoing calls