Skip to main content
Glama

stopMongoServer

Stop a running MongoDB-compatible server instance by specifying its port number to terminate database operations and free up system resources.

Instructions

Stop a running MongoDB-compatible server instance by port number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYesPort of the server to stop

Implementation Reference

  • Primary handler implementation that stops the MongoDB server instance by retrieving it from the internal servers map, calling its stop() method with error handling and cleanup.
    async stopMongoServer(args) { const { port } = args; const server = this.servers.get(port); if (!server) { throw new Error(`No server running on port ${port}`); } try { // Stop the server and wait for it to fully close await server.stop(); // Verify the server is actually stopped const isListening = server.server && server.server.listening; if (isListening) { this.logger.warn(`Server on port ${port} may not have stopped completely`); } } catch (error) { this.logger.error(`Error stopping server on port ${port}:`, error); throw error; } finally { // Always remove from map, even if stop failed this.servers.delete(port); } return { success: true, message: `Server on port ${port} stopped` }; }
  • Tool schema definition including name, description, and inputSchema requiring the 'port' integer parameter.
    { name: 'stopMongoServer', description: 'Stop a running MongoDB server', inputSchema: { type: 'object', properties: { port: { type: 'integer', description: 'Port of the server to stop' } }, required: ['port'] } },
  • Dispatch/registration case in the handleToolCall switch statement that invokes the stopMongoServer handler.
    case 'stopMongoServer': result = await this.stopMongoServer(args); break;
  • Secondary handler implementation in the SDK-based MCP server entry point, simpler version stopping the server by port.
    case 'stopMongoServer': const targetPort = args.port; const serverInfo = servers.get(targetPort); if (!serverInfo) { throw new Error(`No server running on port ${targetPort}`); } await serverInfo.server.stop(); servers.delete(targetPort); return { content: [{ type: 'text', text: `MongoDB server on port ${targetPort} stopped successfully.` }] };
  • Tool schema in the TOOLS array for the SDK-based server implementation.
    { name: 'stopMongoServer', description: 'Stop a running MongoDB-compatible server instance by port number', inputSchema: { type: 'object', properties: { port: { type: 'integer', description: 'Port of the server to stop' } }, required: ['port'] } },

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