@payloadcms/plugin-mcp 4.0.0-internal.167c7cd → 4.0.0-internal.16f218d

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 (196) hide show
  1. package/bin.js +0 -7
  2. package/dist/endpoint/access.d.ts.map +1 -1
  3. package/dist/endpoint/access.js +25 -5
  4. package/dist/endpoint/access.js.map +1 -1
  5. package/dist/endpoint/index.d.ts.map +1 -1
  6. package/dist/endpoint/index.js +45 -4
  7. package/dist/endpoint/index.js.map +1 -1
  8. package/dist/endpoint/oauth.d.ts +35 -0
  9. package/dist/endpoint/oauth.d.ts.map +1 -0
  10. package/dist/endpoint/oauth.js +96 -0
  11. package/dist/endpoint/oauth.js.map +1 -0
  12. package/dist/endpoint/oauthLoginToken.d.ts +21 -0
  13. package/dist/endpoint/oauthLoginToken.d.ts.map +1 -0
  14. package/dist/endpoint/oauthLoginToken.js +79 -0
  15. package/dist/endpoint/oauthLoginToken.js.map +1 -0
  16. package/dist/endpoint/oauthServer.d.ts +12 -0
  17. package/dist/endpoint/oauthServer.d.ts.map +1 -0
  18. package/dist/endpoint/oauthServer.js +361 -0
  19. package/dist/endpoint/oauthServer.js.map +1 -0
  20. package/dist/index.d.ts +10 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +15 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/mcp/buildMcpServer.d.ts +2 -2
  25. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  26. package/dist/mcp/buildMcpServer.js +36 -24
  27. package/dist/mcp/buildMcpServer.js.map +1 -1
  28. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  29. package/dist/mcp/builtin/collections/authTools.js +80 -56
  30. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  31. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
  32. package/dist/mcp/builtin/collections/countTool.js +9 -14
  33. package/dist/mcp/builtin/collections/countTool.js.map +1 -1
  34. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
  35. package/dist/mcp/builtin/collections/countVersionsTool.js +9 -13
  36. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
  37. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  38. package/dist/mcp/builtin/collections/createTool.js +48 -49
  39. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  40. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  41. package/dist/mcp/builtin/collections/deleteTool.js +44 -43
  42. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  43. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
  44. package/dist/mcp/builtin/collections/duplicateTool.js +31 -37
  45. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
  46. package/dist/mcp/builtin/collections/fileInput.d.ts +21 -21
  47. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -1
  48. package/dist/mcp/builtin/collections/fileInput.js +34 -70
  49. package/dist/mcp/builtin/collections/fileInput.js.map +1 -1
  50. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
  51. package/dist/mcp/builtin/collections/findDistinctTool.js +11 -26
  52. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
  53. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  54. package/dist/mcp/builtin/collections/findTool.js +28 -46
  55. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  56. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
  57. package/dist/mcp/builtin/collections/findVersionByIDTool.js +17 -26
  58. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
  59. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
  60. package/dist/mcp/builtin/collections/findVersionsTool.js +16 -30
  61. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
  62. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  63. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +30 -14
  64. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  65. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
  66. package/dist/mcp/builtin/collections/restoreVersionTool.js +14 -26
  67. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
  68. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  69. package/dist/mcp/builtin/collections/updateTool.js +55 -87
  70. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  71. package/dist/mcp/builtin/collections/uploadInstructionsTool.js +11 -11
  72. package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -1
  73. package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
  74. package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
  75. package/dist/mcp/builtin/formatEntityError.js +55 -0
  76. package/dist/mcp/builtin/formatEntityError.js.map +1 -0
  77. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  78. package/dist/mcp/builtin/getConfigInfoTool.js +3 -2
  79. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  80. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
  81. package/dist/mcp/builtin/globals/countVersionsTool.js +9 -13
  82. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
  83. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  84. package/dist/mcp/builtin/globals/findTool.js +10 -16
  85. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  86. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
  87. package/dist/mcp/builtin/globals/findVersionByIDTool.js +13 -24
  88. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
  89. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
  90. package/dist/mcp/builtin/globals/findVersionsTool.js +13 -29
  91. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
  92. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  93. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +29 -13
  94. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  95. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
  96. package/dist/mcp/builtin/globals/restoreVersionTool.js +15 -22
  97. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
  98. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  99. package/dist/mcp/builtin/globals/updateTool.js +27 -36
  100. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  101. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  102. package/dist/mcp/sanitizeMCPConfig.js +3 -0
  103. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  104. package/dist/stdio.js +4 -3
  105. package/dist/stdio.js.map +1 -1
  106. package/dist/types.d.ts +99 -7
  107. package/dist/types.d.ts.map +1 -1
  108. package/dist/types.js.map +1 -1
  109. package/dist/utils/seal.d.ts +18 -0
  110. package/dist/utils/seal.d.ts.map +1 -0
  111. package/dist/utils/seal.js +27 -0
  112. package/dist/utils/seal.js.map +1 -0
  113. package/dist/utils/toStandardSchema.js.map +1 -1
  114. package/package.json +23 -28
  115. package/src/endpoint/access.ts +24 -6
  116. package/src/endpoint/index.ts +41 -3
  117. package/src/endpoint/oauth.ts +100 -0
  118. package/src/endpoint/oauthLoginToken.ts +91 -0
  119. package/src/endpoint/oauthServer.ts +396 -0
  120. package/src/index.ts +40 -5
  121. package/src/mcp/buildMcpServer.ts +40 -30
  122. package/src/mcp/builtin/collections/authTools.ts +82 -71
  123. package/src/mcp/builtin/collections/countTool.ts +9 -21
  124. package/src/mcp/builtin/collections/countVersionsTool.ts +9 -18
  125. package/src/mcp/builtin/collections/createTool.ts +71 -96
  126. package/src/mcp/builtin/collections/deleteTool.ts +37 -65
  127. package/src/mcp/builtin/collections/duplicateTool.ts +36 -86
  128. package/src/mcp/builtin/collections/fileInput.spec.ts +2 -2
  129. package/src/mcp/builtin/collections/fileInput.ts +44 -81
  130. package/src/mcp/builtin/collections/findDistinctTool.ts +11 -63
  131. package/src/mcp/builtin/collections/findTool.ts +24 -106
  132. package/src/mcp/builtin/collections/findVersionByIDTool.ts +15 -58
  133. package/src/mcp/builtin/collections/findVersionsTool.ts +14 -85
  134. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +23 -12
  135. package/src/mcp/builtin/collections/restoreVersionTool.ts +15 -57
  136. package/src/mcp/builtin/collections/updateTool.ts +55 -109
  137. package/src/mcp/builtin/collections/uploadInstructionsTool.ts +12 -12
  138. package/src/mcp/builtin/formatEntityError.ts +77 -0
  139. package/src/mcp/builtin/getConfigInfoTool.ts +2 -1
  140. package/src/mcp/builtin/globals/countVersionsTool.ts +9 -17
  141. package/src/mcp/builtin/globals/findTool.ts +13 -52
  142. package/src/mcp/builtin/globals/findVersionByIDTool.ts +13 -52
  143. package/src/mcp/builtin/globals/findVersionsTool.ts +14 -92
  144. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +21 -11
  145. package/src/mcp/builtin/globals/restoreVersionTool.ts +14 -45
  146. package/src/mcp/builtin/globals/updateTool.ts +38 -61
  147. package/src/mcp/sanitizeMCPConfig.ts +1 -0
  148. package/src/stdio.ts +2 -2
  149. package/src/types.ts +99 -7
  150. package/src/utils/seal.ts +46 -0
  151. package/src/utils/toStandardSchema.ts +1 -1
  152. package/dist/mcp/builtin/collections/fileInput.spec.js +0 -86
  153. package/dist/mcp/builtin/collections/fileInput.spec.js.map +0 -1
  154. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
  155. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
  156. package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
  157. package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
  158. package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
  159. package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
  160. package/dist/mcp/builtin/validateEntityData.js +0 -82
  161. package/dist/mcp/builtin/validateEntityData.js.map +0 -1
  162. package/dist/utils/getVirtualFieldNames.d.ts +0 -14
  163. package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
  164. package/dist/utils/getVirtualFieldNames.js +0 -35
  165. package/dist/utils/getVirtualFieldNames.js.map +0 -1
  166. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +0 -28
  167. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +0 -1
  168. package/dist/utils/schemaConversion/filterFieldsByAccess.js +0 -71
  169. package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +0 -1
  170. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -13
  171. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
  172. package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -66
  173. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
  174. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -10
  175. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
  176. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -384
  177. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
  178. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -133
  179. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
  180. package/dist/utils/transformPointDataToPayload.d.ts +0 -7
  181. package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
  182. package/dist/utils/transformPointDataToPayload.js +0 -28
  183. package/dist/utils/transformPointDataToPayload.js.map +0 -1
  184. package/dist/utils/whereSchema.d.ts +0 -9
  185. package/dist/utils/whereSchema.d.ts.map +0 -1
  186. package/dist/utils/whereSchema.js +0 -13
  187. package/dist/utils/whereSchema.js.map +0 -1
  188. package/src/mcp/builtin/collections/formatCollectionError.ts +0 -84
  189. package/src/mcp/builtin/validateEntityData.ts +0 -132
  190. package/src/utils/getVirtualFieldNames.ts +0 -53
  191. package/src/utils/schemaConversion/filterFieldsByAccess.ts +0 -123
  192. package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -96
  193. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -96
  194. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -432
  195. package/src/utils/transformPointDataToPayload.ts +0 -40
  196. package/src/utils/whereSchema.ts +0 -24
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CallToolResult, ContentBlock, JsonSchemaType, McpServer, ResourceTemplate, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from '@modelcontextprotocol/server';
1
+ import type { CallToolResult, ContentBlock, Implementation, JsonSchemaType, McpServerOptions, ResourceTemplate, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from '@modelcontextprotocol/server';
2
2
  import type { AuthCollectionSlug, CollectionSlug, GlobalSlug, MaybePromise, PayloadRequest, SanitizedPermissions } from 'payload';
3
3
  import type { GetAuthorizedMCPArgs } from './endpoint/access.js';
4
4
  import type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName } from './mcp/builtinTools.js';
