Skip to main content
Glama
yaoxiaolinglong

MCP-MongoDB-MySQL-Server

mongodb_create_collection

Create a new collection in MongoDB to organize and store data, enabling structured database management through the MCP server interface.

Instructions

Create a new collection in MongoDB

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
optionsNoCollection options

Implementation Reference

  • The handler function that executes the tool logic: ensures MongoDB connection, validates collection name, creates the collection with optional options, returns success message or throws appropriate MCP error.
    private async handleMongoDBCreateCollection(args: any) {
      await this.ensureMongoConnection();
    
      if (!args.collection) {
        throw new McpError(ErrorCode.InvalidParams, 'Collection name is required');
      }
    
      try {
        await this.mongoDB!.createCollection(args.collection, args.options || {});
        return {
          content: [
            {
              type: 'text',
              text: `Collection ${args.collection} created successfully`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to create collection: ${getErrorMessage(error)}`
        );
      }
    }
  • src/index.ts:513-531 (registration)
    Tool registration in the listTools response, defining the tool name, description, and input schema for validation.
    {
      name: 'mongodb_create_collection',
      description: 'Create a new collection in MongoDB',
      inputSchema: {
        type: 'object',
        properties: {
          collection: {
            type: 'string',
            description: 'Collection name',
          },
          options: {
            type: 'object',
            description: 'Collection options',
            optional: true
          }
        },
        required: ['collection'],
      },
    }
  • src/index.ts:564-565 (registration)
    Switch case in callTool handler that routes requests for this tool to the specific handler method.
    case 'mongodb_create_collection':
      return await this.handleMongoDBCreateCollection(request.params.arguments);
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states it creates a collection but doesn't disclose permissions needed, whether it overwrites existing collections, error conditions, or typical response format. For a mutation tool with zero annotation coverage, this is inadequate.

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's front-loaded with the core action and resource, making it easy 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?

For a mutation tool with no annotations, no output schema, and complex nested parameters (the 'options' object), the description is incomplete. It doesn't explain what 'options' might include, potential side effects, or what success/failure looks like, leaving significant gaps for an AI agent.

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%, so the schema already documents both parameters ('collection' and 'options'). The description adds no additional meaning beyond implying the tool creates something, which is obvious from the name. Baseline 3 is appropriate when 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 ('Create') and resource ('new collection in MongoDB'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create_table' or 'mongodb_list_collections', which would require mentioning it's specifically for MongoDB collections rather than general database tables.

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 an established MongoDB connection via 'connect_mongodb'), nor does it clarify when to choose this over similar tools like 'create_table' for relational databases.

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