documentation: Knowledge note for the agents module (MCP access, suggestions, run history)
Back to our planType
documentation
Summary
Write the short note that explains how the neighborhood agents reach the site: through one MCP address with an admin-issued key, what they may read, how a suggestion becomes a draft for an editor, and how their runs and review items are kept.
Problem
Agent access spans the official MCP plugin, two custom tools, three collections and rules in other modules (review queue, password sign-in). Nothing in one place says what an agent can and can't do, or how a suggestion's fields are filled.
What the generated reference already shows, so the note doesn't repeat it: agent-runs, opens in a new tab, agent-review-items, opens in a new tab and payload-mcp-api-keys, opens in a new tab list fields, access functions and hooks. They don't say what the MCP view hides, how a suggestion is built, or which identity fields are write-once.
Proposed fix
Write src/modules/agents/README.md from the template. Owner's direction for every note (2026-11-06, Claude session, recorded on #712 and #719): a note explains the behavior and logic of its content types and code (what shows, where, when, who publishes or changes it, and the special rules), never a list of fields; and every link between fields is stated near the top, so no agent has to work it out from the code.
Links between fields the note states up front (each one checked in the code first):
- A suggestion's categories are found by slug (an unknown slug is refused, never created), and its image is the first category's
defaultImage, or its parent's (cms/tools/submitSuggestion.ts, #363; the field lives in news'scategories). - The suggestion's Markdown becomes the collection's rich text, with
<Chart>and<FactTabs>tags read by the rich-text converters (cms/tools/submitSuggestion.ts,src/platform/richtext/editorial/*Markdown.ts). - Card text: a post's suggestion fills its search-engine description and share image, an event's its description (
cms/tools/submitSuggestion.ts). externalIdandcontentHashidentify an item so the same one is never stored twice (domain/suggestion.ts,src/platform/payload/reviewQueue.ts).- A run's and a review item's agent is set by the server from the key's account;
RUN_IDENTITYfields are written once and kept on later updates (cms/agentRuns.ts,domain/runs.ts). - What an agent sees is each collection's allowlist in
cms/agentViews.ts, checked against the generated types; related documents become ids andmetakeeps only title and description (domain/agentView.ts).
Behaviors and rules the note must cover (each with the file or test named):
- Agents use Payload's official MCP plugin at
/api/mcpwith a key acting as an agent account; collection access decides what they may do (cms/mcp.ts). - Keys are admin-only, each tied to an agent account; the key's account must still be an agent at each request (
cms/apiKeys.ts,cms/mcp.ts). - Limits: per connection before the key is looked up, then per key per minute, 429 past either (
domain/mcpLimits.ts); counted in memory. - Every MCP answer is rebuilt from the allowlisted view, so no personal data reaches the model (
cms/mcp.ts). submitSuggestionstores a draft held assuggestedfor staff review (holdSuggestions), never published; the title cap is the only length guard on a draft (#633,domain/suggestion.ts).reportItemadds one document per report under the agent's own run; it never changes the content it points at (cms/tools/reportItem.ts,cms/agentReviewItems.ts).- An agent sees only its own runs, which is how it resumes from its cursors (
cms/agentRuns.ts,cms/tools/runs.ts). - Tool arguments follow the agents' contract in
intelligence/schemas/(cms/tools/schemas.ts). - Where it meets other modules:
src/payload.config.ts(plugin, collections), accounts (no password sign-in for agents), the review queue insrc/platform/payload/.
Tests to name under "Rules and the tests that protect them": domain/agentView.test.ts, domain/suggestion.test.ts, cms/tools/schemas.contract.test.ts, and src/payload.config.agentAccess.test.ts, agentTools, agentProbes, agentSuggestionCards, agentMigration, chartSuggestion, factTabsSuggestion.
Map entry: { "note": "src/modules/agents/README.md", "paths": ["src/modules/agents/**"] }
Acceptance criteria
- Not done:
src/modules/agents/README.mdfollowsdocs/knowledge/note-template.mdand is at most 80 lines. - Not done: It explains behavior and logic, not fields: no field lists, props tables or route lists. It links the generated pages named above for those.
- Not done: Right after its opening sentences, a short list states every link between fields named above (relationships, values copied or derived, mapper inputs and the props they become, hooks that copy a value), each with its file.
- Not done: Every behavior listed above is covered or, if the code turns out different, the note says what the code does and this issue gets a comment saying what changed.
- Not done: Every statement names the file or test it comes from, checked against the code at the branch's base.
- Not done:
docs/knowledge/index.mdgets one short line for the note (a few words after the link). It stays within the budget check. - Not done:
docs/knowledge/map.jsongets the entry above. - Not done:
npm run agent-context -- --writehas been run and its generated rule committed, andnpm run agent-contextpasses. If the budget check fails, this issue is not done; trimming other always-loaded files is not part of this issue. - Not done: Known contradictions: none of #279, #158, #366 or #531 applies to this module.
- Not done: No code changes. A bug or gap found in the code goes under the note's "Known gaps" and is filed as its own issue (labeled
scope-creep, linked here). - Not done:
Prettier,Knowledge sync,PR PolicyandAgent contextpass.
Files likely touched
src/modules/agents/README.mddocs/knowledge/index.md(one line)docs/knowledge/map.json(one entry).claude/rules/generated/src--modules--agents--README.md
Must not touch
- Code under
src/(the note itself excepted): this issue documents behavior and changes none. - Other notes, their generated rules, and the files the other note issues under #712 list.
docs/knowledge/note-template.mdand the session-start set (CLAUDE.md,AGENTS.md,docs/guidelines/guard-rails.md).docs/architecture/data-model.md,docs/ui/data-types.md,docs/ui/component-set-modules.md: read them and fold this area's facts into the note (decision 0019, section 7); report any drift in them in a comment on #712 instead of editing them, since every note issue reads them.src/modules/README.md,src/platform/README.md,docs/project.md(#725 owns them).
Open questions
- Session-start room. The index line needs room at session start, which #799 makes. This issue is blocked by #799 and is not Ready until it lands; the line then stays within the budget check.
- Dead code first. #728 (the audit, waiting for the owner's keep-or-drop marks) removes unused or unwanted code before a note describes it. This issue is marked blocked by #728; it can start once #728 has settled this area, even if other areas are still open there.
- Size: not set; a cloud session can't read the board. Suggested: M.
Area
tooling, cms
Priority
medium
Generated by Claude Code, opens in a new tab