@@ -37,10 +37,10 @@ export type MCPAccessArgs = {
37
37
  req: PayloadRequest;
38
38
  };
39
39
  export type CollectionMCPAccessArgs = {
40
- collectionSlug: CollectionSlug;
40
+ slug: CollectionSlug;
41
41
  } & MCPAccessArgs;
42
42
  export type GlobalMCPAccessArgs = {
43
- globalSlug: GlobalSlug;
43
+ slug: GlobalSlug;
44
44
  } & MCPAccessArgs;
45
45
  export type ToolHandlerArgs<TSchema = undefined> = {
46
46
  authorizedMCP: AuthorizedMCP;
@@ -49,10 +49,10 @@ export type ToolHandlerArgs<TSchema = undefined> = {
49
49
  serverContext: ServerContext;
50
50
  };
51
51
  export type CollectionToolHandlerArgs<TSchema = undefined> = {
52
- collectionSlug: CollectionSlug;
52
+ slug: CollectionSlug;
53
53
  } & ToolHandlerArgs<TSchema>;
54
54
  export type GlobalToolHandlerArgs<TSchema = undefined> = {
55
- globalSlug: GlobalSlug;
55
+ slug: GlobalSlug;
56
56
  } & ToolHandlerArgs<TSchema>;
57
57
  export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
58
58
  /**
@@ -223,9 +223,24 @@ export type MCPPluginConfig = {
223
223
  afterToolCall?: MCPAfterToolCallHook[];
224
224
  };
225
225
  mcp?: {
226
+ /**
227
+ * Largest HTTP request body, in bytes, that the MCP endpoint accepts. Larger requests
228
+ * are answered with `413`. Base64 file uploads count toward this limit.
229
+ *
230
+ * @default 4194304 (4 MiB, the MCP SDK default)
231
+ */
232
+ maxRequestBodySize?: number;
226
233
  serverOptions?: MCPServerOptions;
227
234
  verboseLogs?: boolean;
228
235
  };
