When someone asks JARVIS why a job is stuck, the answer lives in the Job Adding System, the system that keeps every job in step across the company's platforms. There were three ways to give an AI agent that answer: a database connection, an API key, or a short list of questions it's allowed to ask. I chose the list, and published it as an MCP server. MCP is the open protocol assistants use to call tools.

This post is about what it took to put that server in front of a production system that runs the business's automations, so that the agent gets real answers and production doesn't notice it's there. The other half of the picture, the gateway that holds every credential on the agent's side, is in An assistant that asks first.

Tools, not tables

The Job Adding System already had a staff console with its own assistant, Ask JAS. Behind it sits a catalogue of checks: small Python functions that each answer one question well. Why is this job stuck? Where is its network application? Which installs are booked next month, crew by crew? Each check declares its inputs as a JSON Schema and returns a verdict.

The MCP server is a thin layer over that catalogue. Every check that a non-administrator may run and that never writes becomes one tool: 36 today, in six families covering one job, applications and compliance, money, lists and reports, the automations, and reference. They are the same checks the staff use, run over the system's own records, so a question never sets off a live call to the accounting system, the CRM or the work boards.

That choice does a lot of quiet work. The agent can't write a query, so it can't write a slow one, or a clever one. It can't page through a table it was never meant to see. Every answer comes from code that already had tests and already served the staff. And the platforms behind the system never take an extra call because someone asked JARVIS a question.

Two checks stay out: the raw-table search and the system journal are for administrators in the console, and no AI client gets them. A third was dropped after a closer look. A documentation search turned out to open its store read-write and run schema statements on the way. It looked like a read. Read-only by construction means checking every tool, not trusting its name.

Every tool is also marked read-only and non-destructive in the protocol's own hints, so a client can tell at a glance. The hints are a courtesy, though. What makes them true is that the write action isn't in the list the server builds its tools from, and the code each tool calls is the read-only executor.

Answers as data, not prose

A tool returns structured verdicts: a status, a reason and the evidence behind it, with times stated in Sydney's time zone. It doesn't return an essay. That's for the model's sake as much as anyone's. A structured result is data for the agent to reason over, and where it carries something a person typed, such as a note on a job, that text sits in its own field. The agent can tell what the system concluded from what someone wrote, which matters when the someone could have written anything.

Inputs get the same care. Each tool advertises its check's own schema, tightened for an AI client: no properties beyond the ones declared, and every string capped at 120 characters. The connector also guards the inputs that would make one call fan out, such as how many words a name search may use and how many days a list may span.

Who is asking

Any server that answers an AI client has two jobs before it answers anything: know who is calling, and don't take the caller's word for what they may see.

There are two kinds of caller. One is a person, signed in with their own company account, whose token their client holds on their behalf. The other is a machine: an executive's JARVIS server, which signs in as itself, with an identity the cloud platform issues to that server and only the gateway on it can use. Either way, the connector verifies the token's signature, issuer, audience and expiry. It maps a machine to the one person it acts for, and checks that person against the same allowlist the staff console uses, on every call.

What a caller may see is a profile, and the system enforces it itself:

  • An executive's profile gets every tool.
  • A sales profile gets the sixteen tools about selling and job progress, and no money. Every price, deposit, invoice, margin and rebate amount is stripped from every result before it leaves, however deep it sits, including dollar figures inside sentences and any number a removed field held.
  • A caller whose entry names no profile gets the most restrictive one. A forgotten setting fails closed.

The client's gateway applies the same tool list as a second layer, but the system never relies on it. A misconfigured gateway can't widen what reaches anyone.

Turning a caller off is one line on the system's side and a restart. That matters more than it sounds. The identity platform caches a machine's tokens for up to a day, so taking its role away in the directory is a slow off switch. The fast one has to live in the system being protected.

How a question gets there

I didn't want to open anything new on the production server. A question from JARVIS takes this path:

  1. The agent calls a tool on a gateway on its own server. Its MCP entry carries no credentials at all.
  2. The gateway, running as a separate user, adds the credentials only it can reach, applies its own budget and tool list, writes an audit line and sends the request on.
  3. The edge network in front of production admits the request only if it carries that server's own token and comes from that server's address. Everything else stops there.
  4. The tunnel that already serves the staff console delivers it to the connector, which listens only on the production server's own loopback, verifies the caller and applies its limits.

I looked at two other routes. Peering the networks would have opened every port on production to the peered range unless a deny rule went in first, and it would have died with the planned move to containers. A mesh VPN would have been encrypted and simple, but it meant a new daemon running as root on the production box. The edge route needed no new software and no network change on production, it's encrypted end to end, and it survives the move to containers, because the route points at a name rather than a machine.

Four layers, so production never notices

The obvious worry was locking: an agent reading the same stores the automations write to. It isn't the real risk. Every store is opened read-only, with a short busy timeout and a hard abort. The real risk is load. The connector shares a machine with every automation and the staff console, and a client asking question after question could slow all of them. So the limits come in four layers, outermost first:

  • Behaviour. The workspace rules tell the agent to plan before calling, use a handful of checks per question, never fan out across sub-agents and never poll. It's courtesy only, which is why three layers follow it.
  • The client's budget. The gateway allows one call at a time, inside a per-minute, a burst and a daily budget. Heavy checks, the ones that scan or fan out, count three times.
  • The server's limits. The connector keeps its own windows per caller, a burst window, a global window across every caller and a daily cap, with the same weights. It caps input sizes and request bodies.
  • The operating system. The connector's service has hard caps on CPU, memory and processes, and a lower priority than the automations, so even a runaway check can't take more than its share of the machine.

Only the first layer depends on the model behaving. The other three would hold if it didn't.

Refusals an agent can read

A limit only helps if the client reacts to it sensibly. An HTTP 401 or 403 tells a client its sign-in failed, and a well-meaning client retries an auth failure, which is the opposite of backing off. So every refusal from the connector is a normal tool error, with a body written for an agent to read: the reason, the limit in words, and how many seconds to wait.

A few details make that hold up:

  • A refusal for bad input carries no retry time, because the same input will never pass.
  • A refused call still counts against the caller's budget, so a client looping on bad calls is throttled like any other.
  • Refusals are audited at most once per caller a minute, so a loop shows up in the log without flooding it.
  • The agent's own rules say what to do with one: stop, say so, and wait.

What I took from it

  • Give an agent questions, not tables. A catalogue of tested checks is safer, cheaper and more useful than a connection string.
  • Read-only by construction means checking every tool, not trusting its name.
  • Return data, not prose, and keep what people typed in a field of its own.
  • Decide what each caller sees inside the system being protected, fail closed, and keep the fast off switch there too.
  • Put every hard limit below the model. Rules for the agent are courtesy; budgets, caps and the operating system are the boundary.
  • Make a refusal something an agent can act on: a tool error with a reason and a wait, never an auth failure.