Skip to main content
Glama

list_databases

Retrieve databases in an Oracle Cloud compartment, with optional filtering by DB System to identify available database resources and their connection details.

Instructions

List all databases in a compartment, optionally filtered by DB System.

Args:
    compartment_id: OCID of the compartment to list databases from
    db_system_id: Optional OCID of the DB System to filter databases

Returns:
    List of databases with their state, version, and connection information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes
db_system_idNo

Implementation Reference

  • Core handler function implementing the logic to list OCI databases in a compartment using the OCI SDK, optionally filtered by db_system_id. Returns formatted list of database details.
    def list_databases(database_client: oci.database.DatabaseClient, compartment_id: str, 
                       db_system_id: Optional[str] = None) -> List[Dict[str, Any]]:
        """
        List all databases in a compartment, optionally filtered by DB system.
        
        Args:
            database_client: OCI Database client
            compartment_id: OCID of the compartment
            db_system_id: Optional OCID of the DB system to filter by
            
        Returns:
            List of databases with their details
        """
        try:
            databases_response = oci.pagination.list_call_get_all_results(
                database_client.list_databases,
                compartment_id,
                db_system_id=db_system_id
            )
            
            databases = []
            for database in databases_response.data:
                databases.append({
                    "id": database.id,
                    "db_name": database.db_name,
                    "compartment_id": database.compartment_id,
                    "character_set": database.character_set,
                    "ncharacter_set": database.ncharacter_set,
                    "db_workload": database.db_workload,
                    "pdb_name": database.pdb_name,
                    "lifecycle_state": database.lifecycle_state,
                    "time_created": str(database.time_created),
                    "db_unique_name": database.db_unique_name,
                    "db_system_id": database.db_system_id,
                    "vm_cluster_id": database.vm_cluster_id,
                    "kms_key_id": database.kms_key_id,
                    "vault_id": database.vault_id,
                })
            
            logger.info(f"Found {len(databases)} databases in compartment {compartment_id}")
            return databases
            
        except Exception as e:
            logger.exception(f"Error listing databases: {e}")
            raise
  • MCP tool registration for 'list_databases' using @mcp.tool decorator. This async wrapper function handles MCP context, logging, error handling via mcp_tool_wrapper, and delegates to the core handler.
    @mcp.tool(name="list_databases")
    @mcp_tool_wrapper(
        start_msg="Listing databases in compartment {compartment_id}...",
        error_prefix="Error listing databases"
    )
    async def mcp_list_databases(ctx: Context, compartment_id: str, db_system_id: Optional[str] = None) -> List[Dict[str, Any]]:
        """
        List all databases in a compartment, optionally filtered by DB System.
    
        Args:
            compartment_id: OCID of the compartment to list databases from
            db_system_id: Optional OCID of the DB System to filter databases
    
        Returns:
            List of databases with their state, version, and connection information
        """
        return list_databases(oci_clients["database"], compartment_id, db_system_id)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the return format (list with state, version, connection info), but doesn't disclose critical behavioral traits like pagination, rate limits, authentication requirements, error conditions, or whether it's a read-only operation. For a list operation with zero annotation coverage, this is inadequate.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence adds value: the first states the action, the next two explain parameters, and the last describes returns. No wasted words.

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?

Given 2 parameters with 0% schema coverage and no output schema, the description does well on parameters but lacks behavioral context. It explains what the tool returns but doesn't cover pagination, errors, or operational constraints. For a list tool with no annotations, this is minimally adequate but leaves gaps.

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 description coverage is 0%, so the description must compensate. It clearly explains both parameters: 'compartment_id' as 'OCID of the compartment to list databases from' and 'db_system_id' as 'Optional OCID of the DB System to filter databases'. This adds essential meaning beyond the schema's bare titles, though it doesn't detail OCID format or validation.

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 verb ('List') and resource ('databases in a compartment'), with optional filtering by DB System. It distinguishes from siblings like 'get_database' (singular retrieval) and 'list_db_systems' (different resource), but doesn't explicitly differentiate from 'list_autonomous_databases' (a specific database type).

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

Usage Guidelines3/5

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

The description implies usage for listing databases within a compartment, optionally filtered. It doesn't provide explicit when-to-use vs. when-not-to-use guidance, nor does it mention alternatives like 'list_autonomous_databases' for specific database types. The context is clear but lacks sibling differentiation.

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/jopsis/mcp-server-oci'

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