236
+ /**
237
+ * How MCP clients sign in. MCP requests without an authenticated user get a `401` that points
238
+ * to the protected resource metadata (RFC 9728). Set to `false` to only accept API keys and
239
+ * anonymous requests.
240
+ *
241
+ * @default { type: 'builtin' }
242
+ */
243
+ oauth?: false | MCPOAuthConfig;
229
244
  /**
230
245
  * Replace the default MCP authorization resolver.
231
246
  *
@@ -240,12 +255,89 @@ export type MCPPluginConfig = {
240
255
  /** Cross-cutting tools (not scoped to any collection or global). */
241
256
  tools?: MCPTopLevelToolsMap;
242
257
  };
258
+ export type MCPOAuthConfig = MCPBuiltinOAuthConfig | MCPExternalOAuthConfig;
259
+ /**
260
+ * This Payload app is the authorization server. Users sign in to the admin panel and allow the
261
+ * MCP client, which then gets an access token for them.
262
+ */
263
+ export type MCPBuiltinOAuthConfig = {
264
+ /**
265
+ * Creates the tokens the MCP client gets when the user clicks Allow. `req` is the user's own
266
+ * browser request, so `req.user` is the user who allowed it. Pass `authenticate` too if
267
+ * Payload's auth strategies don't accept the access token.
268
+ *
269
+ * @default a Payload login token for that user that only works for MCP, with a refresh token when
270
+ * the collection uses sessions
271
+ */
272
+ issueToken?: (args: {
273
+ req: PayloadRequest;
274
+ }) => MaybePromise<MCPOAuthTokens>;
275
+ /**
276
+ * Trades a refresh token from `issueToken`, or from an earlier refresh, for new tokens. Return
277
+ * `null` when it's no longer valid, and the client sends the user through sign-in again. `req`
278
+ * is the MCP client's request, without a user. Only used together with `issueToken`.
279
+ *
280
+ * OAuth requires noticing copied refresh tokens: return a new refresh token every time, and
281
+ * revoke the tokens when an already used refresh token comes back.
282
+ */
283
+ refreshToken?: (args: {
284
+ refreshToken: string;
285
+ req: PayloadRequest;
286
+ }) => MaybePromise<MCPOAuthTokens | null>;
287
+ type: 'builtin';
288
+ } & MCPOAuthSharedConfig;
289
+ export type MCPOAuthTokens = {
290
+ accessToken: string;
291
+ /** Seconds until the access token expires. */
292
+ expiresIn?: number;
293
+ /** Lets the client get new tokens without the user, through `refreshToken`. */
294
+ refreshToken?: string;
295
+ };
296
+ /** Another service, e.g. your identity provider, is the authorization server. */
297
+ export type MCPExternalOAuthConfig = {
298
+ /**
299
+ * The authorization servers that issue access tokens for MCP clients. Clients require each one
300
+ * to exactly match the `issuer` in that server's metadata, so pass a function when the exact
301
+ * value is only known at runtime, e.g. from the server's OpenID configuration or per host.
302
+ */
303
+ authorizationServers: ((args: {
304
+ req: PayloadRequest;
305
+ }) => MaybePromise<string[]>) | string[];
306
+ /**
307
+ * Scopes MCP clients should request, e.g. `['openid', 'email', 'profile']`. Without them,
308
+ * clients request none, which some authorization servers reject or answer with a token that
309
+ * doesn't identify the user.
310
+ */
311
+ scopes?: string[];
312
+ type: 'external';
313
+ } & MCPOAuthSharedConfig;
314
+ type MCPOAuthSharedConfig = {
315
+ /**
316
+ * Called on MCP requests with a bearer token that Payload's auth strategies didn't accept.
317
+ * Return the Payload user, including its `collection`, or `null` to answer with the OAuth challenge.
318
+ */
319
+ authenticate?: (args: {
320
+ req: PayloadRequest;
321
+ token: string;
322
+ }) => MaybePromise<PayloadRequest['user']>;
323
+ /**
324
+ * The URL clients call to reach the MCP endpoint. The metadata link and the built-in
325
+ * authorization server's issuer are based on it.
326
+ *
327
+ * @default the absolute URL of `/api/mcp`, based on `serverURL` or the request URL
328
+ */
329
+ resource?: ((args: {
330
+ req: PayloadRequest;
331
+ }) => string) | string;
332
+ };
243
333
  export type SanitizedMCPPluginConfig = {
244
334
  items: MCPItem[];
335
+ /** `undefined` when OAuth is turned off. */
336
+ oauth?: MCPOAuthConfig;
245
337
  } & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>;
246
338
  export type MCPServerOptions = {
247
- options?: ConstructorParameters<typeof McpServer>[1];
248
- serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>;
339
+ options?: McpServerOptions;
340
+ serverInfo?: Partial<Implementation>;
249
341
  };
