Least-Privilege Access for an AI Agent on a Hosting API
Systems Architecture
What does this project do?
It gates a hosting provider’s full API so that an AI coding agent is able to read through it and has to ask before changing anything. Hostinger publishes a Model Context Protocol server that exposes its hosting, domain, DNS, billing, mail, and server APIs as tools an agent is able to call. I built the layer around it: a classifier that sorts every tool by what it can do, a generated allowlist that lets the read-only tools run and stops everything else for a human decision, and a harness that verifies each server with a real call before it is trusted.
This page covers the access pattern, its measured cost, and what the work found along the way.
Why is a hosting API dangerous to hand to an agent?
Because the same connection that reads a list of websites also deletes one. The tool surface covers actions that overwrite a live web root, change DNS records, and place billable orders, and nothing in the protocol distinguishes those from a harmless lookup. The agent sees a flat list of names.
The account behind this work holds several sites. The static deploy tool replaces the contents of a web root with an uploaded archive and has no undo. A deploy aimed at the wrong site destroys that site, so every deploy in this project begins by listing the account’s sites and confirming the target, and no state-changing tool runs without my approval for that specific call.
How do you classify hundreds of tools by risk?
By the verb in the tool’s name, with a default that fails closed. Each tool name carries a namespace prefix and then a verb, as in a tool that lists orders or one that deletes a record. The classifier holds a vocabulary of verbs sorted into three classes: read-only, state-changing, and destructive or billable. It takes the leading verb from each name and assigns the class.
A name that matches no known verb is classified as destructive or billable. An unfamiliar tool is therefore treated as the most dangerous kind until a person looks at it.
Run against the live tool list in September 2026, the classifier sorted 382 tools: 163 read-only, 152 state-changing, and 67 destructive or billable.
How is the allowlist enforced?
A script generates the agent’s permission settings from the classification. Every read-only tool is written into the allow list by its full name, which gives 163 entries. After generation, every entry was classified again from its own name, and each came back read-only.
Everything not on the list prompts. The agent is able to ask for a state-changing call, and the request stops for my decision each time. The deny list is left empty on purpose. A deny entry blocks a tool outright, and the goal is a gate that a person can open for one call, not a wall.
Why is listing a server’s tools not proof that it works?
Because the tool list is produced locally and does not touch the provider. During this work every tool listed correctly with a placeholder in place of the API token. A server that enumerates its tools has proven that it started, and nothing about whether it can authenticate.
The verification harness therefore requires three things from each server: a completed initialization, a non-empty tool list, and one successful read-only call that takes no arguments. The probe call is chosen automatically, and names containing words such as token, secret, password, credential, payment, or card are excluded from the choice. An earlier version of the probe would have called the listings for API tokens and payment methods, which is how that exclusion came to exist.
Of the 11 servers the protocol package splits into, 9 passed with a real read-only call and 2 exposed no tool the probe could safely call, so they are recorded as listed and not as verified. None failed.
What does per-area permission cost?
Splitting the API into one server per area is what makes fine-grained permission possible, and it has a price in memory. Running all 11 servers took 11 processes and 930 MB, about 85 MB each, with a cold start of 6.1 seconds for the set. For a workstation that is acceptable. It is a figure to know before copying the pattern onto a small machine.
The gates and the host each produced a surprise
The harness once reported a failure that was my own bug. A broad exception handler caught a programming error in the harness and presented it as a well-formed server failure. The fault was fixed, and the run that exposed it is kept in the evidence as a stopped task.
A credential scan in the same repository was written after a git init in a working folder nearly staged two live configuration files. It was designed so that it cannot leak what it finds. Its finding record has no field for a secret’s value, only for its location and class. The scan fails only when a live secret sits in a file that the repository’s ignore rules do not cover.
The host alters uploaded images. It re-encodes PNG files without loss and JPEG files with loss, and serves WebP files byte for byte. A comparison of bytes after a deploy fails on the re-encoded files, so the publisher compares PNG files by their pixels and JPEG files by a signal-to-noise threshold.
Where does the pattern stop?
The classification reads names, not behavior. A tool whose name begins with a read verb and changes state would be allowed. The fail-closed default covers unknown verbs, not misleading ones. The second limit is that an allowlist governs one agent on one machine. The API token itself still carries full authority, and the allowlist does nothing to limit it.