Skip to main content
Glama
bpamiri
by bpamiri

disconnect

Close all active connections to the SQL Server database and return the disconnection status with count of closed connections.

Instructions

Close all connections to the SQL Server database.

Returns: Disconnection status and count of closed connections.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'disconnect' MCP tool, decorated with @mcp.tool(). It calls ConnectionManager.disconnect_all() via the global manager and returns a status dict with the number of closed connections.
    @mcp.tool() def disconnect() -> dict[str, Any]: """Close all connections to the SQL Server database. Returns: Disconnection status and count of closed connections. """ try: manager = get_connection_manager() closed = manager.disconnect_all() return { "status": "disconnected", "connections_closed": closed, } except Exception as e: logger.error(f"Error during disconnect: {e}") return {"status": "error", "error": str(e)}
  • The @mcp.tool() decorator registers the disconnect function as an MCP tool.
    @mcp.tool()
  • ConnectionManager.disconnect_all() method, invoked by the tool handler. Closes all tracked connections by calling self.disconnect() on each and returns the count.
    def disconnect_all(self) -> int: """Close all connections. Returns: Count of closed connections """ names = list(self._connections.keys()) count = 0 for name in names: if self.disconnect(name): count += 1 return count
  • Core ConnectionManager.disconnect() method that closes the pymssql.Connection and removes it from tracking.
    def disconnect(self, name: str = "default") -> bool: """Close a named connection. Args: name: Name of the connection to close Returns: True if connection was closed, False if not found """ if name not in self._connections: return False try: if self._connection: self._connection.close() self._connection = None self._connections[name].is_active = False del self._connections[name] logger.info(f"Disconnected connection '{name}'") return True except pymssql.Error as e: logger.warning(f"Error during disconnect: {e}") return False

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bpamiri/pymssql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server