Issue 336
enhancement: Agent access to the CMS through Payload MCP, least privilege, with run history
Back to our planDone
enhancementcmsauthpriority: high
Type
enhancement
Problem
The neighborhood intelligence agents (#255) need a safe way to read the site's content and submit suggestions into the CMS. Summary of the owner's direction (2026-10-24, Claude Code session, text):
He wants the CMS to work in the agents' favor here, using its API or a Payload MCP if one exists (he wasn't sure it does). He asked the agents to make the decisions and keep things moving faster.
"At least we're going to have to have some kind of prompts, storing the data, moving the data to payload, being able to back up the data, and a CI/CD kind of thing."
Decision (ladder, #262)
- Native / official: Payload's official MCP plugin,
@payloadcms/plugin-mcp, opens in a new tab, serves/api/mcp, authenticates every request with an API key (Bearer), and grants each keyfind/create/update/deleteper collection. Each key acts as its owner user, so Payload's access rules still apply. That fits: no custom API. - REST with
auth.useAPIKeywould also work, but MCP is what agent runtimes (OpenClaw, Claude) speak, and per-key permissions are built in.
Proposed fix
- Role
agent(new, with migration): no admin panel, no publishing. Only admins create agent users and their keys. - MCP plugin, least privilege:
events,posts:findandcreate. A create by anagentis forced to an unpublished draft with moderation statussuggestedand required provenance (#123's fields).updateanddeleteare refused for agents.categories:find.agent-runs(new collection):createandupdateof the agent's own runs. Fields: agent name, started/finished, sources checked with cursors, counts (seen, proposed, rejected, duplicates), errors, cost. Admin-readable in Admin.- Responses use
selectso no user, email or form data reaches the model.
- Limits: a Caddy body limit on
/api/mcp(as for the form endpoints, #124), and a rate limit per key. - Backups: everything lives in the Payload database, which the existing daily and pre-deploy backups cover (#148).
- Tests: an agent key can't publish, can't update or delete, can't read users or form submissions, and a duplicate
externalIdis refused (accessPolicy.test.tsand request tests on in-memory SQLite, like #299).
Acceptance criteria
- Not done: An admin can create an agent user and an MCP key in Admin; the key never appears in the repo or in issues.
- Not done: Over
/api/mcp, an agent key can find events and posts and create a suggested draft, and nothing else (tests). - Not done: Run history is visible in Admin.
- Not done:
docs/project.mdandsecurity.mddescribe the role, the key handling and the limits.
Dependencies
- Builds on #123 (review-queue fields), stacked on it.
- Umbrella: #255. Parent epic: #161.
Area
cms, auth
Priority
priority: high
Generated by Claude Code, opens in a new tab