Skip to main content
Glama
TrueOleg

MCP Mac Apps Server

by TrueOleg

mongodb_insert_document

Insert JSON documents into MongoDB collections from macOS applications. Specify database, collection, and document data to add records to your database.

Instructions

Вставляет документ в коллекцию

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNameYesИмя базы данных
collectionNameYesИмя коллекции
documentYesJSON строка с документом для вставки

Implementation Reference

  • Python implementation of the mongodb_insert_document tool handler using pymongo to insert a single document into a MongoDB collection.
    def mongodb_insert_document(
        database_name: str, collection_name: str, document_json: str
    ) -> str:
        """Inserts document into collection"""
        client = MongoClient(MONGODB_URI)
        try:
            db = client[database_name]
            collection = db[collection_name]
            document = json.loads(document_json)
            result = collection.insert_one(document)
            return f'Document successfully inserted into collection "{collection_name}". ID: {result.inserted_id}'
        except Exception as e:
            raise Exception(f"Error inserting document: {str(e)}")
        finally:
            client.close()
  • TypeScript implementation of the mongodb_insert_document tool handler using MongoDB Node.js driver to insert a single document into a collection.
    private async mongodbInsertDocument(
      databaseName: string,
      collectionName: string,
      documentJson: string
    ) {
      const client = await this.getMongoClient();
      try {
        const db = client.db(databaseName);
        const collection = db.collection(collectionName);
        const document = JSON.parse(documentJson);
        const result = await collection.insertOne(document);
        
        return {
          content: [
            {
              type: "text",
              text: `Документ успешно вставлен в коллекцию "${collectionName}". ID: ${result.insertedId}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(
          `Ошибка вставки документа: ${error instanceof Error ? error.message : String(error)}`
        );
      } finally {
        await client.close();
      }
    }
  • Input schema for mongodb_insert_document tool in the Python server's tools list.
        "name": "mongodb_insert_document",
        "description": "Inserts document into collection",
        "inputSchema": {
            "type": "object",
            "properties": {
                "databaseName": {
                    "type": "string",
                    "description": "Database name",
                },
                "collectionName": {
                    "type": "string",
                    "description": "Collection name",
                },
                "document": {
                    "type": "string",
                    "description": "JSON string with document to insert",
                },
            },
            "required": ["databaseName", "collectionName", "document"],
        },
    },
  • Input schema for mongodb_insert_document tool in the TypeScript server's tools list.
    name: "mongodb_insert_document",
    description: "Вставляет документ в коллекцию",
    inputSchema: {
      type: "object",
      properties: {
        databaseName: {
          type: "string",
          description: "Имя базы данных",
        },
        collectionName: {
          type: "string",
          description: "Имя коллекции",
        },
        document: {
          type: "string",
          description: "JSON строка с документом для вставки",
        },
      },
      required: ["databaseName", "collectionName", "document"],
    },
  • src/index.ts:359-364 (registration)
    Tool call dispatch/registration in the TypeScript server's CallToolRequest handler switch statement.
    case "mongodb_insert_document":
      return await this.mongodbInsertDocument(
        args?.databaseName as string,
        args?.collectionName as string,
        args?.document as string
      );
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'inserts' which implies a write/mutation operation, but doesn't disclose behavioral traits like required permissions, whether it's idempotent, error handling (e.g., duplicate keys), or what happens on success/failure. For a mutation tool with zero annotation coverage, this is a significant gap.

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 in Russian that directly states the tool's action. It's appropriately sized and front-loaded with zero wasted words, making it highly concise and well-structured.

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 this is a mutation tool with no annotations, no output schema, and 3 parameters, the description is incomplete. It doesn't cover return values, error conditions, or behavioral context needed for safe and effective use. The 100% schema coverage helps but doesn't compensate for the lack of operational guidance.

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 all three parameters (databaseName, collectionName, document) well-documented in the schema. The description adds no additional meaning beyond the schema's parameter details. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Вставляет документ в коллекцию' (Inserts a document into a collection) clearly states the verb 'inserts' and the resource 'document into collection', but it doesn't specify MongoDB context or differentiate from sibling tools like mongodb_create_collection or mongodb_delete_document. It's vague about the specific MongoDB operation scope.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., database/collection must exist), exclusions, or compare to siblings like mongodb_create_collection for collection-level operations. Usage context is implied but not explicit.

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