This plugin adds Model Context Protocol capabilities.
find, create, update, and delete operations for each collectionfind and update operations for each globalInstall the plugin using any JavaScript package manager like pnpm, npm, or Yarn:
In the plugins array of your Payload Config, call the plugin with options:
Option | Type | Description |
|---|---|---|
| | An object of collection slugs to use for MCP capabilities. |
| | An object of collection slugs to use for MCP capabilities. |
| | A description for the collection. |
| | A function that allows you to override the response from the operation tool call. |
| | Determines whether the model can find, create, update, and delete documents in the collection. |
| | Whether to allow the model to find documents in the collection. |
| | Whether to allow the model to create documents in the collection. |
| | Whether to allow the model to update documents in the collection. |
| | Whether to allow the model to delete documents in the collection. |
| | An object of global slugs to expose via MCP. Globals only support find and update. |
| | A description for the global shown to models. |
| | A function that allows you to override the response from the operation tool call. |
| | Determines whether the model can find or update the global. |
| | Whether to allow the model to read the global. |
| | Whether to allow the model to update the global. |
| | Disable the MCP plugin while keeping database schema consistent. |
| | The users collection that API keys are associated with. Defaults to |
| | A function that allows you to override the automatically generated API Keys collection. |
| | Replace the default Bearer-token / API-key auth with a completely custom access strategy. |
| | MCP options that allow you to customize the MCP server. |
| | An array of tools to add to the MCP server. |
| | The name of the tool. |
| | The description of the tool. |
| | The handler function for the tool. |
| | The parameters for the tool (Zod schema). |
| | An array of prompts to add to the MCP server. |
| | The name of the prompt. |
| | The title of the prompt (used by models to determine when to use it). |
| | The description of the prompt. |
| | The handler function for the prompt. |
| | The arguments schema for the prompt (Zod schema). |
| | An array of resources to add to the MCP server. |
| | The name of the resource. |
| | The title of the resource (used by models to determine when to use it). |
| | The description of the resource. |
| | The handler function for the resource. |
| | The URI of the resource (can be a string or ResourceTemplate for dynamic URIs). |
| | The MIME type of the resource. |
| | The handler options for the MCP server. |
| | Whether to log verbose logs to the console (default: false). |
| | The maximum duration for the MCP server requests in seconds (default: 60). |
| | Callback invoked for every MCP event. Useful for analytics and audit logging. |
| | The server options for the MCP server. |
| | The server info for the MCP server. |
| | The name of the MCP server (default: 'Payload MCP Server'). |
| | The version of the MCP server (default: '1.0.0'). |
Step 1 — Enable in your config
Add the collection or global to the plugin with enabled: true (or a capabilities object):
Step 2 — Allow in the API Key
In your Payload admin panel, navigate to MCP → API Keys, create a new key, and toggle the individual capabilities on for each collection, global, tool, prompt, and resource you want that key to be able to use.
All MCP requests must include a valid API key as a Bearer token — requests without one are rejected immediately. Here is a complete example of an MCP tools/list request showing the correct headers:
Access controls are also enforced at the Payload level using the user associated with the API key, so existing collection access rules, hooks, and multi-tenant restrictions all continue to apply.
After installing and configuring the plugin, you can connect apps with MCP client capabilities to Payload.
http://localhost:3000/adminMCP Clients can be configured to interact with your MCP server. These clients require some JSON configuration, or platform configuration in order to know how to reach your MCP server.
Our recommended approach to make your server available for most MCP clients is to use the mcp-remote package via npx.
Below are configuration examples for popular MCP clients.
For connections without using mcp-remote you can use this configuration format:
The MCP Inspector is the recommended way to explore and test your MCP server interactively:
Open the inspector, set the URL to http://127.0.0.1:3000/api/mcp, and add an Authorization: Bearer MCP-USER-API-KEY header.
You can also test directly with curl:
The plugin supports fully custom prompts, tools and resources that can be called or retrieved by MCP clients. After defining a custom method you can allow / disallow the feature from the admin panel by adjusting the API Key MCP Options checklist.
Globals are singleton configuration objects (e.g. site settings, navigation). The plugin exposes them as find and update tools — one tool per global per operation.
This produces two MCP tools: findSiteSettings and updateSiteSettings. Globals do not support create or delete because they are singletons managed by Payload.
Prompts allow models to generate structured messages for specific tasks. Each prompt defines a schema for arguments and returns formatted messages:
Resources provide access to data or content that models can read. They can be static or dynamic with parameterized URIs:
Tools allow you to extend MCP capabilities beyond basic CRUD operations. Use them when you need to perform complex queries, aggregations, or business logic that isn't covered by the standard collection operations.
Every tool handler receives (args, req) where req is the full Payload PayloadRequest object. From it you have access to:
Property | Description |
|---|---|
| The initialised Payload instance — use it to call |
| The authenticated user making the request (the MCP API key owner). |
| The active locale, if localisation is enabled. |
| Incoming request headers. |
Always pass req through to Payload operations and set overrideAccess: false so the request inherits the API key owner's access control rules.
selectAll collection and global tools accept an optional select parameter. It limits which fields are returned in the response, which can significantly reduce token consumption when working with large documents.
select is a JSON string that follows Payload's Select API syntax — set a field to true to include it:
For example, to list only post titles:
Without select, the full document is returned for every result. On collections with many fields or rich text, this can exhaust a model's context budget quickly.
Use overrideResponse on a collection or global to intercept what is sent back to the model after any operation. This is the primary place to sanitize sensitive data.
Payload adds an API key collection that allows admins to manage MCP capabilities. Admins can:
Allow or disallow endpoint traffic in real-timeAllow or disallow tools, resources, and promptsYou can customize the API Key collection using the overrideApiKeyCollection option:
You can create an MCP access strategy using the overrideAuth option:
If you want the default MCPAccessSettings, you can use the additional argument getDefaultMcpAccessSettings. This will use the Bearer token found in the headers on the req to return the MCPAccessSettings related to the user assigned to the API key.
To understand or modify data returned by models at runtime use a collection Hook. Within a hook you can look up the API context. If the context is MCP that collection was triggered by the MCP Plugin. This does not apply to custom tools or resources that have their own context, and can make unrelated database calls.
In this example, Post titles are modified to include '(MCP Hook Override)' when they are read using MCP.
When your Payload config has localization enabled, all collection and global tools automatically include locale and fallbackLocale parameters — no extra plugin configuration is required.
Parameter | Description |
|---|---|
| Retrieve or write data in a specific locale (e.g. |
| The locale to use when the requested locale has no translation for a field. |
Example — find posts in Spanish with English as fallback:
Use the onEvent callback to receive a notification for every MCP request processed by your server. This is useful for analytics, audit logging, or debugging.
Virtual fields (computed, read-only fields) are automatically excluded from the create and update tool schemas. They cannot be set by a model, so including them in the schema would be misleading and add noise. They are still present in find responses.
There are several levers for reducing the number of tokens consumed per MCP request. Token efficiency matters because large responses can exhaust a model's context budget, slow down responses, and increase cost.
The description you provide for a collection or global is the primary signal a model uses to decide which tool to call. A vague description leads to missed or incorrect tool calls; a precise description gets the right tool called on the first try.
select to return only the fields you needBy default, the full document is returned for every operation. On collections with many fields, rich text, or deeply nested relationships this can be very large. Pass a select JSON string to limit what comes back:
See Reducing Token Usage with select for more detail.
overrideResponseIf a collection has fields that are irrelevant or sensitive for the model's task, strip them before the response leaves the server. Fewer fields returned means fewer tokens consumed on every call.
See Modifying Responses for examples.
If a model only needs to read data, enable only find. Every additional operation (create, update, delete) adds more tools to the model's context, which costs tokens and increases the chance of an unintended action.