Connect an AI agent
Foir speaks the Model Context Protocol (MCP), the open standard that lets AI agents use external tools. Connect an agent, whether that is Claude Code, Claude, Cursor, or any other MCP-capable client, and it can work directly with your Foir workspace. It can browse your models, read and write records, manage media, run operations, and more.
Everything the agent does happens within your own access. It can never see or change anything you could not, and the same drafts and approvals rules apply as when you work in the console yourself.
The Foir MCP server
The hosted server lives at:
https://mcp.foir.dev/mcpYou do not run anything yourself. Connect your agent to that address and sign in.
Connect over OAuth (recommended)
Most agents connect with a sign-in flow, so you never paste a key.
For Claude Code:
claude mcp add --transport http foir https://mcp.foir.dev/mcpThe first time the agent uses Foir, your browser opens a Foir consent screen. Sign in and approve, and the connection is ready.
For Claude and Cursor, add a custom connector (Claude) or an MCP server (Cursor) pointing at https://mcp.foir.dev/mcp. Both walk you through the same browser sign-in.
When you approve, you grant the agent access up to your own level, never more. If you only want the agent to look rather than change anything, choose read-only access at the consent screen.
Choose a workspace and project
Your Foir account may span more than one workspace or project, so a fresh connection starts by helping the agent find its footing. Ask the agent to list your workspaces and projects, then tell it which one to work in, for example “use the Marketing project in the Acme workspace.” From then on, everything it does is scoped to that project until you switch. Switching is explicit and logged, so an agent never wanders into a context you did not send it to.
And an organization, if the project has them
If your project uses organizations, the agent can stand in one of them the same way: ask it to list the project’s organizations and name one, for example “use Dave’s Coffee in the Marketing project.” From then on it reads that organization’s rows, the rows of every organization nested under it and the project-shared tier, it writes only into that organization, and it touches nothing of any other organization’s. The row layer decides that, not the agent.
Standing in none is a position, not a gap. A context that names no organization is the project-shared view: the rows that belong to no organization. That is narrower than any one organization, not wider, so an agent there is not seeing “everything” — and if you ask it to count your users from that position it will answer honestly about a set that excludes every organization’s own. Ask it where it is standing (it will say, including “project-shared”) before reading a total as a fact about the project.
A key confined to one organization works the same way without any of this: it can only ever be that organization, and the agent will say so.
Connect from the command line
If you use the Foir CLI, foir mcp bridges a local agent to the hosted server. It runs a small proxy and defaults to the project configured in your repository.
Signed in, it acts as you. After foir login, foir mcp connects with a short-lived token minted from your session and renewed while it runs:
foir login
foir mcpThe agent is offered exactly the tools your roles allow, and a tool they do not is refused in the platform’s words. Everything it does is recorded against you. Signing out, or having your session revoked, ends the connection: the token is checked against your session on every call. foir mcp --read-only narrows the token to the tools that read.
Unattended, it uses a key you made. For CI jobs and scripts there is nobody to sign in, so set FOIR_API_KEY to an admin key made for the job, with the grants it needs. A key can be scoped and rotated independently of any person’s account:
export FOIR_API_KEY=foir_adm_...
foir mcpA publishable key will not work here, because the agent surface includes tools that change your content. --read-only narrows a token and not a key: mint a narrower key instead.
The CLI makes no key of its own. An older CLI minted one named Foir CLI when you selected a project, and foir mcp fell back to it. That key was made with no permissions, so the agent could do nothing with it. Nothing uses it now, and you can revoke it under your project’s API keys.
Build something, start to finish
Here is the whole thing end to end, against an empty project. Connect an agent, point it at the project, and ask:
Set up a blog for me. Create a Post model with a title, a slug, a rich-text body, a cover image, a publish date, and a draft/published state. Then write three posts about the history of typography and leave them as drafts.
The agent will list your existing models to see what is already there, create the model, then create the records. You will be asked to approve the changes it makes. When it finishes, open the console: the model is in your content types, and three drafts are waiting for you to read and publish.
Nothing about that is a demo mode. It is the same model and the same records you would have made by hand, and the API serving them is live the moment you publish.
What an agent can do
Once connected and pointed at a project, an agent can discover your content model by listing models and inspecting their fields, so it writes valid records without you explaining your schema. It can read and write records: search, fetch, create, update, duplicate, and publish. Writes land as drafts, and publishing and deletes are separate, deliberate actions. Depending on your permissions it may also reach media, operations, schedules, hooks and settings.
What any particular agent sees is filtered by the access of the person who connected it, so two people connecting the same agent to the same project can be offered different tools. A read-only connection sees only the read tools. If a tool you expected is missing, that is your own access speaking, not a gap in the agent.
Each tool is offered on the permission its work asks, and one permission never stands in for another:
- Listing models and reading a model’s fields take
models:read. Reading or writing a model’s records does not include reading its definition. An agent that writes records without it shapes each one from a record it can read, or from the errors a rejected write lists field by field. Give its role or keymodels:readto let it read the schema first. - Sign-in providers take
signinproviders:readandsigninproviders:write. - Who is in an organization takes
members:readandmembers:write. - Releasing takes the write of something a release carries: models, operations, settings, hooks, schedules, configurations, design tokens, roles, apps or auth clients.
A note on trust
Two of the rules here exist to protect your data from your own agent, which is worth stating plainly rather than leaving as mechanism.
An agent reads your content, and content can contain instructions. Anyone who can get text into a record — a user submission, an imported feed, a teammate — can attempt to talk to your agent through it. So:
- Consent decides the ceiling. What you approve at sign-in is the most the agent can ever do, no matter what it later reads or is told. Granting read-only means no instruction hidden in your content can turn into a write.
- Choosing a project is explicit and recorded. An agent cannot wander from the project you sent it to into another one, and every switch is written to your audit trail with your name on it.
Start new or shared connections with read-only access, and grant write access only to agents you would trust with the workspace.
Credits
Connecting your own agent does not spend AI credits. Credits pay for the models Foir runs on your behalf, and a connected agent brings its own model, so the tools it calls here are not billed as AI usage. Your agent’s own provider bills you for its model use in the usual way.
Fóir in the console does run on Foir’s models, so it spends credits from your workspace balance. If a Foir feature ever runs a model for you from a connected agent, that action will draw credits and will say so.