250
342
  /**
251
343
  * One MCP primitive plus the metadata needed for config-driven filtering and
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,EAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,CAAA;AAEzF,gGAAgG;AAChG,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,eAAe,EAAE,CAAA;AAEvE;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,sBAAsB,CAAA;AAErE,MAAM,MAAM,e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map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n JsonSchemaType,\n McpServer,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionSlug,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n SanitizedPermissions,\n} from 'payload'\n\nimport type { GetAuthorizedMCPArgs } from './endpoint/access.js'\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */\nexport type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).\n * Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\nexport type MCPAfterToolCallHook = (args: {\n input: unknown\n req: PayloadRequest\n response: MCPToolResponse\n toolName: string\n}) => MaybePromise<MCPToolResponse>\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type MCPAccessArgs = {\n permissions?: SanitizedPermissions\n req: PayloadRequest\n}\n\nexport type CollectionMCPAccessArgs = {\n collectionSlug: CollectionSlug\n} & MCPAccessArgs\n\nexport type GlobalMCPAccessArgs = {\n globalSlug: GlobalSlug\n} & MCPAccessArgs\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n collectionSlug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n globalSlug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n /**\n * Runs while authorizing each MCP request, before the tool is advertised or called. Return\n * `false` to make the tool unavailable for that request. This is skipped when `overrideAccess`\n * is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n /**\n * Runs while authorizing each MCP request for this collection. Return `false` to reject calls\n * to this tool for the collection. The shared tool is not advertised when no collections allow\n * it, but can remain advertised when it is available for another collection. This is skipped\n * when `overrideAccess` is enabled.\n */\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n /**\n * Runs while authorizing each MCP request for this global. Return `false` to reject calls to\n * this tool for the global. The shared tool is not advertised when no globals allow it, but\n * can remain advertised when it is available for another global. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInCollectionToolOverride = {\n /**\n * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for\n * this collection. This is skipped when `overrideAccess` is enabled.\n */\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\nexport type MCPBuiltInGlobalToolOverride = {\n /**\n * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for\n * this global. This is skipped when `overrideAccess` is enabled.\n */\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n /**\n * Runs while authorizing each MCP request, before the prompt is advertised or used. Return\n * `false` to make the prompt unavailable for that request. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n /**\n * Runs while authorizing each MCP request, before the resource is advertised or read. Return\n * `false` to make the resource unavailable for that request. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP endpoint registration. */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n hooks?: {\n /** Transform a tool response after its handler returns */\n afterToolCall?: MCPAfterToolCallHook[]\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n /**\n * Replace the default MCP authorization resolver.\n *\n * This hook replaces the default authentication flow. It must set `req.user` to the\n * authenticated Payload user, or to `null` for an anonymous caller, before returning.\n */\n overrideGetAuthorizedMCP?: (\n args: {\n pluginConfig: SanitizedMCPPluginConfig\n } & GetAuthorizedMCPArgs,\n ) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * One MCP primitive plus the metadata needed for config-driven filtering and\n * registration.\n *\n * - `configKey`: the config identifier, e.g. `find` or `echo`.\n * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.\n * - `label`: human-readable display text.\n */\nexport type MCPItemBase = {\n configKey: string\n label: string\n mcpName: string\n}\n\nexport type CollectionMCPItem = {\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n} & MCPItemBase\n\nexport type GlobalMCPItem = {\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n} & MCPItemBase\n\nexport type MCPItem =\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n | CollectionMCPItem\n | GlobalMCPItem\n\n/**\n * The MCP items and access mode authorized for this request. The authenticated user is available\n * as `req.user`.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n}\n"],"names":[],"mappings":"AAgWA;;;CAGC,GACD,WAGC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n Implementation,\n JsonSchemaType,\n McpServerOptions,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionSlug,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n SanitizedPermissions,\n} from 'payload'\n\nimport type { GetAuthorizedMCPArgs } from './endpoint/access.js'\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */\nexport type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).\n * Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\nexport type MCPAfterToolCallHook = (args: {\n input: unknown\n req: PayloadRequest\n response: MCPToolResponse\n toolName: string\n}) => MaybePromise<MCPToolResponse>\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type MCPAccessArgs = {\n permissions?: SanitizedPermissions\n req: PayloadRequest\n}\n\nexport type CollectionMCPAccessArgs = {\n slug: CollectionSlug\n} & MCPAccessArgs\n\nexport type GlobalMCPAccessArgs = {\n slug: GlobalSlug\n} & MCPAccessArgs\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n slug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n slug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n /**\n * Runs while authorizing each MCP request, before the tool is advertised or called. Return\n * `false` to make the tool unavailable for that request. This is skipped when `overrideAccess`\n * is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n /**\n * Runs while authorizing each MCP request for this collection. Return `false` to reject calls\n * to this tool for the collection. The shared tool is not advertised when no collections allow\n * it, but can remain advertised when it is available for another collection. This is skipped\n * when `overrideAccess` is enabled.\n */\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n /**\n * Runs while authorizing each MCP request for this global. Return `false` to reject calls to\n * this tool for the global. The shared tool is not advertised when no globals allow it, but\n * can remain advertised when it is available for another global. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInCollectionToolOverride = {\n /**\n * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for\n * this collection. This is skipped when `overrideAccess` is enabled.\n */\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\nexport type MCPBuiltInGlobalToolOverride = {\n /**\n * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for\n * this global. This is skipped when `overrideAccess` is enabled.\n */\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n /**\n * Runs while authorizing each MCP request, before the prompt is advertised or used. Return\n * `false` to make the prompt unavailable for that request. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n /**\n * Runs while authorizing each MCP request, before the resource is advertised or read. Return\n * `false` to make the resource unavailable for that request. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP endpoint registration. */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n hooks?: {\n /** Transform a tool response after its handler returns */\n afterToolCall?: MCPAfterToolCallHook[]\n }\n mcp?: {\n /**\n * Largest HTTP request body, in bytes, that the MCP endpoint accepts. Larger requests\n * are answered with `413`. Base64 file uploads count toward this limit.\n *\n * @default 4194304 (4 MiB, the MCP SDK default)\n */\n maxRequestBodySize?: number\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n /**\n * How MCP clients sign in. MCP requests without an authenticated user get a `401` that points\n * to the protected resource metadata (RFC 9728). Set to `false` to only accept API keys and\n * anonymous requests.\n *\n * @default { type: 'builtin' }\n */\n oauth?: false | MCPOAuthConfig\n /**\n * Replace the default MCP authorization resolver.\n *\n * This hook replaces the default authentication flow. It must set `req.user` to the\n * authenticated Payload user, or to `null` for an anonymous caller, before returning.\n */\n overrideGetAuthorizedMCP?: (\n args: {\n pluginConfig: SanitizedMCPPluginConfig\n } & GetAuthorizedMCPArgs,\n ) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n}\n\nexport type MCPOAuthConfig = MCPBuiltinOAuthConfig | MCPExternalOAuthConfig\n\n/**\n * This Payload app is the authorization server. Users sign in to the admin panel and allow the\n * MCP client, which then gets an access token for them.\n */\nexport type MCPBuiltinOAuthConfig = {\n /**\n * Creates the tokens the MCP client gets when the user clicks Allow. `req` is the user's own\n * browser request, so `req.user` is the user who allowed it. Pass `authenticate` too if\n * Payload's auth strategies don't accept the access token.\n *\n * @default a Payload login token for that user that only works for MCP, with a refresh token when\n * the collection uses sessions\n */\n issueToken?: (args: { req: PayloadRequest }) => MaybePromise<MCPOAuthTokens>\n /**\n * Trades a refresh token from `issueToken`, or from an earlier refresh, for new tokens. Return\n * `null` when it's no longer valid, and the client sends the user through sign-in again. `req`\n * is the MCP client's request, without a user. Only used together with `issueToken`.\n *\n * OAuth requires noticing copied refresh tokens: return a new refresh token every time, and\n * revoke the tokens when an already used refresh token comes back.\n */\n refreshToken?: (args: {\n refreshToken: string\n req: PayloadRequest\n }) => MaybePromise<MCPOAuthTokens | null>\n type: 'builtin'\n} & MCPOAuthSharedConfig\n\nexport type MCPOAuthTokens = {\n accessToken: string\n /** Seconds until the access token expires. */\n expiresIn?: number\n /** Lets the client get new tokens without the user, through `refreshToken`. */\n refreshToken?: string\n}\n\n/** Another service, e.g. your identity provider, is the authorization server. */\nexport type MCPExternalOAuthConfig = {\n /**\n * The authorization servers that issue access tokens for MCP clients. Clients require each one\n * to exactly match the `issuer` in that server's metadata, so pass a function when the exact\n * value is only known at runtime, e.g. from the server's OpenID configuration or per host.\n */\n authorizationServers: ((args: { req: PayloadRequest }) => MaybePromise<string[]>) | string[]\n /**\n * Scopes MCP clients should request, e.g. `['openid', 'email', 'profile']`. Without them,\n * clients request none, which some authorization servers reject or answer with a token that\n * doesn't identify the user.\n */\n scopes?: string[]\n type: 'external'\n} & MCPOAuthSharedConfig\n\ntype MCPOAuthSharedConfig = {\n /**\n * Called on MCP requests with a bearer token that Payload's auth strategies didn't accept.\n * Return the Payload user, including its `collection`, or `null` to answer with the OAuth challenge.\n */\n authenticate?: (args: {\n req: PayloadRequest\n token: string\n }) => MaybePromise<PayloadRequest['user']>\n /**\n * The URL clients call to reach the MCP endpoint. The metadata link and the built-in\n * authorization server's issuer are based on it.\n *\n * @default the absolute URL of `/api/mcp`, based on `serverURL` or the request URL\n */\n resource?: ((args: { req: PayloadRequest }) => string) | string\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n /** `undefined` when OAuth is turned off. */\n oauth?: MCPOAuthConfig\n} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>\n\nexport type MCPServerOptions = {\n options?: McpServerOptions\n serverInfo?: Partial<Implementation>\n}\n\n/**\n * One MCP primitive plus the metadata needed for config-driven filtering and\n * registration.\n *\n * - `configKey`: the config identifier, e.g. `find` or `echo`.\n * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.\n * - `label`: human-readable display text.\n */\nexport type MCPItemBase = {\n configKey: string\n label: string\n mcpName: string\n}\n\nexport type CollectionMCPItem = {\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n} & MCPItemBase\n\nexport type GlobalMCPItem = {\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n} & MCPItemBase\n\nexport type MCPItem =\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n | CollectionMCPItem\n | GlobalMCPItem\n\n/**\n * The MCP items and access mode authorized for this request. The authenticated user is available\n * as `req.user`.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n}\n"],"names":[],"mappings":"AA4bA;;;CAGC,GACD,WAGC"}
@@ -0,0 +1,18 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ /**
3
+ * Encrypts data for the client to hold, so it doesn't need to be stored. `type` keeps one kind
4
+ * from being used as another, e.g. a client ID as an authorization code.
5
+ */
6
+ export declare const seal: ({ type, data, expiresIn, req, }: {
7
+ data: object;
8
+ /** Seconds */
9
+ expiresIn?: number;
10
+ req: PayloadRequest;
11
+ type: string;
12
+ }) => string;
13
+ export declare const unseal: <T>({ type, req, value, }: {
14
+ req: PayloadRequest;
15
+ type: string;
16
+ value: null | string;
17
+ }) => T | undefined;
18
+ //# sourceMappingURL=seal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../src/utils/seal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,IAAI,oCAKd;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,KAAG,MAGD,CAAA;AAEH,eAAO,MAAM,MAAM,GAAI,CAAC,yBAIrB;IACD,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;CACrB,KAAG,CAAC,GAAG,SAeP,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Encrypts data for the client to hold, so it doesn't need to be stored. `type` keeps one kind
3
+ * from being used as another, e.g. a client ID as an authorization code.
4
+ */ export const seal = ({ type, data, expiresIn, req })=>req.payload.encrypt(JSON.stringify({
5
+ ...data,
6
+ type,
7
+ exp: expiresIn && Date.now() + expiresIn * 1000
8
+ }));
9
+ export const unseal = ({ type, req, value })=>{
10
+ // Only the v1 format is authenticated. Older formats decrypt anything without an error.
11
+ if (!value?.startsWith('v1:')) {
12
+ return undefined;
13
+ }
14
+ try {
15
+ // Previous secrets can be public, like a default secret from source code, so only client IDs
16
+ // accept them. Client IDs grant nothing, and this keeps clients registered when the secret changes.
17
+ const secret = type === 'client' ? undefined : req.payload.config.secret;
18
+ const data = JSON.parse(req.payload.decrypt(value, {
19
+ secret
20
+ }));
21
+ return data.type === type && (!data.exp || data.exp > Date.now()) ? data : undefined;
22
+ } catch {
23
+ return undefined;
24
+ }
25
+ };
26
+
27
+ //# sourceMappingURL=seal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/seal.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\n/**\n * Encrypts data for the client to hold, so it doesn't need to be stored. `type` keeps one kind\n * from being used as another, e.g. a client ID as an authorization code.\n */\nexport const seal = ({\n type,\n data,\n expiresIn,\n req,\n}: {\n data: object\n /** Seconds */\n expiresIn?: number\n req: PayloadRequest\n type: string\n}): string =>\n req.payload.encrypt(\n JSON.stringify({ ...data, type, exp: expiresIn && Date.now() + expiresIn * 1000 }),\n )\n\nexport const unseal = <T>({\n type,\n req,\n value,\n}: {\n req: PayloadRequest\n type: string\n value: null | string\n}): T | undefined => {\n // Only the v1 format is authenticated. Older formats decrypt anything without an error.\n if (!value?.startsWith('v1:')) {\n return undefined\n }\n\n try {\n // Previous secrets can be public, like a default secret from source code, so only client IDs\n // accept them. Client IDs grant nothing, and this keeps clients registered when the secret changes.\n const secret = type === 'client' ? undefined : req.payload.config.secret\n const data = JSON.parse(req.payload.decrypt(value, { secret }))\n return data.type === type && (!data.exp || data.exp > Date.now()) ? data : undefined\n } catch {\n return undefined\n }\n}\n"],"names":["seal","type","data","expiresIn","req","payload","encrypt","JSON","stringify","exp","Date","now","unseal","value","startsWith","undefined","secret","config","parse","decrypt"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,OAAO,CAAC,EACnBC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,GAAG,EAOJ,GACCA,IAAIC,OAAO,CAACC,OAAO,CACjBC,KAAKC,SAAS,CAAC;QAAE,GAAGN,IAAI;QAAED;QAAMQ,KAAKN,aAAaO,KAAKC,GAAG,KAAKR,YAAY;IAAK,IACjF;AAEH,OAAO,MAAMS,SAAS,CAAI,EACxBX,IAAI,EACJG,GAAG,EACHS,KAAK,EAKN;IACC,wFAAwF;IACxF,IAAI,CAACA,OAAOC,WAAW,QAAQ;QAC7B,OAAOC;IACT;IAEA,IAAI;QACF,6FAA6F;QAC7F,oGAAoG;QACpG,MAAMC,SAASf,SAAS,WAAWc,YAAYX,IAAIC,OAAO,CAACY,MAAM,CAACD,MAAM;QACxE,MAAMd,OAAOK,KAAKW,KAAK,CAACd,IAAIC,OAAO,CAACc,OAAO,CAACN,OAAO;YAAEG;QAAO;QAC5D,OAAOd,KAAKD,IAAI,KAAKA,QAAS,CAAA,CAACC,KAAKO,GAAG,IAAIP,KAAKO,GAAG,GAAGC,KAAKC,GAAG,EAAC,IAAKT,OAAOa;IAC7E,EAAE,OAAM;QACN,OAAOA;IACT;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/toStandardSchema.ts"],"sourcesContent":["import { fromJsonSchema, type StandardSchemaWithJSON } from '@modelcontextprotocol/server'\n\nimport type { ToolInputSchema } from '../types.js'\n\n/** Normalize a tool/prompt input to a Standard Schema. Raw JSON Schema gets wrapped; Standard Schema instances pass through. */\nexport const toStandardSchema = (schema: ToolInputSchema): StandardSchemaWithJSON =>\n typeof schema === 'object' && schema !== null && '~standard' in schema\n ? (schema as StandardSchemaWithJSON)\n : fromJsonSchema(schema)\n"],"names":["fromJsonSchema","toStandardSchema","schema"],"mappings":"AAAA,SAASA,cAAc,QAAqC,+BAA8B;AAI1F,8HAA8H,GAC9H,OAAO,MAAMC,mBAAmB,CAACC,SAC/B,OAAOA,WAAW,YAAYA,WAAW,QAAQ,eAAeA,SAC3DA,SACDF,eAAeE,QAAO"}
1
+ {"version":3,"sources":["../../src/utils/toStandardSchema.ts"],"sourcesContent":["import { fromJsonSchema, type StandardSchemaWithJSON } from '@modelcontextprotocol/server'\n\nimport type { ToolInputSchema } from '../types.js'\n\n/** Normalize a tool/prompt input to a Standard Schema. Raw JSON Schema gets wrapped; Standard Schema instances pass through. */\nexport const toStandardSchema = (schema: ToolInputSchema): StandardSchemaWithJSON =>\n typeof schema === 'object' && schema !== null && '~standard' in schema\n ? schema\n : fromJsonSchema(schema)\n"],"names":["fromJsonSchema","toStandardSchema","schema"],"mappings":"AAAA,SAASA,cAAc,QAAqC,+BAA8B;AAI1F,8HAA8H,GAC9H,OAAO,MAAMC,mBAAmB,CAACC,SAC/B,OAAOA,WAAW,YAAYA,WAAW,QAAQ,eAAeA,SAC5DA,SACAF,eAAeE,QAAO"}
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-mcp",
3
- "version": "4.0.0-internal.167c7cd",
3
+ "version": "4.0.0-internal.16f218d",
4
4
  "description": "MCP (Model Context Protocol) capabilities with Payload",
5
5
  "keywords": [
6
- "plugin",
7
6
  "mcp",
8
- "model context protocol"
7
+ "model context protocol",
8
+ "plugin"
9
9
  ],
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/payloadcms/payload.git",
13
- "directory": "packages/plugin-mcp"
14
- },
15
10
  "license": "MIT",
16
11
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
17
12
  "maintainers": [
@@ -21,7 +16,22 @@
21
16
  "url": "https://payloadcms.com"
22
17
  }
23
18
  ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/payloadcms/payload.git",
22
+ "directory": "packages/plugin-mcp"
23
+ },
24
+ "bin": {
25
+ "payload-mcp": "./bin.js"
26
+ },
27
+ "files": [
28
+ "src",
29
+ "dist",
30
+ "bin.js"
31
+ ],
24
32
  "type": "module",
