listActiveServers
Retrieve a list of 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)Primary implementation of listActiveServers tool handler. Lists running MongoDB servers, reports port, status, and connection count. Automatically cleans up entries for stopped servers from the internal map and returns structured data with count and server list.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:92-98 (schema)Tool schema definition in the tools array, defining name, description, and empty input schema (no parameters required). Used for tools/list response.name: 'listActiveServers', description: 'List all active MongoDB servers', inputSchema: { type: 'object', properties: {} } },
- src/mcp/mcp-server.js:750-752 (registration)Registration and dispatch in handleToolCall switch statement that calls the listActiveServers handler when the tool is invoked via tools/call.case 'listActiveServers': result = await this.listActiveServers(); break;
- src/mcp/index.js:363-377 (handler)Alternative inline handler implementation in index.js that lists active servers and returns a formatted text response instead of structured JSON.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:161-167 (schema)Tool schema definition in index.js TOOLS constant.name: 'listActiveServers', description: 'Get a list of all currently running MongoDB-compatible server instances', inputSchema: { type: 'object', properties: {} } },