-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: plugin mcp #13674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: plugin mcp #13674
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot here I don't really understand in our approach. It would be good to get more user feedback and validation or point to other systems that behave similarly.
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
| * @param str - The string to convert to camel case | ||
| * @returns The camel cased string | ||
| */ | ||
| export const toCamelCase = (str: string): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we do in other places already? This has to be redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this one in CPA https://github.com/payloadcms/payload/blob/d8a62b7022f9b5a007e0294a49b9e6dd03bee17d/packages/create-payload-app/src/utils/casing.ts
Your function is not the same and doesn't appear to cover as many characters combinations.
This isn't a blocker for merge, future cleanup.
| // Create the resource | ||
| const result = await payload.create({ | ||
| collection: collectionSlug, | ||
| data: collections?.[collectionSlug]?.override?.(parsedData, req) || parsedData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this just be done in a beforeChange because it is unclear where the plugin "override". We need a way to identify in your hook if the request is made over MCP.
Do we extend the payloadAPI using the module declare pattern?
/**
- The context in which the request is being made
*/
payloadAPI: 'GraphQL' | 'local' | 'REST' | 'MCP'
…ible exisitng keys
8f722ce to
923a46b
Compare
| * @param str - The string to convert to camel case | ||
| * @returns The camel cased string | ||
| */ | ||
| export const toCamelCase = (str: string): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this one in CPA https://github.com/payloadcms/payload/blob/d8a62b7022f9b5a007e0294a49b9e6dd03bee17d/packages/create-payload-app/src/utils/casing.ts
Your function is not the same and doesn't appear to cover as many characters combinations.
This isn't a blocker for merge, future cleanup.
packages/plugin-mcp/src/index.ts
Outdated
| import { createAPIKeysCollection } from './collections/createApiKeysCollection.js' | ||
| import { initializeMCPHandler } from './endpoints/mcp.js' | ||
|
|
||
| export const pluginMCP = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is where we'd add @experimental in a jsdoc.
Als should this be named mcpPlugin or MCPPlugin? Our other plugins are all suffixed this way : formBuilderPlugin, ecommercePlugin, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MCP for you and me.
|
🚀 This is included in version v3.61.0 |
|
Great plugin! Can you review my PR to add localization support to this new plugin |
Discussion: [RFC] MCP Plugin
This plugin adds support for MCP (Model Context Protocol) so you can use Payload as an MCP server.
For any feedback leave your comments on the Github RFC
Getting Started docs to MCP
Background
MCP Allows you to interact with with models via a streamlined protocol. Developers can define allow retrieval on collections, create tools, create resources, and create prompts that models can interact with.
This plugin uses: @modelcontextprotocol/sdk, mcp-adapter
🚀 Basic Setup
With custom server options
Tools
These are the Payload tools you control through the Admin or Payload config that LLMs use to interact with collection documents.
Resources
findResourcescreateResourceupdateResourcedeleteResourceCustom Tools
You can include your own custom MCP tools as well.
Connectors
To connect to the MCP server as a connector via a client like VS Code, Claude or Cursor:
{ "mcpServers": { "My Payload App": { "command": "npx", "args": [ "-y", "mcp-remote", "http://localhost:300/api/mcp", "--header", "Authorization: Bearer API_KEY_GOES_HERE" ] }, } }Testing your MCP endpoint
I highly recommend using
npx @modelcontextprotocol/inspectorto test your MCP server.Your default MCP endpoint is:
http://localhost:3000/api/mcp