Skip to main content
Glama

MCP-MongoDB-MySQL-Server

mongodb_list_collections

Retrieve all collections in a MongoDB database to manage or analyze data. Part of the MCP-MongoDB-MySQL-Server, this tool supports streamlined database operations and schema insights.

Instructions

List all collections in the MongoDB database

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "required": [], "type": "object" }

Implementation Reference

  • The handler function that ensures MongoDB connection and lists all collections using this.mongoDB!.listCollections().toArray(), returning the JSON stringified collections.
    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)}` ); } }
  • Input schema definition for the tool, which requires no parameters (empty object).
    inputSchema: { type: 'object', properties: {}, required: [], },
  • src/index.ts:399-407 (registration)
    Tool registration in the tools array passed to server.setTools(), defining name, description, and schema.
    { name: 'mongodb_list_collections', description: 'List all collections in the MongoDB database', inputSchema: { type: 'object', properties: {}, required: [], }, },
  • src/index.ts:554-555 (registration)
    Switch case in the CallToolRequestHandler that dispatches calls to the specific handler function.
    case 'mongodb_list_collections': return await this.handleMongoDBListCollections();

Other Tools

Related 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