33
+ "main": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
25
35
  "exports": {
26
36
  ".": {
27
37
  "import": "./dist/index.js",
@@ -44,30 +54,17 @@
44
54
  "default": "./dist/exports/internal.js"
45
55
  }
46
56
  },
47
- "main": "./dist/index.js",
48
- "types": "./dist/index.d.ts",
49
- "bin": {
50
- "payload-mcp": "./bin.js"
51
- },
52
- "files": [
53
- "src",
54
- "dist",
55
- "bin.js"
56
- ],
57
57
  "dependencies": {
58
- "@modelcontextprotocol/server": "2.0.0",
59
- "tsx": "4.22.4",
60
- "zod": "^4.2.0"
58
+ "@modelcontextprotocol/server": "2.4.0",
59
+ "tsx": "4.23.15"
61
60
  },
62
61
  "devDependencies": {
63
- "payload": "4.0.0-internal.167c7cd",
64
- "@payloadcms/eslint-config": "3.28.0"
62
+ "payload": "4.0.0-internal.16f218d"
65
63
  },
66
64
  "peerDependencies": {
67
- "payload": "4.0.0-internal.167c7cd"
65
+ "payload": "4.0.0-internal.16f218d"
68
66
  },
69
67
  "//deps_notes": {
70
- "zod": "zod is a hard dependency of @modelcontextprotocol/server, thus we can safely use it without it impacting bundle size. Make extra sure the zod version here matches exactly what's defined in the dependencies of @modelcontextprotocol/server to avoid duplicate versions being installed.",
71
68
  "tsx": "Required by the `bin.js` stdio mcp. Keep the version pinned to whatever `payload` ships to avoid duplicate installs."
72
69
  },
