Skip to main content
Glama
officialpraise

MongoDB MCP Server

create-collection

Create a new MongoDB collection in a specified database. Automatically creates the database if it doesn't exist.

Instructions

Creates a new collection in a database. If the database doesn't exist, it will be created automatically.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesDatabase name
collectionYesCollection name

Implementation Reference

  • The execute method implements the core logic of the 'create-collection' tool, connecting to MongoDB if necessary and calling createCollection on the provider.
    protected async execute({ collection, database }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
        const provider = await this.ensureConnected();
        await provider.createCollection(database, collection);
    
        return {
            content: [
                {
                    type: "text",
                    text: `Collection "${collection}" created in database "${database}".`,
                },
            ],
        };
    }
  • Zod schema defining the required input parameters (database and collection) for the create-collection tool, referenced via argsShape.
    export const DbOperationArgs = {
        database: z.string().describe("Database name"),
        collection: z.string().describe("Collection name"),
    };
  • Includes CreateCollectionTool in the MongoDbTools export array, enabling its instantiation and registration in the MCP server via server.ts.
    CreateCollectionTool,
  • src/server.ts:142-144 (registration)
    Instantiates each tool from MongoDbTools (including create-collection) and calls its register method on the MCP server.
    for (const tool of [...AtlasTools, ...MongoDbTools]) {
        new tool(this.session, this.userConfig, this.telemetry).register(this.mcpServer);
    }
  • Declares the tool name as 'create-collection', used during registration for MCP tool listing.
    protected name = "create-collection";
Behavior3/5

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

Annotations indicate readOnlyHint=false and destructiveHint=false, covering the safety profile. The description adds value by disclosing the automatic database creation behavior, which is a key trait not covered by annotations. It doesn't detail other behaviors like error handling or permissions, but with annotations present, this is adequate.

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 two sentences, front-loaded with the main action and followed by a critical behavioral detail. Every word contributes essential information without redundancy, making it highly efficient and well-structured.

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

Completeness4/5

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

Given the tool's moderate complexity (creation with side effects), no output schema, and rich annotations, the description is mostly complete. It covers the core action and a key behavioral trait, but could benefit from mentioning potential outcomes or errors, though annotations help mitigate this gap.

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 both parameters ('database' and 'collection') well-documented in the schema. The description doesn't add any additional meaning or examples beyond what the schema provides, such as format constraints or naming rules, so it meets the baseline for high coverage.

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

Purpose5/5

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

The description clearly states the action ('Creates a new collection') and resource ('in a database'), distinguishing it from siblings like 'list-collections' or 'drop-collection'. It specifies the scope of creation, making the purpose explicit and distinct.

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

Usage Guidelines4/5

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

The description provides clear context for usage by mentioning automatic database creation if it doesn't exist, which is useful guidance. However, it doesn't explicitly state when to use this tool versus alternatives like 'insert-many' or 'rename-collection', or any prerequisites beyond the parameters.

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/officialpraise/mcp'

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