Giving a support agent your data without giving it your database
An agent that cannot read your systems can only apologise. Here is how to expose real data through MCP tools with a boundary you can actually defend in a security review.
Jesbin James
Engineering
There are two kinds of support bot. One can see the customer's order and one cannot. Everything else, model choice, prompt quality, channel coverage, matters far less than which of those two you have built.
The uncomfortable part is that connecting an agent to production data is exactly the thing your security team is right to be nervous about. So the design question is not whether to give the agent access, it is how to give it access that is enumerable, revocable, and auditable.
Tools, not queries
The tempting shortcut is to hand the model database credentials and let it write SQL. Do not. You get an agent whose capability surface equals your schema, which means every new table is a new thing it can read and no review can keep up.
Instead expose a small number of named tools, each answering one question the agent is allowed to ask. The Model Context Protocol is a reasonable way to do this because the tool list is explicit and inspectable rather than implied.
{
"name": "get_order_status",
"description": "Return the current status of one order belonging to the authenticated customer.",
"inputSchema": {
"type": "object",
"properties": {
"order_id": { "type": "string", "description": "Order identifier" }
},
"required": ["order_id"]
}
}Note what the schema does not contain: a customer ID. The agent should never get to choose whose data it reads.
Bind identity at the edge, not in the prompt
The single most common mistake in agent integrations is passing the customer identity as a tool argument. The moment it is an argument, it is something the model can be talked into changing, and a customer who works out that the bot will read any order ID has found a data breach, not a bug.
The conversation already knows who it is talking to: on WhatsApp it is the verified phone number, in an in-product chat it is the session. Resolve that to an internal customer ID at the server boundary and scope every tool call to it.
# The agent asks for order 10042.
# The server decides whose order 10042 may be read.
async def get_order_status(order_id: str, ctx: ToolContext):
customer_id = ctx.session.customer_id # from the verified channel identity
order = await db.fetch_one(
"SELECT status, carrier, eta FROM orders "
"WHERE id = $1 AND customer_id = $2",
order_id, customer_id,
)
if order is None:
return {"found": False}
return dict(order)That AND customer_id = $2 is doing more security work than any amount of prompt instruction ever will. A prompt is a request. A WHERE clause is a rule.
Return the minimum
- Select columns explicitly.
SELECT *on a customer table eventually returns a password hash, an internal risk score, or a note from an agent that was never meant to be read aloud. - Strip internal fields before they reach the model. If the agent can see it, assume a customer can eventually get it repeated back to them.
- Return structured values, not prose.
{"status": "in_transit", "eta": "2026-08-14"}lets the agent phrase the answer; a pre-written sentence fights with it. - Say 'not found' the same way for missing records and forbidden ones, so the tool cannot be used as an existence oracle.
Separate reads from writes
Reads are recoverable. Writes are not. Issuing a refund, cancelling an order, and changing a delivery address are all things an agent can be argued into by a sufficiently persistent customer.
Keep write tools out of the agent's hands where you can, and put them after the agent node as deterministic steps with their own conditions. Where a write genuinely has to be agent-initiated, bound it server-side: refunds under a fixed amount, within the policy window, at most once per order, logged with the transcript that produced them.
Log the call, not just the answer
When an agent gives a wrong answer, the transcript alone will not tell you why. You need the tool calls: what it asked for, what came back, in what order. Nearly every 'the AI hallucinated' incident we have looked at was actually a tool returning an empty result and the model filling the silence.
- MCP
- Security
- Integrations
Jesbin James
Engineering
Writes about integrations, agent tooling, and the parts of the WhatsApp Cloud API that only show up in production.
Keep reading
- Engineering
Connect your systems without glue code: MCP, APIs, databases
How RoutMe reaches your data without glue code: MCP servers, your own APIs and read-only database views. What each is, when to use it and how to keep it safe.
- Engineering
Your webhook will be delivered twice. Plan for it.
Duplicate deliveries, out-of-order events, and the 20-second timeout are not edge cases on the WhatsApp Cloud API. They are Tuesday. Here is the handling that keeps them boring.
See it on your own data
Connect a system, drop an agent node into a flow, and watch it answer from what is actually true in your systems right now.