SIGN IN SIGN UP
payloadcms / payload UNCLAIMED

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.

0 0 282 TypeScript

feat(plugin-mcp): adds MCP context to req.payloadAPI (#14595)

- Adds `MCP` option to `req.payloadAPI`

Users can write a conditional to detect when the Payload API context is
'MCP' related.

```ts
import type { CollectionConfig } from 'payload'

export const Posts: CollectionConfig = {
  slug: 'posts',
  fields: [
    {
      name: 'title',
      type: 'text',
      admin: {
        description: 'The title of the post',
      },
      required: true,
    },

    // ... other fields
  ],
  hooks: {
    beforeRead: [
      ({ doc, req }) => {
        if (req.payloadAPI === 'MCP') {
          doc.title = `${doc.title} (MCP Hook Override)`
        }
        return doc
      },
    ],
  },
}
K
Kendell committed
860bdf2b448541eb063c7c74c0dd45b4bdf7a1aa
Parent: 6070d8d
Committed by GitHub <noreply@github.com> on 11/13/2025, 7:19:05 PM