listActiveServers
Retrieve all currently running MongoDB-compatible server instances to monitor active database connections and manage server resources.
Instructions
Get a list of all currently running MongoDB-compatible server instances
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/mcp-server.js:983-1010 (handler)The core handler function for the 'listActiveServers' tool. Iterates over the 'this.servers' Map, identifies running servers based on listening status, collects their details, cleans up references to stopped servers, and returns a summary with count and list of active servers.async listActiveServers() { const servers = []; const stoppedServers = []; for (const [port, server] of this.servers) { if (server.server && server.server.listening) { servers.push({ port, status: 'running', connections: server.connections ? server.connections.size : 0 }); } else { // Server is stopped but still in map - mark for cleanup stoppedServers.push(port); } } // Clean up stopped servers from the map for (const port of stoppedServers) { this.logger.debug(`Cleaning up stopped server on port ${port}`); this.servers.delete(port); } return { count: servers.length, servers }; }
- src/mcp/mcp-server.js:91-98 (registration)Tool registration in the 'this.tools' array within MCPServerEnhanced constructor. Defines the tool name, description, and empty input schema. Used by 'tools/list' handler and client initialization.{ name: 'listActiveServers', description: 'List all active MongoDB servers', inputSchema: { type: 'object', properties: {} } },
- src/mcp/index.js:363-376 (handler)Alternative inline handler implementation in the CallToolRequestSchema handler's switch statement. Lists active servers from a global 'servers' Map and returns formatted text response.case 'listActiveServers': const activeServers = Array.from(servers.entries()).map(([port, info]) => ({ port, database: info.database, status: info.status, connections: info.connections })); return { content: [{ type: 'text', text: `Active MongoDB servers:\n${activeServers.map(s => `- Port ${s.port}: ${s.database} (${s.status}, ${s.connections} connections)`).join('\n') || 'No active servers'}` }] };
- src/mcp/index.js:160-167 (registration)Tool registration in the TOOLS constant array used for listing tools in this MCP server implementation.{ name: 'listActiveServers', description: 'Get a list of all currently running MongoDB-compatible server instances', inputSchema: { type: 'object', properties: {} } },
- src/mcp/mcp-server.js:750-752 (helper)Dispatch case in handleToolCall method that invokes the listActiveServers handler.case 'listActiveServers': result = await this.listActiveServers(); break;