MCPcopy Create free account
hub / github.com/IBM/mcp-cli / ServerInfo

Class ServerInfo

src/mcp_cli/tools/models.py:190–242  ·  view source on GitHub ↗

Information about a connected server instance.

Source from the content-addressed store, hash-verified

188
189
190class ServerInfo(BaseModel):
191 """Information about a connected server instance."""
192
193 id: int
194 name: str
195 status: str
196 tool_count: int
197 namespace: str
198 enabled: bool = True
199 connected: bool = False
200 transport: TransportType = TransportType.STDIO
201 capabilities: dict[str, Any] = Field(default_factory=dict)
202 description: str | None = None # From server metadata
203 version: str | None = None # Server version
204 command: str | None = None # Server command if known (for stdio)
205 url: str | None = None # Server URL (for http/sse)
206 args: list[str] = Field(default_factory=list) # Command arguments
207 env: dict[str, str] = Field(default_factory=dict) # Environment variables
208
209 model_config = {"frozen": False, "arbitrary_types_allowed": True}
210
211 @property
212 def is_healthy(self) -> bool:
213 """Check if server is healthy and ready."""
214 return self.status == "healthy" and self.connected
215
216 @property
217 def display_status(self) -> str:
218 """Get a user-friendly status string."""
219 if not self.enabled:
220 return "disabled"
221 elif not self.connected:
222 return "disconnected"
223 else:
224 return self.status
225
226 @property
227 def display_description(self) -> str:
228 """Get description or a default based on name."""
229 # Use server-provided description if available
230 if self.description:
231 return self.description
232 # Otherwise just return a generic description
233 return f"{self.name} MCP server"
234
235 @property
236 def has_tools(self) -> bool:
237 """Check if server has any tools."""
238 return self.tool_count > 0
239
240 def get_capabilities_typed(self) -> ServerCapabilities:
241 """Get capabilities as typed ServerCapabilities object."""
242 return ServerCapabilities.from_dict(self.capabilities)
243
244
245class ToolCallResult(BaseModel):

Calls

no outgoing calls