Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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 }; }
  • 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: {} } },
  • 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'}` }] };
  • 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: {} } },
  • Dispatch case in handleToolCall method that invokes the listActiveServers handler.
    case 'listActiveServers': result = await this.listActiveServers(); break;

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/smallmindsco/MongTap'

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