This plugin adds Model Context Protocol capabilities.
find, create, update, and delete operations for each collectionInstall 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. |
| | Disable the MCP plugin while keeping database schema consistent. |
| | A function that allows you to override the automatically generated API Keys collection. |
| | 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. |
| | The base path for the MCP server (default: '/api'). |
| | Whether to log verbose logs to the console (default: false). |
| | The maximum duration for the MCP server requests (default: 60). |
| | 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'). |
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 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.
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.
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 addtional 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.
The description you choose to use for your collection greatly impacts the way a model will decide to use it.
The description in this example is more difficult for a model to understand it's purpose.
The description in this example gives a model a stronger ability to know when to use this collection.