Skip to main content
Glama
yaoxiaolinglong

MCP-MongoDB-MySQL-Server

mongodb_list_collections

Retrieve all collection names from a MongoDB database to view available data structures and manage database organization.

Instructions

List all collections in the MongoDB database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the mongodb_list_collections tool. Ensures MongoDB connection, lists collections using listCollections().toArray(), and returns JSON-formatted list.
    private async handleMongoDBListCollections() {
      await this.ensureMongoConnection();
    
      try {
        const collections = await this.mongoDB!.listCollections().toArray();
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(collections, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to list collections: ${getErrorMessage(error)}`
        );
      }
    }
  • src/index.ts:399-407 (registration)
    Tool registration in the listTools handler, defining name, description, and empty input schema (no parameters required).
    {
      name: 'mongodb_list_collections',
      description: 'List all collections in the MongoDB database',
      inputSchema: {
        type: 'object',
        properties: {},
        required: [],
      },
    },
  • src/index.ts:554-555 (registration)
    Dispatcher case in CallToolRequestHandler that routes calls to the handleMongoDBListCollections method.
    case 'mongodb_list_collections':
      return await this.handleMongoDBListCollections();
  • Input schema definition for the tool: empty object with no required properties.
      inputSchema: {
        type: 'object',
        properties: {},
        required: [],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It states it's a list operation (implying read-only), but doesn't cover important aspects like whether it requires authentication, returns paginated results, includes system collections, or what format the output takes. This leaves significant gaps for an agent to understand the tool's behavior.

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 communicates the core purpose without any wasted words. It's appropriately sized for a simple listing operation and is front-loaded with the essential information.

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

Completeness3/5

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

For a zero-parameter listing tool with no output schema, the description is minimally complete - it tells the agent what the tool does. However, without annotations and with sibling tools that perform similar functions in different contexts, more guidance would be helpful. The description doesn't address how this differs from 'list_tables' or when to use MongoDB-specific versus generic database tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description doesn't need to add parameter information, and it appropriately doesn't mention any parameters. This meets the baseline expectation for a zero-parameter tool.

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 ('List all collections') and target resource ('in the MongoDB database'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_tables' or 'describe_table', which reduces its score from a perfect 5.

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. There's no mention of prerequisites (e.g., needing a connection first), comparison to similar tools like 'list_tables' for SQL databases, or context about when listing collections is appropriate versus other MongoDB operations.

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