Your keys, not a master key
25 October 2026
A client runs his whole company on databases he built himself over many years. Staff records, time sheets, customers, spread across three files. He wanted Claude to work in them directly. Read, write, change things, and eventually help him rebuild parts of the system.
The connection is the easy part. The protocol for it is called MCP, and a server that speaks it is a few hundred lines of code. The hard part is one question: when the AI writes something into the database, who is doing it?
The master key
My first version answered that question the lazy way. The server logged into the database with one technical account that could read everything. Then I added filters on top: these tables are blocked, these columns are hidden, these people may see more.
It worked. Then every request was about the filters. Someone needed a table I had blocked. Someone else should see less than the shared account allowed. I was rebuilding the database’s own permission system, badly, in a second place.
The database already knew who may see what. Every employee has an account. Every account has a role. Somebody had spent years getting those roles right.
The person’s own login
So the server stopped having an identity of its own.
When you connect Claude to it, a login page asks for your database username and password. The server checks them against the database and keeps them, encrypted, inside the token Claude holds. It stores no passwords anywhere else. Every call after that runs as you. If your role may not see salaries, Claude cannot see salaries. If your role may edit a time sheet, Claude can edit it, and the database records it as your edit.
Two rules stayed on top, for everyone. Password and API-key columns are hidden, even for the owner. And the account has to be on a short list before it may connect at all.
That is the whole permission model. The owner manages it where he always has, in the database.
Writing needs a brake
Reading is safe. Writing is where it gets interesting, so every write goes through three checks:
- Claude has to ask before it writes, and show what it is about to change.
- An update or delete only goes through if the search matches exactly one record. Zero matches or two matches, and nothing happens.
- Every write leaves one log line: who, which database, which table, which record, which fields.
The third one paid off quickly. The owner asked Claude to add an entry, got a success message, and could not find the entry. The API had answered 201 Created. The log showed exactly what was sent and where. The cause sat in the database setup, not in the server, and the log line pointed straight at it. A success code is a claim. The record is the proof.
The bug that was mine
Before that, a new account could not log in at all. “Username or password wrong”, every time, and the owner was sure they were right.
They were. My login check also looked the person up in the staff table, and a technical account has no row there. The database had said yes. My own extra check said no and reported it as a wrong password. I removed the lookup for accounts without a staff row and added a log line for every failed login. Now a refusal says which check refused.
One server for three databases
The company has three database files. I could have built three servers. I built one, where every tool takes the database as an argument.
One login, one address to add in Claude. And Claude can answer a question that needs two of the files without anyone switching connections.
Scripts and structure
This week I added the parts a developer needs: running the database’s own scripts, creating tables and adding fields. All three still run as the signed-in person. Changing the structure requires full access in the database, so for a normal account the request simply fails.
There is one gap, and it belongs to the database, not to the AI. A script can be marked to run with full rights no matter who starts it. Anyone allowed to start such a script gets those rights for the length of the script. The fix is a list of those scripts and a deliberate decision for each one before an AI account may run it.
I did not build deleting tables or fields. That one stays with a human and a backup.
What I would tell you
- Let the AI be the person. Do not give it an account of its own with a filter layer on top. Your system’s permissions are already there. Use them.
- Log every write in one line. You will need it sooner than you think.
- Make the destructive cases boring. Exactly one match, or nothing.
- When a login fails, say which check failed. “Wrong password” from the wrong layer sends everyone looking in the wrong place.
The whole thing runs on a Cloudflare Worker.
If your company runs on something old and solid, a database, an ERP, a system someone built in-house, this works the same way. I build these at supercharged.sh.