How to Configure OpenHands MySQL MCP Server
To set up an openhands mysql mcp server, link your agent runtime to the database server. You supply database login keys to the server process so the agent can run queries. Most teams start by giving the agent a shared database user with full read rights. That fast setup works at first, but broad roles expose every table to your AI agent. How the openhands mysql mcp server architecture works OpenHands runs as an autonomous coding agent inside its own workspace container. When the agent needs d
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 an openhands mysql mcp server, link your agent runtime to the database server. You supply database login keys to the server process so the agent can run queries. Most teams start by giving the agent a shared database user with full read rights. That fast setup works at first, but broad roles expose every table to your AI agent.
How the openhands mysql mcp server architecture works
OpenHands runs as an autonomous coding agent inside its own workspace container. When the agent needs database facts, it talks to the Model Context Protocol server. The server translates agent tool calls into standard MySQL queries and sends them over the network. MySQL runs the query and sends the rows back to the agent workspace.
To make this work, engineers store a database host, user name, and password in the workspace. The server reads those stored values when it starts up. It opens a persistent session to your MySQL instance using that single database role. Every prompt from the agent shares that exact same database identity and permission set.
Setting up native MySQL roles for agent queries
A safer native setup starts inside your MySQL instance before you run the agent. Database admins create a dedicated MySQL user just for the coding agent. They grant read privileges only on specific tables instead of the whole database schema. If the agent must test migrations, admins point it at a scratch database instead of production.
Next, the team starts the MCP server inside the same network as the agent container. You register the tool server with the OpenHands runtime so the agent sees the database tools. When a user asks the agent to check a bug, the agent inspects the table list. It writes a SQL statement, calls the read tool, and reads the returned rows.
What native setup solves and what it leaves open
Native MySQL roles do a good job of stopping basic damage at the table level. A read-only database user stops an agent from dropping tables or deleting customer rows by mistake. Schema rules also block the agent from touching billing tables if you lock those down.
MySQL Access Governance + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, database roles only check who logs in at the start of a session. They do not inspect what individual SQL statements do while the session is active. If an agent has read access to a users table, it can pull every row by default. Raw emails, phone numbers, card numbers, and national IDs flow straight into the model context.
Static keys inside the agent workspace create another risk for engineering teams. Anyone who can read the container settings can take the database password and use it elsewhere. Also, native database logs only show that the shared agent user ran a query. You cannot tell which engineer or task triggered that specific query during a debugging session. Teams also lack a way to pause a risky write query for human approval in flight.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.
With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
How does OpenHands talk to a MySQL database?
OpenHands sends tool calls to a local or remote MCP server over standard transport channels. That server holds the database driver and runs SQL statements against your MySQL instance.
Should I give my coding agent write permissions in MySQL?
Only grant write permissions inside isolated test databases where lost data does not matter. For shared staging or production databases, stick to strict read-only roles or require statement approvals.
What happens if the agent queries a table with sensitive customer fields?
With a plain setup, MySQL sends all matching rows back to the agent workspace. Unless data masking rewrites matched fields in results, emails and card numbers enter the model prompt.
Related guides
In this post