@payloadcms/plugin-mcp 3.64.0-internal.fc1e451 → 3.65.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/collections/createApiKeysCollection.d.ts.map +1 -1
  2. package/dist/collections/createApiKeysCollection.js +6 -0
  3. package/dist/collections/createApiKeysCollection.js.map +1 -1
  4. package/dist/endpoints/mcp.d.ts.map +1 -1
  5. package/dist/endpoints/mcp.js +30 -24
  6. package/dist/endpoints/mcp.js.map +1 -1
  7. package/dist/index.d.ts +7 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/mcp/createRequest.d.ts.map +1 -1
  11. package/dist/mcp/createRequest.js +2 -2
  12. package/dist/mcp/createRequest.js.map +1 -1
  13. package/dist/mcp/getMcpHandler.d.ts.map +1 -1
  14. package/dist/mcp/getMcpHandler.js +10 -8
  15. package/dist/mcp/getMcpHandler.js.map +1 -1
  16. package/dist/mcp/tools/resource/create.d.ts.map +1 -1
  17. package/dist/mcp/tools/resource/create.js +1 -0
  18. package/dist/mcp/tools/resource/create.js.map +1 -1
  19. package/dist/mcp/tools/resource/delete.d.ts.map +1 -1
  20. package/dist/mcp/tools/resource/delete.js +1 -0
  21. package/dist/mcp/tools/resource/delete.js.map +1 -1
  22. package/dist/mcp/tools/resource/find.d.ts.map +1 -1
  23. package/dist/mcp/tools/resource/find.js +2 -0
  24. package/dist/mcp/tools/resource/find.js.map +1 -1
  25. package/dist/mcp/tools/resource/update.d.ts.map +1 -1
  26. package/dist/mcp/tools/resource/update.js +2 -0
  27. package/dist/mcp/tools/resource/update.js.map +1 -1
  28. package/dist/types.d.ts +13 -0
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js.map +1 -1
  31. package/package.json +3 -3
  32. package/src/collections/createApiKeysCollection.ts +7 -0
  33. package/src/endpoints/mcp.ts +42 -30
  34. package/src/index.ts +8 -1
  35. package/src/mcp/createRequest.ts +2 -2
  36. package/src/mcp/getMcpHandler.ts +10 -7
  37. package/src/mcp/tools/resource/create.ts +1 -0
  38. package/src/mcp/tools/resource/delete.ts +1 -0
  39. package/src/mcp/tools/resource/find.ts +2 -0
  40. package/src/mcp/tools/resource/update.ts +2 -0
  41. package/src/types.ts +18 -0
@@ -50,6 +50,7 @@ export const createResourceTool = (
50
50
  // Create the resource
51
51
  const result = await payload.create({
52
52
  collection: collectionSlug,
53
+ req,
53
54
  // TODO: Move the override to a `beforeChange` hook and extend the payloadAPI context req to include MCP request info.
54
55
  data: collections?.[collectionSlug]?.override?.(parsedData, req) || parsedData,
55
56
  overrideAccess: false,
@@ -78,6 +78,7 @@ export const deleteResourceTool = (
78
78
  collection: collectionSlug,
79
79
  depth,
80
80
  overrideAccess: false,
81
+ req,
81
82
  user,
82
83
  }
83
84
 
@@ -65,6 +65,7 @@ export const findResourceTool = (
65
65
  id,
66
66
  collection: collectionSlug,
67
67
  overrideAccess: false,
68
+ req,
68
69
  user,
69
70
  })
70
71
 
@@ -117,6 +118,7 @@ ${JSON.stringify(doc, null, 2)}`,
117
118
  limit,
118
119
  overrideAccess: false,
119
120
  page,
121
+ req,
120
122
  user,
121
123
  }
122
124
 
@@ -116,6 +116,7 @@ export const updateResourceTool = (
116
116
  draft,
117
117
  overrideAccess: false,
118
118
  overrideLock,
119
+ req,
119
120
  user,
120
121
  ...(filePath && { filePath }),
121
122
  ...(overwriteExistingFiles && { overwriteExistingFiles }),
@@ -162,6 +163,7 @@ ${JSON.stringify(result, null, 2)}
162
163
  draft,
163
164
  overrideAccess: false,
164
165
  overrideLock,
166
+ req,
165
167
  user,
166
168
  where: whereClause,
167
169
  ...(filePath && { filePath }),
package/src/types.ts CHANGED
@@ -215,8 +215,26 @@ export type PluginMCPServerConfig = {
215
215
  parameters: z.ZodRawShape
216
216
  }[]
217
217
  }
218
+
219
+ /**
220
+ * Override the API key collection.
221
+ * This allows you to add fields to the API key collection or modify the collection in any way you want.
222
+ * @param collection - The API key collection.
223
+ * @returns The modified API key collection.
224
+ */
218
225
  overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig
219
226
 
227
+ /**
228
+ * Override the authentication method.
229
+ * This allows you to use a custom authentication method instead of the default API key authentication.
230
+ * @param req - The request object.
231
+ * @returns The MCP access settings.
232
+ */
233
+ overrideAuth?: (
234
+ req: PayloadRequest,
235
+ getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,
236
+ ) => MCPAccessSettings | Promise<MCPAccessSettings>
237
+
220
238
  /**
221
239
  * Set the users collection that API keys should be associated with.
222
240
  */