disconnect
Terminate the active connection to a CockroachDB cluster to end database sessions and release resources.
Instructions
Disconnect from the CockroachDB cluster.
Returns:
Disconnection status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cockroachdb_mcp/server.py:39-47 (handler)MCP tool handler for 'disconnect'. Decorated with @mcp.tool(), registers the tool and executes by delegating to connection_manager.disconnect().@mcp.tool() async def disconnect() -> dict[str, Any]: """Disconnect from the CockroachDB cluster. Returns: Disconnection status. """ return await connection_manager.disconnect()
- Core implementation of disconnect in ConnectionManager class. Closes the AsyncConnection and resets the connection state.async def disconnect(self) -> dict[str, Any]: """Disconnect from CockroachDB cluster. Returns: Disconnection status. """ async with self._lock: if self._state.connection is None: return {"status": "not_connected"} try: await self._state.connection.close() except Exception: pass # Ignore errors on close database = self._state.database self._state = ConnectionState() return { "status": "disconnected", "database": database, }