Applied AI ·Build

How do you let AI assistants into a system without handing them the keys?

A personal archive and a privacy and security test lab

People already paste company data into assistants, and connecting an assistant to the company's documents does save time spent searching. Every connection is also a new point of entry: it can expose a document, apply a change nobody approved, or send confidential text to an outside model. I put the rules in the system, not in the instructions given to the model: keys that can only narrow a user's access, changes as proposals a person approves, and a ceiling on what each model provider may receive. Then I tested them in a separate lab against a simulated assistant that obeys every instruction hidden in what it reads. On the hardened server, the leak was refused, the change waited as a proposal, and every step was logged.

Problem
assistants are being connected to business systems to look things up and draft changes, and each connection can expose documents, apply edits nobody approved or send confidential text to an outside model.
Deciding constraint
the assistant must never hold more authority than the person it acts for, and the instructions given to a model do not guarantee safety.
Choice
an MCP server whose rules are enforced by the system: narrow keys, shared access functions, changes as proposals a person approves, and a data ceiling per model provider.
Result
every rule has one enforcement point, and the system stays safe with no model attached.

The lab is public, with its tests and the command behind each of its figures: assistant-integration-review.

If this is your situation

If people already paste your system's data into an assistant, the question is no longer whether assistants get access but whether that access has rules. Start read-only with one narrow key, and add writes only as proposals a person approves.

Applied AI → discuss giving assistants access

For your technical team How it was diagnosed, the options rejected and why, what went wrong, and the decision record. About 12 min read

Context and scope

The case is a document archive for small businesses that assistants such as Claude reach through MCP (Model Context Protocol), the open protocol assistants use to call tools in other systems.

In scope: what an assistant can read, change and send onward, including when it has been misled by text in a document it reads. Out of scope: the assistant vendor's own handling of what it is shown, and prompt-level defences; neither is something the archive can enforce, so the design assumes the second one fails. Assumption: the person approving a proposal reads it.

Drivers

Constraints

  • Operated by one person, so rules must be kept in one place.
  • Documents carry different sensitivity, and some collections are records that may only be corrected.
  • Confidential material must not reach an external model by default.

Scenarios

  • When an assistant's key belongs to a user with narrower access, the assistant sees no more than that user. Measured by a test with a key that should see nothing.
  • When a document sits above a key's data tier, the answer is "not found", the same as for a missing one.
  • When an assistant proposes a change, its own key cannot approve it unless the operator has deliberately granted that key approval, and the commit then records who approved. Measured by a refusal (403) for a key without approval rights in the acceptance tests.
  • When shared files changed after a proposal was made, approval is refused as stale.
  • When a document is above a model provider's ceiling, it is not sent and the skip is logged.
  • When a document the assistant reads contains instructions, the assistant gains no authority from them: whatever it then attempts is refused, queued as a proposal or logged, exactly as if it had asked for it unprompted. Measured in a separate lab: a scripted assistant that obeys every hidden instruction, run against a deliberately weak server and one built to these rules.

Options against those drivers

  • Export data to the assistant

    Fits when
    a one-off question over a fixed set of documents.
    Breaks when
    the copy goes stale the next day and carries no access rules.
  • A read-only API

    Fits when
    the assistant only needs to look things up.
    Breaks when
    it cannot help with changes, and access is often all or nothing.
  • Chosen

    An MCP server with limits enforced by the system

    Fits when
    assistants should read and draft changes under rules you set.
    Breaks when
    you must build it, and every rule has to hold in one place.

Where each rule is enforced

