How to Configure n8n MySQL MCP Server
You set up an n8n mysql mcp server by linking an AI Agent node to a tool sub-node. The agent then uses this tool to run SQL queries against your database. Many teams start by giving the workflow a broad database user role. This quick shortcut creates big risks when the agent runs bad queries. Overly broad permissions let a confused model change or delete live data. How the n8n mysql mcp server workflow operates The n8n AI Agent node builds an agent from a chat model and tools. You must attach
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 an n8n mysql mcp server by linking an AI Agent node to a tool sub-node. The agent then uses this tool to run SQL queries against your database. Many teams start by giving the workflow a broad database user role. This quick shortcut creates big risks when the agent runs bad queries. Overly broad permissions let a confused model change or delete live data.
How the n8n mysql mcp server workflow operates
The n8n AI Agent node builds an agent from a chat model and tools. You must attach at least one tool sub-node to the AI Agent node. The agent then decides which tools to call to finish its task. In n8n 1.82.0, the old agent type setting is deprecated. Every AI Agent node now works as a Tools Agent by default. Node version 1 with that old setting goes away in n8n 3.0. Earlier workflows often used the old SQL Agent for database tasks. That SQL Agent took plain text questions and turned them into SQL queries. It ran those queries on MySQL, SQLite, or Postgres and showed the results. For SQL Agent tasks today, the docs say to use a MySQL tool sub-node. You attach that sub-node to a recent AI Agent node instead. Beyond built-in nodes, n8n also offers a registry of MCP servers as agent tools. You can also attach a Call n8n Workflow Tool or a Custom Code Tool. An HTTP Request Tool works as an agent tool in the workflow too.
What native database roles solve and what they miss
Native MySQL roles and n8n settings control which account logs into the database. You can set up a read-only database user for the tool sub-node. You can also restrict which tables the agent sees during a run. The old SQL Agent had an Included Tables option for this basic need. These static controls stop an agent from writing to blocked tables. Still, native login roles only check who logs in at the start. They do not inspect what individual SQL statements do in flight. A read-only user can still run a huge query that locks a table. It can also pull thousands of rows with sensitive customer data. Native database roles do not rewrite matched fields in query results. If a table holds emails, phone numbers, card numbers, or national IDs, the query returns them. The chat model then processes those raw details inside the workflow prompt. Static credentials also sit stored inside the workflow tool settings. Anyone with edit rights on the workflow can use that database session.
Why runtime query controls matter for AI agents
AI agents do not run fixed scripts that you can review in advance. The chat model writes a brand new SQL query for every user prompt. A small change in a user question can trigger a bad query plan. Without runtime checks, you cannot pause a risky query before it runs. Teams need a way to check every statement after the agent writes it. They also need to mask emails and card numbers in query results. Rewriting matched fields in results keeps sensitive values out of the model context. Detailed logs of every tool call help teams see what the agent ran.
MySQL Access Governance + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev is an open-source proxy that runs as a sidecar for your MySQL. It reads plain queries, prepared statements, and cursors on the wire.
First, hoop.dev guardrails block banned actions before MySQL runs them. An AI Analyzer you configure can score intent, and hoop.dev data masking rewrites sensitive string columns in results. Every query and verdict goes to the resource audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Should I use the SQL Agent or a Tools Agent for MySQL in n8n?
Use a recent AI Agent node with a MySQL tool sub-node attached. From n8n 1.82.0, the agent type setting is deprecated and nodes work as Tools Agents.
How does an n8n agent connect to an MCP server for database tasks?
You attach a tool sub-node to the AI Agent node in your workflow. Besides built-in database nodes, n8n provides a registry of MCP servers as agent tools.
Why is a read-only MySQL user not enough for an AI agent?
A read-only role stops writes, but it still returns every column in a table by default. It does not rewrite emails, phone numbers, or card numbers in the query results.
Related guides
In this post