Skip to main content
Glama
TrueOleg

MCP Mac Apps Server

by TrueOleg

mongodb_create_collection

Create a new collection in a specified MongoDB database to organize and store data for your application.

Instructions

Создает новую коллекцию в указанной базе данных

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNameYesИмя базы данных
collectionNameYesИмя коллекции

Implementation Reference

  • The handler function that implements the core logic for the 'mongodb_create_collection' tool. It connects to MongoDB, creates the specified collection in the given database, and returns a success message or throws an error.
    private async mongodbCreateCollection(
      databaseName: string,
      collectionName: string
    ) {
      const client = await this.getMongoClient();
      try {
        const db = client.db(databaseName);
        await db.createCollection(collectionName);
        return {
          content: [
            {
              type: "text",
              text: `Коллекция "${collectionName}" успешно создана в базе данных "${databaseName}"`,
            },
          ],
        };
      } catch (error) {
        throw new Error(
          `Ошибка создания коллекции: ${error instanceof Error ? error.message : String(error)}`
        );
      } finally {
        await client.close();
      }
  • The handler function that implements the core logic for the 'mongodb_create_collection' tool. It connects to MongoDB, creates the specified collection, and returns a success message.
    def mongodb_create_collection(database_name: str, collection_name: str) -> str:
        """Creates collection in database"""
        client = MongoClient(MONGODB_URI)
        try:
            db = client[database_name]
            db.create_collection(collection_name)
            return (
                f'Collection "{collection_name}" successfully created '
                f'in database "{database_name}"'
            )
        except Exception as e:
            raise Exception(f"Error creating collection: {str(e)}")
        finally:
            client.close()
  • The input schema definition for the 'mongodb_create_collection' tool, used in tools/list response for registration.
    name: "mongodb_create_collection",
    description: "Создает новую коллекцию в указанной базе данных",
    inputSchema: {
      type: "object",
      properties: {
        databaseName: {
          type: "string",
          description: "Имя базы данных",
        },
        collectionName: {
          type: "string",
          description: "Имя коллекции",
        },
      },
      required: ["databaseName", "collectionName"],
    },
  • The input schema definition for the 'mongodb_create_collection' tool, returned in the tools/list endpoint.
        "name": "mongodb_create_collection",
        "description": "Creates new collection in specified database",
        "inputSchema": {
            "type": "object",
            "properties": {
                "databaseName": {
                    "type": "string",
                    "description": "Database name",
                },
                "collectionName": {
                    "type": "string",
                    "description": "Collection name",
                },
            },
            "required": ["databaseName", "collectionName"],
        },
    },
  • src/index.ts:344-348 (registration)
    The dispatch case in the tool call handler that routes to the mongodbCreateCollection method.
    case "mongodb_create_collection":
      return await this.mongodbCreateCollection(
        args?.databaseName as string,
        args?.collectionName as string
      );
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a creation operation but doesn't mention whether it requires specific permissions, what happens if the collection already exists, whether it's idempotent, or any rate limits. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 that gets straight to the point with zero wasted words. It's appropriately sized for a simple creation tool and front-loads the essential information without unnecessary elaboration.

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 database mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens on success/failure, return values, error conditions, or behavioral nuances. Given the complexity of database operations and the lack of structured metadata, more contextual information would be needed for reliable agent usage.

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?

The schema description coverage is 100%, with both parameters clearly documented in the input schema. The description doesn't add any additional parameter semantics beyond what's already in the schema (it mentions 'указанной базе данных' which corresponds to databaseName, but this is already covered). With complete schema coverage, the baseline score of 3 is appropriate.

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 ('Создает' - Creates) and resource ('новую коллекцию в указанной базе данных' - new collection in the specified database), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'mongodb_create_database' or 'mongodb_list_collections', but the verb+resource combination is specific enough for basic understanding.

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 like 'mongodb_create_database' (for creating databases) or 'mongodb_list_collections' (for listing existing collections). There's no mention of prerequisites, constraints, or typical use cases, leaving the agent with minimal contextual direction.

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/TrueOleg/MCP-expirements'

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