Skip to main content
Glama
yaoxiaolinglong

MCP-MongoDB-MySQL-Server

mongodb_delete

Delete documents from a MongoDB collection using query filters to remove specific data entries through the MCP-MongoDB-MySQL-Server interface.

Instructions

Delete documents from a MongoDB collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
filterYesMongoDB query filter
manyNoDelete multiple documents if true

Implementation Reference

  • The handler function that executes the mongodb_delete tool. It ensures MongoDB connection, validates inputs, and performs deleteOne or deleteMany based on the 'many' parameter.
    private async handleMongoDBDelete(args: any) {
      await this.ensureMongoConnection();
    
      if (!args.collection || !args.filter) {
        throw new McpError(ErrorCode.InvalidParams, 'Collection name and filter are required');
      }
    
      try {
        const collection = this.mongoDB!.collection(args.collection);
        let result;
        
        if (args.many) {
          result = await collection.deleteMany(args.filter);
        } else {
          result = await collection.deleteOne(args.filter);
        }
        
        return {
          content: [
            {
              type: 'text',
              text: `Successfully deleted ${result.deletedCount} documents`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to delete documents: ${getErrorMessage(error)}`
        );
      }
    }
  • The input schema definition for the mongodb_delete tool, specifying required collection and filter, optional many flag.
    {
      name: 'mongodb_delete',
      description: 'Delete documents from a MongoDB collection',
      inputSchema: {
        type: 'object',
        properties: {
          collection: {
            type: 'string',
            description: 'Collection name',
          },
          filter: {
            type: 'object',
            description: 'MongoDB query filter',
          },
          many: {
            type: 'boolean',
            description: 'Delete multiple documents if true',
            optional: true
          }
        },
        required: ['collection', 'filter'],
      },
    },
  • src/index.ts:562-563 (registration)
    The switch case in the request handler that registers and dispatches calls to the mongodb_delete tool to its handler.
    case 'mongodb_delete':
      return await this.handleMongoDBDelete(request.params.arguments);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool deletes documents, implying a destructive mutation, but doesn't cover critical aspects like permissions required, whether deletions are permanent or reversible, rate limits, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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 waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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?

Given the complexity of a destructive database operation with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., safety, permissions), output format, or error handling, which are crucial for an agent to use this tool correctly in context.

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%, with clear descriptions for all parameters (collection, filter, many). The description doesn't add any meaning beyond what the schema provides (e.g., it doesn't explain filter syntax or 'many' implications), so it meets the baseline of 3 where the schema does the heavy lifting.

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 ('Delete documents') and resource ('from a MongoDB collection'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'mongodb_update' or 'execute' which might also modify data, leaving room for improvement in 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 Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a connection first), exclusions, or comparisons to siblings like 'mongodb_update' for modifications or 'execute' for general queries, leaving the agent with no usage context.

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/yaoxiaolinglong/mcp-mongodb-mysql-server'

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