Skip to main content
Glama
TrueOleg

MCP Mac Apps Server

by TrueOleg

mongodb_list_databases

Retrieve a list of all databases in MongoDB to manage data storage and organization within the MCP Mac Apps Server environment.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function that connects to MongoDB, lists all databases via admin().listDatabases(), filters out system databases (admin, config, local), 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();
      }
    }
  • Tool schema definition in the ListTools response, specifying 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)
    Dispatch/registration in the CallToolRequestHandler switch statement that routes the tool call to the mongodbListDatabases method.
    case "mongodb_list_databases":
      return await this.mongodbListDatabases();
  • Python implementation of the handler function using pymongo to list databases, filtering system ones, returning formatted text. Note: dispatch case is commented out.
    def mongodb_list_databases() -> str:
        """Gets list of databases"""
        client = MongoClient(MONGODB_URI)
        try:
            admin_db = client.admin
            databases = admin_db.command("listDatabases")
            db_names = [
                db["name"]
                for db in databases["databases"]
                if db["name"] not in ["admin", "config", "local"]
            ]
            result = "Databases:\n" + (
                "\n".join(db_names) if db_names else "No databases found"
            )
            return result
        except Exception as e:
            raise Exception(f"Error getting list of databases: {str(e)}")
        finally:
            client.close()
  • Helper method 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;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets a list' but doesn't elaborate on aspects like whether it requires authentication, returns all databases or a filtered subset, handles errors, or provides metadata (e.g., sizes, status). For a tool with zero annotation coverage, this leaves significant gaps in understanding its 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, clear sentence in Russian: 'Получает список всех баз данных в MongoDB'. It is front-loaded with the core action and resource, with no unnecessary words or fluff. This makes it highly efficient and easy to parse, earning a top score for conciseness.

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 the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimal but adequate for basic understanding. However, it lacks details on behavioral aspects (e.g., authentication needs, return format) and usage context, which are important for an AI agent to invoke it correctly in real-world scenarios. This makes it incomplete despite the low complexity.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here. A baseline score of 4 is given because the schema fully covers the parameters (none exist), and the description doesn't need to compensate, avoiding redundancy.

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 tool's purpose: 'Получает список всех баз данных в MongoDB' (Gets a list of all databases in MongoDB). It specifies the verb 'получает' (gets) and resource 'баз данных в MongoDB' (databases in MongoDB), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'mongodb_list_collections', which might cause confusion about 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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer this over other database-related tools (e.g., 'mongodb_list_collections' for listing collections within a database) or any prerequisites. This lack of context could lead to misuse in scenarios requiring more specific database 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/TrueOleg/MCP-expirements'

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