list_connections
View active database connections in SQL Server to monitor usage, identify sessions, and manage resources effectively.
Instructions
List all active database connections.
Returns:
List of active connections with their details (name, host, database,
connection time, and active status).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mssql_mcp/server.py:169-195 (handler)The MCP tool handler and registration for 'list_connections'. It fetches the connection manager and returns formatted list of active connections.@mcp.tool() def list_connections() -> dict[str, Any]: """List all active database connections. Returns: List of active connections with their details (name, host, database, connection time, and active status). """ try: manager = get_connection_manager() connections = manager.list_connections() return { "connections": [ { "name": info.name, "host": info.host, "database": info.database, "connected_at": info.connected_at.isoformat(), "is_active": info.is_active, } for info in connections.values() ] } except Exception as e: logger.error(f"Error listing connections: {e}") return {"status": "error", "error": str(e)}
- src/mssql_mcp/connection.py:144-146 (helper)Helper method in ConnectionManager class that filters and returns active connections dictionary.def list_connections(self) -> dict[str, ConnectionInfo]: """Return all active connections.""" return {k: v for k, v in self._connections.items() if v.is_active}