get_database
Retrieve detailed Oracle Cloud Infrastructure database information including connection strings, character set, and PDB name by providing the database OCID.
Instructions
Get detailed information about a specific database.
Args:
database_id: OCID of the database to retrieve
Returns:
Detailed database information including connection strings, character set, and PDB name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_id | Yes |
Implementation Reference
- mcp_server_oci/mcp_server.py:998-1015 (handler)MCP tool handler for 'get_database': registers the tool, wraps with error handling decorator, and delegates to helper function using global OCI database client.@mcp.tool(name="get_database") @mcp_tool_wrapper( start_msg="Getting database details for {database_id}...", success_msg="Retrieved database details successfully", error_prefix="Error getting database details" ) async def mcp_get_database(ctx: Context, database_id: str) -> Dict[str, Any]: """ Get detailed information about a specific database. Args: database_id: OCID of the database to retrieve Returns: Detailed database information including connection strings, character set, and PDB name """ return get_database(oci_clients["database"], database_id)
- Core helper function that performs the OCI DatabaseClient.get_database API call, extracts relevant fields, and returns formatted dictionary with database details.def get_database(database_client: oci.database.DatabaseClient, database_id: str) -> Dict[str, Any]: """ Get details of a specific database. Args: database_client: OCI Database client database_id: OCID of the database Returns: Details of the database """ try: database = database_client.get_database(database_id).data database_details = { "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, "source_database_point_in_time_recovery_timestamp": str(database.source_database_point_in_time_recovery_timestamp) if database.source_database_point_in_time_recovery_timestamp else None, } logger.info(f"Retrieved details for database {database_id}") return database_details except Exception as e: logger.exception(f"Error getting database details: {e}") raise