How to Configure OpenHands CockroachDB MCP Server
You set up an openhands cockroachdb mcp server by linking an agent to a database role. You pass a database URL to the local MCP process inside the agent settings. Most engineering teams start by handing the agent a shared root login. This quick setup lets the agent read tables, change schemas, and run queries right away. Yet broad database permissions create high risks when an autonomous coding agent makes a mistake. A single bad prompt can cause the agent to drop tables or read private rows.
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 openhands cockroachdb mcp server by linking an agent to a database role. You pass a database URL to the local MCP process inside the agent settings. Most engineering teams start by handing the agent a shared root login. This quick setup lets the agent read tables, change schemas, and run queries right away. Yet broad database permissions create high risks when an autonomous coding agent makes a mistake. A single bad prompt can cause the agent to drop tables or read private rows.
How the openhands cockroachdb mcp server workflow works
OpenHands runs as an autonomous coding agent inside a local container or workspace. It uses the Model Context Protocol to talk to external tools and data stores. The CockroachDB MCP server sits between the agent runtime and your distributed SQL cluster. When the agent needs schema details, it sends a tool call to the MCP server. The MCP server translates that request into a standard SQL statement for the cluster.
To set this up, you first create a dedicated SQL user inside your cluster. You grant this user specific table privileges based on the tasks the agent will run. Next, you store the cluster login details inside the host workspace settings. You then register the MCP server entry inside the agent config file. When OpenHands boots up, it starts the MCP server process and opens a database session. The agent can now inspect tables, check indexes, and test queries during coding tasks.
Scoping database roles for autonomous coding agents
A safe setup starts with strict SQL role limits inside the database cluster. You should never give an autonomous agent an admin role or full write permissions. Instead, create a read-only role that only sees public schemas and test tables. If the agent must write data, restrict that role to a staging schema. You can also set cluster statement timeouts to stop slow queries from locking nodes.
Network rules add another layer of safety for your database cluster. You should restrict the cluster allowlist to known IP addresses from your agent host. Always require encrypted TLS sessions between the MCP server process and the database nodes. Rotate the agent database password on a regular schedule to limit key exposure. Store those keys in host secret files rather than plain text workspace files.
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
Native SQL roles and network rules control which process can log into the cluster. They do a great job of blocking outside attackers and limiting broad schema access. If an agent only has read rights, it cannot delete rows or drop tables. These built-in controls form the base of any safe agent database setup.
Still, static database roles only check who logs in at the start of a session. They do not inspect what each SQL statement does while the session runs. If an agent has read access to a customer table, it can pull every row. Native roles will not rewrite sensitive fields like emails, phone numbers, or card numbers. A shared agent role also makes audit logs hard to read during an incident. Every query in the cluster log shows the same generic agent user name. Teams cannot tell which developer prompt or task triggered a specific database query. Also, an agent with write rights in a test schema can still run destructive commands. Static grants cannot pause a risky drop command to ask a human for approval.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
What permissions does an OpenHands agent need in CockroachDB?
Start with read-only permissions on specific non-production tables and views. Only grant write or schema change rights inside isolated dev or staging databases.
Can the MCP server limit sensitive customer data in query results?
No, the standard MCP server returns every column the SQL user can read by default. To hide emails, phone numbers, or national IDs, you need data masking in flight.
How do you stop an agent from running slow queries?
Set a short statement timeout on the SQL role used by the MCP server. The cluster will cancel any query that runs past your time limit.
Related guides
In this post