PHP calls the query layer directly. The content API calls it over HTTP, as JSON under /api/mainstay, and an MCP server at /api/mainstay/mcp calls it as tools a language model can use. All three go through the same operations, which find the type, make the call as the caller and shape the answer, so a rule written once holds on each of them. What the API adds is the question of who is calling.
Public by declaration
A request with no token reads only the types marked #[PublicRead]: their published entries or their global, never an internal field, and nothing is written. Every other type answers only to a token. It decides the API alone: the site's own pages serve every type, since the public sees those as HTML anyway.
#[PublicRead]
#[Route('/blog/{slug}')]
class Article extends Entry
{
}
The rule for nobody is in Mainstay's Gate, not in a policy. A site's own policy that answered yes for a missing user could otherwise open a private type to the internet; this way it cannot.
A token's capabilities
An account makes a token from its account menu in the admin, or one is made for it on the server with php artisan mainstay:token, and its capabilities are chosen from what the account holds. It can never choose one the account could not hand out, the rule a role already keeps. When the token is used, the account is read with the token's list as a limit, and a capability has to be held by both. Take a capability off a role and every token of its accounts loses it at once, so a token cannot outlive what its account was trusted with. A token with no capabilities holds nothing: it reads, but never an internal field, and writes nothing; * is everything the account holds.
A token is kept in mainstay_tokens as the SHA-256 of its secret, which is shown once. Every secret starts with mst_, so a person or a secret scanner knows one when they see it.
Over HTTP
The REST API takes the bearer token and answers in JSON, every payload described by a JSON Schema derived from the declared classes:
Entries are created, changed and moved to the trash under the same paths, and drafts are saved and published under /api/mainstay/drafts. php artisan mainstay:typescript writes the schema out as TypeScript declarations for a front end. A read nests what its relations point at wherever they are pointed at, so depth multiplies what one request makes the server write: it is capped at 3 with a token and 1 without, and a page holds at most 100 entries. A mistake in the request, such as an operator where does not take, is a 422 naming it.
Over MCP
The MCP server is built on laravel/mcp rather than hand-written JSON-RPC, because the protocol keeps being revised and laravel/mcp tracks it. Its tools are the same operations: list-types and describe-type, find-entries, get-entry, get-entry-by-path and get-global, save-draft, get-draft, publish-draft and discard-draft, and create-entry, update-entry, trash-entry and save-global. They are resolved per request, so the types a tool offers are the ones its caller may use.
The server's instructions tell an agent to write a draft and let a person publish it, unless it was asked to publish. Capabilities make that more than advice: an agent given a token that edits and does not publish writes drafts, and its publish is refused, naming the capability it lacks. That is the safe default for letting a model help with a site's content, and it needs nothing beyond the roles and tokens every account already has.
What is not in it
Revisions, owners, the front page, media uploads and accounts are not in the API. Moving an entry to the trash is, but browsing or restoring the trash is not.