Skip to main content
Glama

mongodb_list_databases

Retrieve a list of all databases in MongoDB to manage data storage and organization for macOS application control.

Instructions

Получает список всех баз данных в MongoDB

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the tool logic: connects to MongoDB using MongoClient, lists all databases via admin().listDatabases(), filters out system databases, and returns a formatted text response.
    private async mongodbListDatabases() { const client = await this.getMongoClient(); try { const adminDb = client.db().admin(); const { databases } = await adminDb.listDatabases(); const dbNames = databases .map((db) => db.name) .filter((name) => !["admin", "config", "local"].includes(name)); return { content: [ { type: "text", text: `Базы данных:\n${dbNames.length > 0 ? dbNames.join("\n") : "Базы данных не найдены"}`, }, ], }; } catch (error) { throw new Error( `Ошибка получения списка баз данных: ${error instanceof Error ? error.message : String(error)}` ); } finally { await client.close(); } }
  • The tool's schema definition in the list of tools, specifying the name, description, and empty input schema (no parameters required).
    name: "mongodb_list_databases", description: "Получает список всех баз данных в MongoDB", inputSchema: { type: "object", properties: {}, }, },
  • src/index.ts:341-342 (registration)
    Registration in the tool call handler switch statement, mapping the tool name to the handler function.
    case "mongodb_list_databases": return await this.mongodbListDatabases();
  • Helper function to create and connect a MongoClient instance, reused by all MongoDB tools.
    private async getMongoClient(): Promise<MongoClient> { const client = new MongoClient(MONGODB_URI); await client.connect(); return client; }

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