Skip to main content
Glama

list_firestore_databases

Retrieve all Firestore databases within a specified Google Cloud Platform project using the project ID for efficient database management and oversight.

Instructions

    List Firestore databases in a GCP project.
    
    Args:
        project_id: The ID of the GCP project to list Firestore databases for
    
    Returns:
        List of Firestore databases in the specified GCP project
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • The handler function for the 'list_firestore_databases' tool. It uses the FirestoreAdminClient to list all Firestore databases in the specified GCP project, formats them by name, type, and location, and returns a formatted string list.
        @mcp.tool()
        def list_firestore_databases(project_id: str) -> str:
            """
            List Firestore databases in a GCP project.
            
            Args:
                project_id: The ID of the GCP project to list Firestore databases for
            
            Returns:
                List of Firestore databases in the specified GCP project
            """
            try:
                from google.cloud import firestore_admin_v1
                
                # Initialize the Firestore Admin client
                client = firestore_admin_v1.FirestoreAdminClient()
                
                # List databases
                parent = f"projects/{project_id}"
                databases = client.list_databases(parent=parent)
                
                # Format the response
                databases_list = []
                
                for database in databases:
                    name = database.name.split('/')[-1]
                    db_type = "Firestore Native" if database.type_ == firestore_admin_v1.Database.DatabaseType.FIRESTORE_NATIVE else "Datastore Mode"
                    location = database.location_id
                    
                    databases_list.append(f"- {name} (Type: {db_type}, Location: {location})")
                
                if not databases_list:
                    return f"No Firestore databases found in project {project_id}."
                
                databases_str = "\n".join(databases_list)
                
                return f"""
    Firestore Databases in GCP Project {project_id}:
    {databases_str}
    """
            except Exception as e:
                return f"Error listing Firestore databases: {str(e)}"

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