Skip to content
SprecherEast
Issue 336

enhancement: Agent access to the CMS through Payload MCP, least privilege, with run history

Back to our plan
Done
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)

  1. 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 key find/create/update/delete per collection. Each key acts as its owner user, so Payload's access rules still apply. That fits: no custom API.
  2. REST with auth.useAPIKey would 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: find and create. A create by an agent is forced to an unpublished draft with moderation status suggested and required provenance (#123's fields). update and delete are refused for agents.
    • categories: find.
    • agent-runs (new collection): create and update of 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 select so 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 externalId is refused (accessPolicy.test.ts and 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.md and security.md describe 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

See it on GitHub, opens in a new tab