{
  "markdown": "# Gemini CLI Extension - PostgreSQL\n\n> [!NOTE]\n> This extension is currently in beta (pre-v1.0), and may see breaking changes until the first stable release (v1.0).\n\nThis Gemini CLI extension provides a set of tools to interact with [PostgreSQL](https://www.postgresql.org/docs/) instances. It allows you to manage your databases, execute queries, and explore schemas directly from the [Gemini CLI](https://google-gemini.github.io/gemini-cli/), using natural language prompts.\n\nLearn more about [Gemini CLI Extensions](https://github.com/google-gemini/gemini-cli/blob/main/docs/extensions/index.md).\n> [!IMPORTANT]\n> **We Want Your Feedback!**\n> Please share your thoughts with us by filling out our feedback [form][form]. \n> Your input is invaluable and helps us improve the project for everyone.\n\n[form]: https://docs.google.com/forms/d/e/1FAIpQLSfEGmLR46iipyNTgwTmIDJqzkAwDPXxbocpXpUbHXydiN1RTw/viewform?usp=pp_url&entry.157487=postgres\n\n## Why Use the Postgres Extension?\n\n* **Natural Language Management:** Stop wrestling with complex commands. Explore schemas and query data by describing what you want in plain English.\n* **Seamless Workflow:** Stay in your CLI. No need to constantly switch contexts to the GCP console for common database tasks.\n* **Code Generation:** Accelerate development by asking Gemini to generate data classes and other code snippets based on your table schemas.\n\n\n## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n* One of the supported agent harnesses, installed and authenticated:\n  * [Gemini CLI](https://github.com/google-gemini/gemini-cli) (v0.6.0+)\n  * [Claude Code](https://code.claude.com)\n  * [Codex](https://developers.openai.com/codex) (v0.150.0+)\n  * [Antigravity CLI](https://antigravity.google)\n* [Node.js](https://nodejs.org/) (the MCP server runs via `npx`).\n* A running PostgreSQL instance.\n* Users are granted database-level permissions to execute queries.\n\n## Getting Started\n\n### Installation\n\nAll harnesses use the same plugin; the MCP server runs via `npx` (no binary to download). Install with your harness of choice:\n\n**Gemini CLI**\n\n```bash\ngemini extensions install https://github.com/gemini-cli-extensions/postgres\n```\n\n**Claude Code**\n\n```bash\nclaude plugin marketplace add gemini-cli-extensions/postgres\nclaude plugin install postgres@postgres\n```\n\n**Codex**\n\n```bash\ncodex plugin marketplace add gemini-cli-extensions/postgres\ncodex plugin add postgres@postgres\n```\n\n**Antigravity**\n\n```bash\nagy plugin install https://github.com/gemini-cli-extensions/postgres\n```\n\nSee [Configuration](#configuration) for how each harness supplies the connection settings.\n\n### Configuration\n\nThe plugin connects to PostgreSQL using these settings:\n\n*   `POSTGRES_DATABASE`: The name of the database to connect to.\n*   `POSTGRES_USER`: The database username.\n*   `POSTGRES_PASSWORD`: The password for the database user.\n*   `POSTGRES_HOST`: (Optional) The Postgres host. Defaults to `localhost`.\n*   `POSTGRES_PORT`: (Optional) The Postgres port. Defaults to `5432`.\n*   `POSTGRES_QUERY_PARAMS`: (Optional) Connection string parameters.\n\nHow you supply them depends on the harness:\n\n*   **Gemini CLI**: prompted on install and saved to the extension's `.env`. View or update later with `gemini extensions list` / `gemini extensions config postgres [setting] [--scope user|workspace]` (restart the CLI to apply).\n*   **Claude Code**: pass `--config KEY=VALUE` on install (repeatable), or run `/plugin` inside Claude Code.\n*   **Codex** and **Antigravity**: export the variables in your shell before starting:\n\n```bash\nexport POSTGRES_DATABASE=\"<your-database-name>\"\nexport POSTGRES_USER=\"<your-database-user>\"\nexport POSTGRES_PASSWORD=\"<your-database-password>\"\nexport POSTGRES_HOST=\"<your-postgres-host>\"                    # Optional, defaults to localhost\nexport POSTGRES_PORT=\"<your-postgres-port>\"                    # Optional, defaults to 5432\nexport POSTGRES_QUERY_PARAMS=\"<your-connection-string-params>\" # Optional\n```\n\n> [!NOTE]\n> See [Troubleshooting](#troubleshooting) for debugging your configuration.\n\n### Start Gemini CLI\n\nTo start the Gemini CLI, use the following command:\n\n```bash\ngemini\n```\n\n> [!WARNING]\n> **Changing Instance & Database Connections**\n> Currently, the database connection must be configured before starting the Gemini CLI and can not be changed during a session.\n> To save and resume conversation history use command: `/chat save <tag>` and `/chat resume <tag>`.\n\n## Usage Examples\n\nInteract with Postgres using natural language right from your IDE:\n\n* **Explore Schemas and Data:**\n    * \"Show me all tables in the 'orders' database.\"\n    * \"What are the columns in the 'products' table?\"\n    * \"How many orders were placed in the last 30 days, and what were the top 5 most purchased items?\"\n\n* **Generate Code:**\n    * \"Generate a Python dataclass to represent the 'customers' table.\"\n\n## Supported Tools\n\n * `list_tables`: Use this tool to list tables in the database.\n * `database_overview`: Use this tool to fetches the current state of the PostgreSQL server.\n * `execute_sql`: Use this tool to execute a SQL query.\n * `list_active_queries`: Use this tool to list currently running queries.\n * `list_available_extensions`: Use this tool to list available extensions for installation.\n * `list_installed_extensions`: Use this tool to list installed extensions.\n * `get_query_plan`: Use this tool to get query plan.\n * `list_autovacuum_configurations`: Use this tool to list autovacuum configurations and its value.\n * `list_database_stats`: Use this tool to lists the key performance and activity statistics for each database in the PostgreSQL server.\n * `list_indexes`: Use this tool to list available user indexes in a PostgreSQL database.\n * `list_memory_configurations`: Use this tool to list memory configurations and its value.\n * `list_pg_settings`: Use this tool to list configuration parameters for the PostgreSQL server.\n * `list_publication_tables`: Use this tool to list publication tables in a PostgreSQL database.\n * `list_replication_slots`: Use this tool to list replication slots.\n * `list_roles`: Use this tool to lists all the user-created roles in PostgreSQL database.\n * `list_schemas`: Use this tool to lists schemas in the database.\n * `list_sequences`: Use this tool to list sequences in a PostgreSQL database.\n * `list_tablespaces`: Use this tool to lists tablespaces in the database.\n * `list_top_bloated_tables`: Use this tool to list top bloated tables.\n * `list_triggers`: Use this tool to lists triggers in the database.\n * `list_views`: Use this tool to lists views in the database from pg_views with a default limit of 50 rows.\n * `list_invalid_indexes`: Use this tool to list invalid indexes.\n\n## Additional Extensions\n\nFind additional extensions to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions), including:\n* [Cloud SQL for PostgreSQL extension](https://github.com/gemini-cli-extensions/cloud-sql-postgresql)\n* and more!\n\n## Troubleshooting\n\nUse `gemini --debug` to enable debugging.\n\nCommon issues:\n\n* \"✖ Error during discovery for server: MCP error -32000: Connection closed\": The database connection has not been established. Ensure your configuration is set via environment variables.\n* \"✖ MCP ERROR: Error: spawn npx ENOENT\": Node.js/`npx` is not installed or not on your `PATH`. Install Node.js (which provides `npx`).\n* \"npm error\"/network failures on first run: `npx` fetches `@toolbox-sdk/server` on first launch, so it needs network access. Retry once connectivity is available.\n",
  "bytes": 7613,
  "sha": "1d63781dc508db9b7c92159058ff037d75098f4aa8c57396512c80f4281888f7",
  "repo_slug": "gemini-cli-extensions/postgres",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_gemini_cli_extensions_postgres_4ed59bcd/readme"
}