Skip to main content
Glama
hendrickcastro

MCP CosmosDB

mcp_list_databases

List all databases in your Azure CosmosDB account to discover available databases before querying containers. Returns database IDs, timestamps, and ETags.

Instructions

List all databases in the CosmosDB account. Use this to discover available databases before querying containers. Returns database IDs, timestamps, and ETags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connection_idNoID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

Implementation Reference

  • The main handler function that executes the mcp_list_databases tool logic. It accepts an optional connection_id, retrieves the CosmosDB client, lists all databases via client.databases.readAll().fetchAll(), and returns database info (id, etag, timestamp) along with connection metadata.
    export const mcp_list_databases = async (args?: { connection_id?: string }): Promise<ToolResult<any>> => {
      const connection_id = args?.connection_id;
      log(`Executing mcp_list_databases with connection_id: ${connection_id || 'default'}`);
    
      try {
        const connInfo = getConnectionInfo(connection_id);
        log(`[DEBUG] Connection info: ${JSON.stringify(connInfo)}`);
        
        const database = getDatabase(connection_id);
        const client = database.client;
        
        const { resources: databases } = await client.databases.readAll().fetchAll();
        
        const databasesInfo = databases.map(db => ({
          id: db.id,
          etag: db._etag,
          timestamp: new Date(db._ts * 1000)
        }));
    
        // Include connection info for clarity
        return { 
          success: true, 
          data: {
            connection: {
              id: connInfo.connectionId,
              endpoint: connInfo.endpoint,
              databaseId: connInfo.databaseId,
              allowModifications: connInfo.allowModifications
            },
            availableConnections: connInfo.registeredConnections,
            databases: databasesInfo
          }
        };
      } catch (error: any) {
        log(`Error in mcp_list_databases: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
  • Schema/registration definition for the mcp_list_databases tool. Defines the tool name, description, and input schema (optional connection_id property).
    {
      name: "mcp_list_databases",
      description: "List all databases in the CosmosDB account. Use this to discover available databases before querying containers. Returns database IDs, timestamps, and ETags.",
      inputSchema: {
        type: "object",
        properties: {
          ...connectionIdProperty
        },
        required: []
      }
    },
  • src/server.ts:119-121 (registration)
    Registration entry in the MCP CallTool handler's switch statement. Routes the tool name 'mcp_list_databases' to the handler function imported from './mcp-server.js'.
    case 'mcp_list_databases':
        result = await toolHandlers.mcp_list_databases(input as any);
        break;
  • Helper function getDatabase() used by the handler to retrieve the CosmosDB Database reference for the specified connection.
    export const getDatabase = (connectionId?: string): Database => {
      return getConnection(connectionId).database;
    };
  • Helper function getConnectionInfo() used by the handler to retrieve connection metadata for inclusion in the response.
    export const getConnectionInfo = (connectionId?: string): { 
      connectionId: string;
      endpoint: string; 
      databaseId: string; 
      allowModifications: boolean;
      pid: number;
      activeConnections: string[];
      registeredConnections: string[];
    } => {
      const id = resolveConnectionId(connectionId);
      const connection = activeConnections.get(id);
      const config = registeredConnections.get(id);
      
      const { endpoint } = config ? parseConnectionString(config.connectionString) : { endpoint: 'NOT CONNECTED' };
      
      return {
        connectionId: id,
        endpoint,
        databaseId: config?.databaseId || 'NOT SET',
        allowModifications: config?.allowModifications || false,
        pid: process.pid,
        activeConnections: Array.from(activeConnections.keys()),
        registeredConnections: Array.from(registeredConnections.keys())
      };
    };
Behavior3/5

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

No annotations provided, so description carries burden. It states it returns IDs, timestamps, and ETags, but does not mention permissions, rate limits, or default behavior for connection_id.

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?

Two sentences, front-loaded purpose, no wasted words. Efficient and clear.

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

Completeness4/5

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

Covers purpose, usage guidance, and return values. Lacks mention of default connection behavior and any pagination, but adequate for a simple list tool.

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?

Schema coverage is 100% with a clear description of connection_id. The tool description adds value by referencing mcp_list_connections to find available connections.

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

Purpose5/5

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

The description clearly states the tool lists all databases in a CosmosDB account, distinct from sibling tools like mcp_list_containers and mcp_list_connections.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this to discover available databases before querying containers', providing clear context for when to use it. Does not explicitly exclude alternatives but context is sufficient.

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/hendrickcastro/MCPCosmosDB'

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