docs/ALLOYDBPG_README.md
The AlloyDB Model Context Protocol (MCP) Server gives AI-powered development tools the ability to work with your Google Cloud AlloyDB for PostgreSQL resources. It supports full lifecycle control, from exploring schemas and running queries to monitoring your database.
An editor configured to use the AlloyDB MCP server can use its AI capabilities to help you:
For AlloyDB infrastructure management, search the MCP store for the AlloyDB for PostgreSQL Admin MCP Server.
roles/alloydb.client) (for connecting and querying)roles/serviceusage.serviceUsageConsumer)Note: If your AlloyDB instance uses private IPs, you must run the MCP server in the same Virtual Private Cloud (VPC) network.
In the Antigravity MCP Store, click the "Install" button.
[!NOTE] On first use, the installation process automatically downloads and uses MCP Toolbox
>=0.26.0. To update MCP Toolbox, use:npm i -g @toolbox-sdk/server@latestTo always run the latest version, update the MCP server configuration to use:npx -y @toolbox-sdk/server@latest --prebuilt alloydb-postgres.
Add the required inputs for your cluster in the configuration pop-up, then click "Save". You can update this configuration at any time in the "Configure" tab.
[!NOTE] If you encounter issues with Windows Defender blocking the execution, you may need to configure an allowlist. See Configure exclusions for Microsoft Defender Antivirus for more details.
You'll now be able to see all enabled tools in the "Tools" tab.
Once configured, the MCP server will automatically provide AlloyDB capabilities to your AI assistant. You can:
The AlloyDB MCP server provides the following tools:
| Tool Name | Description |
|---|---|
list_tables | Lists detailed schema information for user-created tables. |
execute_sql | Executes a SQL query. |
list_active_queries | List currently running queries. |
list_available_extensions | List available extensions for installation. |
list_installed_extensions | List installed extensions. |
get_query_plan | Get query plan for a SQL statement. |
list_autovacuum_configurations | List autovacuum configurations and their values. |
list_memory_configurations | List memory configurations and their values. |
list_top_bloated_tables | List top bloated tables. |
list_replication_slots | List replication slots. |
list_invalid_indexes | List invalid indexes. |
The AlloyDB MCP server is configured using environment variables.
export ALLOYDB_POSTGRES_PROJECT="<your-gcp-project-id>"
export ALLOYDB_POSTGRES_REGION="<your-alloydb-region>"
export ALLOYDB_POSTGRES_CLUSTER="<your-alloydb-cluster-id>"
export ALLOYDB_POSTGRES_INSTANCE="<your-alloydb-instance-id>"
export ALLOYDB_POSTGRES_DATABASE="<your-database-name>"
export ALLOYDB_POSTGRES_USER="<your-database-user>" # Optional
export ALLOYDB_POSTGRES_PASSWORD="<your-database-password>" # Optional
export ALLOYDB_POSTGRES_IP_TYPE="PUBLIC" # Optional: `PUBLIC`, `PRIVATE`, `PSC`. Defaults to `PUBLIC`.
Add the following configuration to your MCP client (e.g., settings.json for Gemini CLI, mcp_config.json for Antigravity):
{
"mcpServers": {
"alloydb-postgres": {
"command": "npx",
"args": ["-y", "@toolbox-sdk/server", "--prebuilt", "alloydb-postgres", "--stdio"]
}
}
}
For more information, visit the AlloyDB for PostgreSQL documentation.