Skip to main content
Glama

stopMongoServer

Stop a running MongoDB-compatible server instance by specifying its port number to manage database resources effectively.

Instructions

Stop a running MongoDB-compatible server instance by port number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYesPort of the server to stop

Implementation Reference

  • Handler implementation in the main MCP server entry point. Retrieves server from global 'servers' Map by port, calls stop(), deletes entry, returns success response.
    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 registration in TOOLS array used for tools/list response, including name, description, and input schema requiring 'port'.
    {
      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']
      }
    },
  • Class method handler in MCPServerEnhanced class. Stops server instance from this.servers Map, includes verification and error handling.
    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`
        };
    }
  • Input schema definition in this.tools array for the stopMongoServer tool.
    {
        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 case in handleToolCall switch statement that invokes the stopMongoServer handler.
    case 'stopMongoServer':
        result = await this.stopMongoServer(args);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It states the destructive action ('Stop') but doesn't disclose important behavioral traits: whether this requires specific permissions, if the stop is graceful or forceful, what happens to connected clients, or if there are confirmation prompts. The description is minimal beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable. Every word earns its place in conveying the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive operation with no annotations and no output schema, the description is insufficient. It doesn't cover important context: what permissions are needed, whether the operation is reversible (can it be restarted?), what happens to data during shutdown, or what the response looks like. The minimal description leaves critical gaps for a server control tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the single parameter 'port' is fully documented in the schema). The description adds marginal value by reinforcing that stopping is 'by port number', but doesn't provide additional semantic context beyond what the schema already states about the port parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Stop') and resource ('a running MongoDB-compatible server instance'), with the specific mechanism 'by port number'. It distinguishes from siblings like 'startMongoServer' by the opposite action, but doesn't explicitly mention sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through 'running' (only stop what's already running) and 'by port number' (identify target). However, it doesn't provide explicit guidance on when to use this vs alternatives like 'listActiveServers' first, or mention prerequisites like needing admin permissions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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