Boundary Rule Enforced by Without it
Read A key can narrow its user's access, never widen it The shared access functions An assistant sees more than its user
Read Each document has a data tier and each key a ceiling; above the ceiling the answer is "not found" The access layer The existence of a document leaks, even if its text does not
Read One access path: the assistant's tools call the functions the web interface uses Code structure, plus a test with a key that should see nothing A second set of rules drifts out of step
Write Records that can only be corrected (invoices, contracts) refuse assistant writes, even with edit rights A hard rule in the save path An assistant overwrites a record
Write Changes to shared knowledge are proposals; a key cannot approve its own proposal unless the operator has granted it approval, and who approved is always recorded The proposal queue and the key's scope An unreviewed change reaches the archive
Write Approval becomes one commit by the approver, naming who proposed it; a proposal against changed files is refused as stale The write-back to the repository A blind merge, or an untraceable author
Egress Each model provider has a ceiling; a local model may receive anything, an external one only low-sensitivity material by default; above the ceiling the step is skipped and logged The tier gate Confidential text goes to a vendor
All Every assistant call is logged with the documents it touched The audit log No way to answer "what did it see?"

Everything also works with no model at all, so the safety argument never depends on one. Assistants connecting through OAuth receive a token that is an ordinary API key underneath, so the same tiers, audit and revocation apply.

Threats

Asset Threat Mitigation
Restricted documents An assistant reads above its user's access Narrowing-only keys, tiers, the single access path
Existence of a document Its presence is inferred from a "forbidden" answer "Not found" for anything above the ceiling
Records (invoices, contracts) An assistant rewrites a record Hard refusal in the save path
Any permission the assistant holds Text hidden in a document or tool result steers the assistant The assistant holds nothing beyond its key; writes are proposals; the egress ceiling and the audit log apply as if it had obeyed
Shared knowledge repository An unreviewed or forged change Proposals, approver authors the commit, stale proposals refused
Confidential text It reaches an external model Per-provider ceiling, skipped and logged
Accountability No record of what an assistant saw Audit log of every call
The approval step A reviewer approves without reading Not mitigated by the system; a recurring human task

How a change travels

The assistant never writes to the shared knowledge directly. It proposes, a person reads and approves, and the result is one commit in the repository (git). The approver is the author and the proposal records who made it. A key approves only if it carries the approval scope, which is off by default and works only for a user who may approve. The commit is authored by the approver and names the proposal and who proposed it, so a change is never anonymous.

Is this not what the assistant's own approval prompt already does? Most assistants can ask before every tool call, or approve calls automatically. That prompt protects the person at the keyboard, is set by them, and shows a call, not the change in its context; set to approve automatically, it protects nothing. A proposal protects the shared record: the system enforces it whatever the client is set to, and it is reviewed as a diff by someone who may own the record but did not make the call. The two answer different questions, so both stay. The friction is real when every change waits for a person. In the lab's queue, 100 changes waited for a person without approval by risk class and 20 with it, the low-risk ones applied by a key allowed to approve them. In the archive the approval scope is set per key; approval by risk class is the lab's.

How the decision is kept true

  • A test with a key that should see nothing, run against the shared access functions.
  • Acceptance tests for the proposal rules: pending state, the own-key refusal (403), one commit by the approver, stale refusal.
  • In a separate lab, an attack suite run against a weak server and a hardened one, and a pass/fail rubric with a test as evidence for each control (described below).
  • A regression test that starts the server with the web application, as it is deployed, added after the routing bug below.
  • The audit log, which answers "what did it see?" after the fact.
  • The same discipline guards a model step in a business process: known cases, a threshold and a regression gate, so a change that lowers accuracy is refused.

What the lab adds