73
70
  "homepage:": "https://payloadcms.com",
@@ -77,9 +74,7 @@
77
74
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
78
75
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
79
76
  "clean": "rimraf {dist,*.tsbuildinfo}",
80
- "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
81
- "lint": "eslint .",
82
- "lint:fix": "eslint . --fix",
77
+ "copyfiles": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
83
78
  "pack:plugin": "pnpm build && pnpm pack"
84
79
  }
85
80
  }
@@ -1,10 +1,11 @@
1
1
  import type { PayloadRequest, SanitizedPermissions } from 'payload'
2
2
 
3
- import { getAccessResults, UnauthorizedError } from 'payload'
3
+ import { executeAuthStrategies, getAccessResults, UnauthorizedError } from 'payload'
4
4
 
5
5
  import type { AuthorizedMCP, MCPItem } from '../types.js'
6
6
 
7
7
  import { getPluginConfig } from '../utils/getPluginConfig.js'
8
+ import { authenticateLoginToken } from './oauthLoginToken.js'
8
9
 
9
10
  export type GetAuthorizedMCPArgs = {
10
11
  overrideAccess: boolean
@@ -34,9 +35,27 @@ export const getAuthorizedMCP: (args: GetAuthorizedMCPArgs) => Promise<Authorize
34
35
  const hasAuthorization = headers.has('Authorization')
35
36
 
36
37
  headers.set('DisableAutologin', 'true')
37
- req.user = (await req.payload.auth({ headers, req })).user
38
+ // Not `payload.auth()`, which also computes permissions that filterMCPItems computes anyway
39
+ req.user = (await executeAuthStrategies({ headers, payload: req.payload, req })).user
40
+
41
+ // Only bearer tokens that no auth strategy accepted get here, e.g. an OAuth access token.
42
+ // API keys use the `<collection> API-Key <key>` scheme instead of `Bearer`, so they never do.
43
+ const bearerToken = headers.get('Authorization')?.match(/^Bearer (.+)$/)?.[1]
44
+ // Sealed Payload login tokens from the built-in OAuth server
45
+ if (
46
+ !req.user &&
47
+ bearerToken &&
48
+ pluginConfig.oauth?.type === 'builtin' &&
49
+ !pluginConfig.oauth.issueToken
50
+ ) {
51
+ req.user = await authenticateLoginToken({ req, token: bearerToken })
52
+ }
53
+ if (!req.user && bearerToken && pluginConfig.oauth?.authenticate) {
54
+ req.user = await pluginConfig.oauth.authenticate({ req, token: bearerToken })
55
+ }
38
56
 
39
- if (hasAuthorization && !req.user) {
57
+ // With OAuth, the endpoint answers with a challenge that starts the client's sign-in
58
+ if (hasAuthorization && !req.user && !pluginConfig.oauth) {
40
59
  throw new UnauthorizedError(req.t)
41
60
  }
42
61
  }
@@ -95,12 +114,11 @@ const checkItemAccess = async ({
95
114
  case 'collectionTool':
96
115
  return (
97
116
  !item.tool.access ||
98
- (await item.tool.access({ collectionSlug: item.collectionSlug, permissions, req }))
117
+ (await item.tool.access({ slug: item.collectionSlug, permissions, req }))
99
118
  )
100
119
  case 'globalTool':
101
120
  return (
102
- !item.tool.access ||
103
- (await item.tool.access({ globalSlug: item.globalSlug, permissions, req }))
121
+ !item.tool.access || (await item.tool.access({ slug: item.globalSlug, permissions, req }))
104
122
  )
105
123
  case 'prompt':
106
124
  return !item.prompt.access || (await item.prompt.access({ permissions, req }))
@@ -3,6 +3,7 @@ import type { PayloadHandler, PayloadRequest } from 'payload'
3
3
  import {
4
4
  createMcpHandler,
5
5
  isLegacyRequest,
6
+ readRequestBody,
6
7
  WebStandardStreamableHTTPServerTransport,
7
8
  } from '@modelcontextprotocol/server'
8
9
  import { APIError } from 'payload'
@@ -10,6 +11,7 @@ import { APIError } from 'payload'
10
11
  import { buildMcpServer } from '../mcp/buildMcpServer.js'
11
12
  import { getPluginConfig } from '../utils/getPluginConfig.js'
12
13
  import { getAuthorizedMCP } from './access.js'
14
+ import { getMCPResource, oauthChallenge } from './oauth.js'
13
15
 
14
16
  export const mcpEndpoint: PayloadHandler = async (req) => {
15
17
  if (!req.url) {
@@ -17,6 +19,8 @@ export const mcpEndpoint: PayloadHandler = async (req) => {
17
19
  }
18
20
 
19
21
  req.payloadAPI = 'MCP' as const
22
+ // Lets auth strategies check that an OAuth access token was issued for this MCP server
23
+ req.context.mcp = { resource: getMCPResource({ req }) }
20
24
 
21
25
  const pluginConfig = getPluginConfig({ config: req.payload.config })
22
26
  const overrideAccessParam = new URL(req.url).searchParams.get('overrideAccess')
@@ -33,14 +37,22 @@ export const mcpEndpoint: PayloadHandler = async (req) => {
33
37
  }
34
38
 
35
39
  const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })
40
+
41
+ if (pluginConfig.oauth && !req.user) {
42
+ return oauthChallenge({ req })
43
+ }
44
+
45
+ const maxRequestBodySize = pluginConfig.mcp?.maxRequestBodySize
36
46
  // Payload augments the original web-standard Request in place.
37
47
  const mcpRequest = req as PayloadRequest & Request
48
+ const parsedBody = await parseRequestBody({ maxRequestBodySize, request: mcpRequest })
38
49
 
39
50
  // Keep the old JSON-only, stateless behavior because the SDK's 2025 fallback uses SSE.
40
- if (await isLegacyRequest(mcpRequest)) {
51
+ if (await isLegacyRequest(mcpRequest, parsedBody, { maxRequestBodySize })) {
41
52
  const server = buildMcpServer({ authorizedMCP, pluginConfig, req })
42
53
  const transport = new WebStandardStreamableHTTPServerTransport({
43
54
  enableJsonResponse: true,
55
+ maxRequestBodySize,
44
56
  sessionIdGenerator: undefined, // stateless mode
45
57
  })
46
58
  transport.onerror = (err) => {
@@ -49,7 +61,7 @@ export const mcpEndpoint: PayloadHandler = async (req) => {
49
61
 
50
62
  try {
51
63
  await server.connect(transport)
52
- return await transport.handleRequest(mcpRequest)
64
+ return await transport.handleRequest(mcpRequest, { parsedBody })
53
65
  } finally {
54
66
  await server.close().catch((err) => {
55
67
  req.payload.logger.error({ err, msg: 'Error closing MCP server' })
@@ -59,6 +71,7 @@ export const mcpEndpoint: PayloadHandler = async (req) => {
59
71
 
60
72
  const handler = createMcpHandler(() => buildMcpServer({ authorizedMCP, pluginConfig, req }), {
61
73
  legacy: 'reject',
74
+ maxRequestBodySize,
62
75
  // SDK subscriptions always use SSE, so disable them to keep every response JSON-only.
63
76
  maxSubscriptions: 0,
64
77
  onerror: (err) => {
@@ -68,10 +81,35 @@ export const mcpEndpoint: PayloadHandler = async (req) => {
68
81
  })
69
82
 
70
83
  try {
71
- return await handler.fetch(mcpRequest)
84
+ return await handler.fetch(mcpRequest, { parsedBody })
72
85
  } finally {
73
86
  await handler.close().catch((err) => {
74
87
  req.payload.logger.error({ err, msg: 'Error closing modern MCP handler' })
75
88
  })
76
89
  }
77
90
  }
91
+
92
+ /**
93
+ * Parses a POST body once so the era check and the SDK handler can share it. The SDK
94
+ * skips its size limit for a pre-parsed body, so this reads with the same limit. It reads
95
+ * a clone and returns `undefined` for any body the SDK should reject (too large, unreadable,
96
+ * or not JSON), leaving the original request for the SDK to read and answer.
97
+ */
98
+ const parseRequestBody = async ({
99
+ maxRequestBodySize,
100
+ request,
101
+ }: {
102
+ maxRequestBodySize?: number
103
+ request: Request
104
+ }): Promise<unknown> => {
105
+ if (request.method.toUpperCase() !== 'POST') {
106
+ return undefined
107
+ }
108
+
109
+ try {
110
+ const body = await readRequestBody(request.clone(), maxRequestBodySize)
111
+ return body.tooLarge ? undefined : JSON.parse(body.text)
112
+ } catch {
113
+ return undefined
114
+ }
115
+ }