Skip to main content
Glama

list_databases

Retrieve a list of databases within a specified Cloud SQL instance on Google Cloud Platform by providing the project ID and instance ID for quick database management.

Instructions

List databases in a Cloud SQL instance. Args: project_id: The ID of the GCP project instance_id: The ID of the Cloud SQL instance Returns: List of databases in the specified Cloud SQL instance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_idYes
project_idYes

Implementation Reference

  • The core handler function for the 'list_databases' MCP tool. It uses the Google Cloud SQL Admin API to list all databases in a specified Cloud SQL instance, formats the results, and returns a human-readable string.
    @mcp.tool() def list_databases(project_id: str, instance_id: str) -> str: """ List databases in a Cloud SQL instance. Args: project_id: The ID of the GCP project instance_id: The ID of the Cloud SQL instance Returns: List of databases in the specified Cloud SQL instance """ try: from googleapiclient import discovery # Initialize the Cloud SQL Admin API client service = discovery.build('sqladmin', 'v1') # List databases request = service.databases().list(project=project_id, instance=instance_id) response = request.execute() # Format the response databases_list = [] if 'items' in response: for database in response['items']: name = database.get('name', 'Unknown') charset = database.get('charset', 'Unknown') collation = database.get('collation', 'Unknown') databases_list.append(f"- {name} (Charset: {charset}, Collation: {collation})") if not databases_list: return f"No databases found in Cloud SQL instance {instance_id}." databases_str = "\n".join(databases_list) return f""" Databases in Cloud SQL Instance {instance_id}: {databases_str} """ except Exception as e: return f"Error listing databases: {str(e)}"
  • Top-level registration call for the databases module, which registers the 'list_databases' tool (among others) with the MCP server via the module's register_tools function.
    databases_tools.register_tools(mcp)
  • Import of the databases tools module in the main MCP server file, aliased as databases_tools, enabling the registration of tools including 'list_databases'.
    from .gcp_modules.databases import tools as databases_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/henihaddad/gcp-mcp'

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