The archive's tests cover its own rules. Hidden instructions needed something an archive test cannot give: an assistant that obeys them. So a small, separate lab was built: two MCP servers over an invented support desk, one deliberately vulnerable and one hardened, newly written to the same kind of rules (tiers answered as "not found", proposals instead of writes, no sending out above a tier, a per-key call cap, tool descriptions pinned after review). One attack suite runs against both.

  • A scripted assistant that obeys everything read two tickets with hidden instructions. On the weak server it sent a confidential record out and overwrote a runbook. On the hardened server the read came back "not found", sending was refused, the change became a pending proposal, and every step was in the audit log.
  • A real local model, OpenAI's open-weight gpt-oss-20b, read tickets written in plain prose that asked for the same attacks. It followed the send-out ticket in 2 of 17 runs on the weak server, and both times it succeeded. On the hardened server it never tried, so the hardened server was shown against a misled model by replaying that model's recorded calls. The lab's verdicts come from the scripted assistant and the system's own state, never from a model's behaviour.
  • A slow extraction, sixty small reads spaced out to stay under the per-minute rate limit, obtained all sixty records from the weak server and stopped at 24 on the hardened one, at its cap of 25 calls.
  • A tool's description changed after it was reviewed. An assistant decides how to use a tool from the description the server publishes with it. The lab's public notice board kept the name of its post_note tool and, after review, rewrote its description to tell the assistant to read a confidential record and post it as a note. Through a gateway that passes descriptions on unchecked, the assistant did exactly that, and the record ended up on the public board. A gateway that keeps each tool's reviewed description and compares it with the one the server now sends withheld the changed tool and logged the change; the board stayed empty.
  • The rubric: the weak server fails all ten controls and the hardened one, built to them, passes all ten, each with a test as evidence.
  • Through real clients: the hardened server's answers (a read above the key's level returned as "not found", sending refused, a proposal queued, a high-risk approval held for a person) were checked again through two third-party MCP clients, Claude Code and MCP Inspector.

Where it went wrong, and the risks that remain

A routing bug no test detected. The assistants' endpoint and the web application are served by the same server, and the web application answers any address it does not recognise with its own page, so that links inside it work. A request to the assistants' address without its final slash matched the web application instead, and the assistant received a web page. The tests started the server without the web application, so they all passed. It was found on a running server; a regression test now starts the server with the web application, as it is deployed. Test the system as it runs, not only its parts.

Risk Likelihood Impact Mitigation Owner
A tool bypasses the shared access functions Medium over time Rules silently skipped One access path; a test with a key that should see nothing Operator
Proposals are approved without being read High if the queue grows Unreviewed changes reach the repository Keep the queue short; the approver is recorded on every commit Approver
Many small calls extract data slowly or loop Medium Gradual exposure within the key's rights, or uncontrolled cost Result size bounded per call, the audit log shows the pattern, and the key can be revoked. A per-key cap of 25 calls stopped a spaced-out extraction at 24 of 60 records in the lab; the archive does not have one yet Operator
An external provider's data terms change Low Confidential text exposure Ceiling per provider, external low by default Operator

Rollout, operations and scale boundary

  • Rollout: the access rules for assistants were part of the archive's first design, not added to a finished system.
  • To run: issuing and revoking keys, the proposal queue, and reading the audit log.
  • To learn: the tiers, and which collections are records.
  • Governance, what an operator must own: who holds each key (built: every key belongs to a user and only narrows that user's access); revocation (built: revoking a key also ends its OAuth tokens); an audit of every call (built, hash-chained); and two things the build leaves to the operator: how long the audit log is kept, and a written procedure for rotating keys.
  • Scale boundary: the article is about where rules are enforced, not throughput.

Which model. The limits hold whichever model is connected, a proprietary one on the vendor's servers or an open one on your own: the provider sets only the ceiling, so confidential material goes to a model on your own hardware. Choosing the model is a separate question, about usefulness and cost.

On a different stack

The rules depend neither on the protocol nor on the language. The archive offers the same proposal rules over its REST API, described by an OpenAPI document, so an assistant that calls HTTP tools is subject to the same limits as an MCP client; MCP adds tool discovery and a key checked before the session starts. In .NET or any other stack the same enforcement points apply: one authorisation service that every tool calls, proposals in a queue with a separate approver, and a ceiling per outbound provider. What differs is the framework and where the identity comes from.

Applied AI → discuss giving assistants access

Where to start?

Describe the problem in a few minutes: what it is about, a little context and how to reach you.