How to Configure Dify Supabase MCP Server
To set up a dify supabase mcp server, link your agent to a dedicated Postgres role. You pass the server credentials into your agent tool settings so models can query data. Many teams take a shortcut and use the default admin login during setup. That broad role lets an agent change tables or read every row by mistake by default. How a dify supabase mcp server works with database roles The Model Context Protocol gives language models a standard way to call external tools. In this setup, Dify ac
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.
To set up a dify supabase mcp server, link your agent to a dedicated Postgres role. You pass the server credentials into your agent tool settings so models can query data. Many teams take a shortcut and use the default admin login during setup. That broad role lets an agent change tables or read every row by mistake by default.
How a dify supabase mcp server works with database roles
The Model Context Protocol gives language models a standard way to call external tools. In this setup, Dify acts as the host app that runs your agent workflow. The server sits between the agent and your Supabase Postgres database. When a user asks a question, the agent picks a tool and sends a request. The server turns that request into a database query and returns the result.
Every new Supabase project comes with a default postgres role. This role has admin rights, though Supabase blocks full superuser access to prevent destructive tasks. The password you pick when you create the project belongs to this admin role. Supabase warns teams not to give this main password to external tools or services. Instead, you should make a new Postgres user just for your agent server.
Supabase also includes built-in roles like anon, authenticated, and service_role for its API layer. If your server connects straight to Postgres, you control access with standard database grants. You can limit the new user to read-only queries on a few safe tables. When the server logs in with this role, Postgres checks those table grants first.
How to scope permissions for your agent workflow
Start by creating a fresh database role inside your Supabase project for the server. Give this role a strong password and do not share it with other apps. Next, remove public access Rights so the new role starts with zero table access. Grant select rights only on the specific tables that your Dify workflow needs to read. If the agent must write data, limit insert or update rights to those exact tables.
Once the role is ready, you register the server inside your Dify workspace. You point the agent tool settings to the running server endpoint. The server holds the database string and opens sessions when the agent calls a tool. Test the setup by asking the agent to read a table outside its grant list. Postgres will reject the query and return a permission error to the agent.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native roles solve and what they leave open
A scoped Postgres role solves the first layer of access control for your database. It stops the agent from dropping tables or reading schemas it should not touch. It also separates your agent traffic from queries you run in the Supabase dashboard. Queries run in the dashboard use the main admin role and carry a dashboard comment.
Still, static database roles only check who logs in at the start of a session. They do not inspect what individual queries do while the session is active. If a table holds user profiles, a select grant returns every column in those rows by default. The database sends raw emails, phone numbers, card numbers, and national IDs back to the model. Data masking is needed to rewrite matched fields in results before they reach the prompt.
Static credentials also sit in your server config files until someone rotates them by hand. Also, database role checks do not tie a specific SQL statement to the end user in Dify. If an agent runs a bad update query, you cannot pause that single command for human approval. You need statement-level controls and field masking to manage live agent queries safely.
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
Should I use the default postgres password for my Dify agent?
No, the default postgres role has admin rights across your project. Supabase advises creating a separate database user for every external service you connect.
Can database roles hide sensitive columns from language models?
Standard table grants allow or block access to whole tables or columns at once. They do not dynamically rewrite emails or card numbers inside query results in flight.
How do I stop an AI agent from deleting rows in Supabase?
Create a dedicated Postgres role for the server and grant it only select privileges. Without delete or drop grants, Postgres will block any destructive query from the agent.
Related guides
In this post