list_connections
View all active database connections across PostgreSQL, MySQL, and SQLite databases to monitor current database sessions and manage connection resources.
Instructions
List all active database connections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:48-61 (handler)Handler function for the 'list_connections' tool. Retrieves all database connections using DatabaseConnections.getAllConnections() and returns them as JSON in a text content block.async () => { const connections = databaseConnections.getAllConnections(); return { content: [ { type: "text", text: JSON.stringify({ connections: connections, }), }, ], }; }
- src/index.ts:42-62 (registration)Registration of the 'list_connections' tool on the MCP server, including title, description, and inline handler function.mcpServer.registerTool( "list_connections", { title: "List Connections", description: "List all active database connections", }, async () => { const connections = databaseConnections.getAllConnections(); return { content: [ { type: "text", text: JSON.stringify({ connections: connections, }), }, ], }; } );
- src/connection.ts:102-110 (helper)Helper method in DatabaseConnections class that returns an array of all active connections, including connectionID, dialect, and connectedAt timestamp.public getAllConnections() { return Array.from(this.connections.entries()).map( ([connectionID, conn]) => ({ connectionID, dialect: conn.dialect, connectedAt: conn.connectedAt, }) ); }