Files
genai-toolbox/docs/en/how-to/connect-ide/postgres_mcp.md
release-please[bot] f13e9635ba chore(main): release 0.8.0 (#689)
🤖 I have created a release *beep* *boop*
---


##
[0.8.0](https://github.com/googleapis/genai-toolbox/compare/v0.7.0...v0.8.0)
(2025-07-02)


### ⚠ BREAKING CHANGES

* **postgres,mssql,cloudsqlmssql:** encode source connection url for
sources ([#727](https://github.com/googleapis/genai-toolbox/issues/727))

### Features

* Add support for multiple YAML configuration files
([#760](https://github.com/googleapis/genai-toolbox/issues/760))
([40679d7](40679d700e))
* Add support for optional parameters
([#617](https://github.com/googleapis/genai-toolbox/issues/617))
([4827771](4827771b78)),
closes [#475](https://github.com/googleapis/genai-toolbox/issues/475)
* **mcp:** Support MCP version 2025-03-26
([#755](https://github.com/googleapis/genai-toolbox/issues/755))
([474df57](474df57d62))
* **sources/http:** Support disable SSL verification for HTTP Source
([#674](https://github.com/googleapis/genai-toolbox/issues/674))
([4055b0c](4055b0c356))
* **tools/bigquery:** Add templateParameters field for bigquery
([#699](https://github.com/googleapis/genai-toolbox/issues/699))
([f5f771b](f5f771b0f3))
* **tools/bigtable:** Add templateParameters field for bigtable
([#692](https://github.com/googleapis/genai-toolbox/issues/692))
([1c06771](1c067715fa))
* **tools/couchbase:** Add templateParameters field for couchbase
([#723](https://github.com/googleapis/genai-toolbox/issues/723))
([9197186](9197186b8b))
* **tools/http:** Add support for HTTP Tool pathParams
([#726](https://github.com/googleapis/genai-toolbox/issues/726))
([fd300dc](fd300dc606))
* **tools/redis:** Add Redis Source and Tool
([#519](https://github.com/googleapis/genai-toolbox/issues/519))
([f0aef29](f0aef29b0c))
* **tools/spanner:** Add templateParameters field for spanner
([#691](https://github.com/googleapis/genai-toolbox/issues/691))
([075dfa4](075dfa47e1))
* **tools/sqlitesql:** Add templateParameters field for sqlitesql
([#687](https://github.com/googleapis/genai-toolbox/issues/687))
([75e254c](75e254c0a4))
* **tools/valkey:** Add Valkey Source and Tool
([#532](https://github.com/googleapis/genai-toolbox/issues/532))
([054ec19](054ec198b9))


### Bug Fixes

* **bigquery,mssql:** Fix panic on tools with array param
([#722](https://github.com/googleapis/genai-toolbox/issues/722))
([7a6644c](7a6644cf0c))
* **postgres,mssql,cloudsqlmssql:** Encode source connection url for
sources ([#727](https://github.com/googleapis/genai-toolbox/issues/727))
([67964d9](67964d939f)),
closes [#717](https://github.com/googleapis/genai-toolbox/issues/717)
* Set default value to field's type during unmarshalling
([#774](https://github.com/googleapis/genai-toolbox/issues/774))
([fafed24](fafed24858)),
closes [#771](https://github.com/googleapis/genai-toolbox/issues/771)
* **server/mcp:** Do not listen from port for stdio
([#719](https://github.com/googleapis/genai-toolbox/issues/719))
([d51dbc7](d51dbc759b)),
closes [#711](https://github.com/googleapis/genai-toolbox/issues/711)
* **tools/mysqlexecutesql:** Handle nil panic and connection leak in
Invoke ([#757](https://github.com/googleapis/genai-toolbox/issues/757))
([7badba4](7badba42ee))
* **tools/mysqlsql:** Handle nil panic and connection leak in invoke
([#758](https://github.com/googleapis/genai-toolbox/issues/758))
([cbb4a33](cbb4a33351))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan <45984206+Yuan325@users.noreply.github.com>
2025-07-02 09:30:33 -06:00

7.8 KiB

title, type, weight, description
title type weight description
PostgreSQL using MCP docs 2 Connect your IDE to PostgreSQL using Toolbox.

Model Context Protocol (MCP) is an open protocol for connecting Large Language Models (LLMs) to data sources like Postgres. This guide covers how to use MCP Toolbox for Databases to expose your developer assistant tools to a Postgres instance:

{{< notice tip >}} This guide can be used with AlloyDB Omni. {{< /notice >}}

Set up the database

  1. Create or select a PostgreSQL instance.

  2. Create or reuse a database user and have the username and password ready.

Install MCP Toolbox

  1. Download the latest version of Toolbox as a binary. Select the correct binary corresponding to your OS and CPU architecture. You are required to use Toolbox version V0.6.0+:

    {{< tabpane persist=header >}} {{< tab header="linux/amd64" lang="bash" >}} curl -O https://storage.googleapis.com/genai-toolbox/v0.8.0/linux/amd64/toolbox {{< /tab >}}

{{< tab header="darwin/arm64" lang="bash" >}} curl -O https://storage.googleapis.com/genai-toolbox/v0.8.0/darwin/arm64/toolbox {{< /tab >}}

{{< tab header="darwin/amd64" lang="bash" >}} curl -O https://storage.googleapis.com/genai-toolbox/v0.8.0/darwin/amd64/toolbox {{< /tab >}}

{{< tab header="windows/amd64" lang="bash" >}} curl -O https://storage.googleapis.com/genai-toolbox/v0.8.0/windows/amd64/toolbox {{< /tab >}} {{< /tabpane >}}

  1. Make the binary executable:

    chmod +x toolbox
    
  2. Verify the installation:

    ./toolbox --version
    

Configure your MCP Client

{{< tabpane text=true >}} {{% tab header="Claude code" lang="en" %}}

  1. Install Claude Code.

  2. Create a .mcp.json file in your project root if it doesn't exist.

  3. Add the following configuration, replace the environment variables with your values, and save:

    {
      "mcpServers": {
        "postgres": {
          "command": "./PATH/TO/toolbox",
          "args": ["--prebuilt","postgres","--stdio"],
          "env": {
            "POSTGRES_HOST": "",
            "POSTGRES_PORT": "",
            "POSTGRES_DATABASE": "",
            "POSTGRES_USER": "",
            "POSTGRES_PASSWORD": ""
          }
        }
      }
    }
    
  4. Restart Claude code to apply the new configuration. {{% /tab %}}

{{% tab header="Claude desktop" lang="en" %}}

  1. Open Claude desktop and navigate to Settings.

  2. Under the Developer tab, tap Edit Config to open the configuration file.

  3. Add the following configuration, replace the environment variables with your values, and save:

    {
      "mcpServers": {
        "postgres": {
          "command": "./PATH/TO/toolbox",
          "args": ["--prebuilt","postgres","--stdio"],
          "env": {
            "POSTGRES_HOST": "",
            "POSTGRES_PORT": "",
            "POSTGRES_DATABASE": "",
            "POSTGRES_USER": "",
            "POSTGRES_PASSWORD": ""
          }
        }
      }
    }
    
  4. Restart Claude desktop.

  5. From the new chat screen, you should see a hammer (MCP) icon appear with the new MCP server available. {{% /tab %}}

{{% tab header="Cline" lang="en" %}}

  1. Open the Cline extension in VS Code and tap the MCP Servers icon.

  2. Tap Configure MCP Servers to open the configuration file.

  3. Add the following configuration, replace the environment variables with your values, and save:

    {
      "mcpServers": {
        "postgres": {
          "command": "./PATH/TO/toolbox",
          "args": ["--prebuilt","postgres","--stdio"],
          "env": {
            "POSTGRES_HOST": "",
            "POSTGRES_PORT": "",
            "POSTGRES_DATABASE": "",
            "POSTGRES_USER": "",
            "POSTGRES_PASSWORD": ""
          }
        }
      }
    }
    
  4. You should see a green active status after the server is successfully connected. {{% /tab %}}

{{% tab header="Cursor" lang="en" %}}

  1. Create a .cursor directory in your project root if it doesn't exist.

  2. Create a .cursor/mcp.json file if it doesn't exist and open it.

  3. Add the following configuration, replace the environment variables with your values, and save:

    {
      "mcpServers": {
        "postgres": {
          "command": "./PATH/TO/toolbox",
          "args": ["--prebuilt","postgres","--stdio"],
          "env": {
            "POSTGRES_HOST": "",
            "POSTGRES_PORT": "",
            "POSTGRES_DATABASE": "",
            "POSTGRES_USER": "",
            "POSTGRES_PASSWORD": ""
          }
        }
      }
    }
    
  4. Cursor and navigate to Settings > Cursor Settings > MCP. You should see a green active status after the server is successfully connected. {{% /tab %}}

{{% tab header="Visual Studio Code (Copilot)" lang="en" %}}

  1. Open VS Code and create a .vscode directory in your project root if it doesn't exist.

  2. Create a .vscode/mcp.json file if it doesn't exist and open it.

  3. Add the following configuration, replace the environment variables with your values, and save:

    {
      "mcpServers": {
        "postgres": {
          "command": "./PATH/TO/toolbox",
          "args": ["--prebuilt","postgres","--stdio"],
          "env": {
            "POSTGRES_HOST": "",
            "POSTGRES_PORT": "",
            "POSTGRES_DATABASE": "",
            "POSTGRES_USER": "",
            "POSTGRES_PASSWORD": ""
          }
        }
      }
    }
    

{{% /tab %}}

{{% tab header="Windsurf" lang="en" %}}

  1. Open Windsurf and navigate to the Cascade assistant.

  2. Tap on the hammer (MCP) icon, then Configure to open the configuration file.

  3. Add the following configuration, replace the environment variables with your values, and save:

    {
      "mcpServers": {
        "postgres": {
          "command": "./PATH/TO/toolbox",
          "args": ["--prebuilt","postgres","--stdio"],
          "env": {
            "POSTGRES_HOST": "",
            "POSTGRES_PORT": "",
            "POSTGRES_DATABASE": "",
            "POSTGRES_USER": "",
            "POSTGRES_PASSWORD": ""
          }
        }
      }
    }
    
    

{{% /tab %}} {{< /tabpane >}}

Use Tools

Your AI tool is now connected to Postgres using MCP. Try asking your AI assistant to list tables, create a table, or define and execute other SQL statements.

The following tools are available to the LLM:

  1. list_tables: lists tables and descriptions
  2. execute_sql: execute any SQL statement

{{< notice note >}} Prebuilt tools are pre-1.0, so expect some tool changes between versions. LLMs will adapt to the tools available, so this shouldn't affect most users. {{< /notice >}}