How to Configure JetBrains AI Postgres MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a jetbrains ai postgres mcp server by adding the Model Context Protocol process to your IDE settings. Next, you pass a scoped PostgreSQL database string to that local server process. Teams often start by reusing an admin database user to get fast results. That shortcut lets the AI assistant read every table or alter data by mistake. A safer setup uses a dedicated Postgres role with strict read permissions. How a jetbrains ai postgres mcp server works The IDE runs the MCP server as

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a jetbrains ai postgres mcp server by adding the Model Context Protocol process to your IDE settings. Next, you pass a scoped PostgreSQL database string to that local server process. Teams often start by reusing an admin database user to get fast results. That shortcut lets the AI assistant read every table or alter data by mistake. A safer setup uses a dedicated Postgres role with strict read permissions.

How a jetbrains ai postgres mcp server works

The IDE runs the MCP server as a local background process on your machine. When you ask a question in chat, the assistant inspects your database schema. It sends requests to the MCP server, which translates them into SQL queries. The server then runs those queries against PostgreSQL using the role you gave it. Query results flow back to the assistant so it can write or debug code.

Because the assistant writes its own queries, database permissions are your first defense. You should create a group role in PostgreSQL to hold read-only privileges. Then you create a login user for the IDE and add it to that group. In PostgreSQL, the SELECT privilege lets a role read specific columns or whole tables. It also allows the role to export table data using the copy command.

You must also check default rules tied to the special PUBLIC role in PostgreSQL. By default, every role gets rights to log in to databases and create temporary tables. Every role can also run functions and procedures unless the owner removes that right. In older databases upgraded from before version 15, users might still create objects in the public schema. An admin should revoke those public defaults so the AI role stays locked down.

What native database roles solve and what they miss

Native PostgreSQL roles are great at deciding who can log in to the database. They also control which tables or columns a user is allowed to read. If you grant SELECT only on safe tables, the assistant cannot read secret tables. If you revoke write rights, the assistant cannot drop tables or delete rows.

Still, static roles leave big gaps during daily work with an AI assistant. First, the local MCP config file on each developer laptop needs a database password. Sharing and rotating those plain text keys across a whole engineering team is hard. Second, column grants are rigid when a table mixes safe data with private fields. If the AI needs a user table, it reads raw emails, phone numbers, and card numbers. Database roles do not rewrite sensitive patterns inside query results on the fly. Finally, standard database logs only show that the shared MCP role ran a query. They do not tie each query back to a specific developer identity cleanly.

Kubernetes API Server Access + AI Agent Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Steps to harden your database role

Start by creating a dedicated role that only your IDE assistant will use. Never share your personal admin account or the main app account with the server. Grant the new role access only to the schemas needed for coding tasks. Where a table holds private records, grant SELECT only on the safe columns.

Next, check what the PUBLIC group can do inside your target database. Revoke execute rights on sensitive functions so the assistant cannot trigger side effects. Set a short statement timeout on the role to stop slow queries from locking tables. Review these permissions each time your team adds new tables to the schema. Keep the scope tight so a bad prompt does not expose customer records.

Check every Postgres query on the wire

Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres. It runs beside your database and reads the Postgres wire protocol. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.

Before a query runs, hoop.dev guardrails check the statement by its effect, table, or pattern. They refuse bad deletes or drops with a real Postgres error. On the way back, hoop.dev data masking rewrites sensitive values in returned rows based on your rules. Every query and verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.

Frequently asked questions

Can I restrict the assistant to specific columns in a table?

Yes, PostgreSQL lets you grant the SELECT privilege on individual columns of a table. The assistant will only be able to query the exact columns you allow.

Why can my read-only role still run database functions?

PostgreSQL grants EXECUTE rights on functions and procedures to the PUBLIC role by default. You must revoke that default privilege from PUBLIC so the read-only role cannot run them.

What is the biggest risk of local MCP database setups?

Storing static database credentials in local IDE settings exposes keys on developer machines. It also lets raw emails, phone numbers, and card numbers enter AI chat contexts.

The query runs. The emails stay hidden.