How to Configure LangChain MariaDB Approval
You set up a langchain mariadb approval step by pausing the agent before SQL runs. Your app holds the query, asks a human to check it, and then runs it. Teams often give AI agents a shared database role with broad read and write access. When that role is too wide, a bad prompt can alter rows or pull private data. Putting a review gate in the workflow helps, yet app code alone can fail. You need database rules and clear query checks working together. How to set up a langchain mariadb approval
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 langchain mariadb approval step by pausing the agent before SQL runs. Your app holds the query, asks a human to check it, and then runs it.
Teams often give AI agents a shared database role with broad read and write access. When that role is too wide, a bad prompt can alter rows or pull private data. Putting a review gate in the workflow helps, yet app code alone can fail. You need database rules and clear query checks working together.
How to set up a langchain mariadb approval workflow
In a standard setup, the agent turns a user prompt into a SQL query. It uses a database tool linked to a MariaDB login. Instead of running the query right away, the workflow pauses at the tool call. The app saves the state and sends the draft SQL to a reviewer.
A team member reads the query in a chat channel or a web app. If the reviewer clicks approve, the app resumes the agent loop. The database tool then sends the SQL statement to MariaDB and returns the rows. If the reviewer rejects the query, the agent stops or tries a safer path.
You also set up a specific MariaDB user for the agent. Database admins grant this role permission to read only the tables the agent needs. If the agent only answers reporting questions, you give it read rights on those tables. You leave out drop, alter, or delete rights from that database user.
What native controls solve and what they leave open
Database grants and app callbacks solve the first layer of risk. MariaDB roles decide which accounts can log in and which tables they can touch. App level pause steps let a human check a tool call inside that one app. Together, they stop random guests from logging in and catch clear mistakes in that workflow.
Still, this setup leaves a large operational gap during daily work. Database grants apply to the whole user account, not to one query at a time. Once an agent logs in with write rights, MariaDB runs any valid update on allowed tables. The database cannot pause a risky update on its own to ask a human.
Approval Chains & Escalation + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
App level callbacks only work inside the single script where you wrote them. If another builder writes a new script using the same MariaDB key, the check is gone. Also, standard database roles do not mask sensitive text inside allowed tables. If an agent reads a customer table, the query result includes raw emails and phone numbers. The model receives those raw fields unless another control rewrites matched fields in results.
Why static database keys hurt agent safety
Most agent tools read a static username and password from an app config file. Sharing that password across laptops and servers makes it hard to track who ran what. In the MariaDB logs, every query from every agent looks like the same database user. You cannot tie a bad query back to the person who triggered the agent.
Rotating that shared password also breaks running agents until you update every config file. Teams often put off password updates to avoid downtime. A safer plan removes raw database keys from the agent host and checks every query in flight.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL. It runs next to MySQL, RDS, or Aurora and reads the MySQL wire protocol.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails. When a rule refuses a query, MySQL returns a native error packet with your message. On the response path, hoop.dev data masking rewrites string values in returned rows that match your rules. Every query and decision is logged per resource. See the MIT-licensed project on GitHub.
Frequently asked questions
Can MariaDB pause a single query for human approval on its own?
No, MariaDB checks user permissions at login and table level. It runs allowed SQL right away and cannot pause a statement to wait for a chat approval.
Why is a read-only MariaDB user not enough for AI agents?
A read-only user can still read every row and column in an allowed table by default. Without field masking, the agent pulls raw emails, phone numbers, and card numbers into the model.
What happens if a developer forgets to add the callback in code?
If the approval check lives only in app code, skipping it lets the agent run SQL freely. Enforcing reviews outside the app code ensures every query gets checked.
Related guides
In this post