@payloadcms/plugin-mcp 4.0.0-internal.40de3ec → 4.0.0-internal.4cbdd50

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 (201) hide show
  1. package/dist/defaultAccess.d.ts +3 -0
  2. package/dist/defaultAccess.d.ts.map +1 -0
  3. package/dist/defaultAccess.js +3 -0
  4. package/dist/defaultAccess.js.map +1 -0
  5. package/dist/endpoint/access.d.ts +17 -5
  6. package/dist/endpoint/access.d.ts.map +1 -1
  7. package/dist/endpoint/access.js +82 -88
  8. package/dist/endpoint/access.js.map +1 -1
  9. package/dist/endpoint/index.d.ts.map +1 -1
  10. package/dist/endpoint/index.js +11 -0
  11. package/dist/endpoint/index.js.map +1 -1
  12. package/dist/exports/client.d.ts +1 -1
  13. package/dist/exports/client.d.ts.map +1 -1
  14. package/dist/exports/client.js +1 -1
  15. package/dist/exports/client.js.map +1 -1
  16. package/dist/exports/internal.d.ts +2 -0
  17. package/dist/exports/internal.d.ts.map +1 -0
  18. package/dist/exports/internal.js +3 -0
  19. package/dist/exports/internal.js.map +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +13 -18
  22. package/dist/index.js.map +1 -1
  23. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  24. package/dist/mcp/buildMcpServer.js +102 -71
  25. package/dist/mcp/buildMcpServer.js.map +1 -1
  26. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  27. package/dist/mcp/builtin/collections/authTools.js +44 -6
  28. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  29. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  30. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  31. package/dist/mcp/builtin/collections/countTool.js +69 -0
  32. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  33. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  34. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  35. package/dist/mcp/builtin/collections/countVersionsTool.js +65 -0
  36. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  37. package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
  38. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  39. package/dist/mcp/builtin/collections/createTool.js +38 -42
  40. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  41. package/dist/mcp/builtin/collections/deleteTool.d.ts +1 -1
  42. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  43. package/dist/mcp/builtin/collections/deleteTool.js +14 -20
  44. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  45. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  46. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  47. package/dist/mcp/builtin/collections/duplicateTool.js +97 -0
  48. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  49. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  50. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  51. package/dist/mcp/builtin/collections/findDistinctTool.js +93 -0
  52. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  53. package/dist/mcp/builtin/collections/findTool.d.ts +1 -1
  54. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  55. package/dist/mcp/builtin/collections/findTool.js +49 -43
  56. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  57. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  58. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  59. package/dist/mcp/builtin/collections/findVersionByIDTool.js +84 -0
  60. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  61. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  62. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  63. package/dist/mcp/builtin/collections/findVersionsTool.js +99 -0
  64. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  65. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  66. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  67. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  68. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  69. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  70. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  71. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +47 -0
  72. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  73. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  74. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  75. package/dist/mcp/builtin/collections/restoreVersionTool.js +82 -0
  76. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  77. package/dist/mcp/builtin/collections/updateTool.d.ts +1 -1
  78. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  79. package/dist/mcp/builtin/collections/updateTool.js +87 -86
  80. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  81. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  82. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  83. package/dist/mcp/builtin/getConfigInfoTool.js +71 -0
  84. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  85. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  86. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  87. package/dist/mcp/builtin/globals/countVersionsTool.js +65 -0
  88. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  89. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  90. package/dist/mcp/builtin/globals/findTool.js +18 -21
  91. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  92. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  93. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  94. package/dist/mcp/builtin/globals/findVersionByIDTool.js +80 -0
  95. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  96. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  97. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  98. package/dist/mcp/builtin/globals/findVersionsTool.js +95 -0
  99. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  100. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  101. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  102. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +47 -0
  103. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  104. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  105. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  106. package/dist/mcp/builtin/globals/restoreVersionTool.js +78 -0
  107. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  108. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  109. package/dist/mcp/builtin/globals/updateTool.js +31 -40
  110. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  111. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  112. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  113. package/dist/mcp/builtin/validateEntityData.js +82 -0
  114. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  115. package/dist/mcp/builtinTools.d.ts +144 -19
  116. package/dist/mcp/builtinTools.d.ts.map +1 -1
  117. package/dist/mcp/builtinTools.js +119 -20
  118. package/dist/mcp/builtinTools.js.map +1 -1
  119. package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
  120. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  121. package/dist/mcp/sanitizeMCPConfig.js +120 -58
  122. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  123. package/dist/stdio.d.ts +3 -2
  124. package/dist/stdio.d.ts.map +1 -1
  125. package/dist/stdio.js +27 -8
  126. package/dist/stdio.js.map +1 -1
  127. package/dist/types.d.ts +62 -108
  128. package/dist/types.d.ts.map +1 -1
  129. package/dist/types.js +4 -4
  130. package/dist/types.js.map +1 -1
  131. package/dist/utils/getPluginConfig.d.ts +1 -1
  132. package/dist/utils/getPluginConfig.js +1 -1
  133. package/dist/utils/getPluginConfig.js.map +1 -1
  134. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
  135. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  136. package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
  137. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  138. package/dist/utils/whereSchema.d.ts +9 -0
  139. package/dist/utils/whereSchema.d.ts.map +1 -0
  140. package/dist/utils/whereSchema.js +13 -0
  141. package/dist/utils/whereSchema.js.map +1 -0
  142. package/package.json +8 -11
  143. package/src/defaultAccess.ts +3 -0
  144. package/src/endpoint/access.ts +88 -101
  145. package/src/endpoint/index.ts +14 -1
  146. package/src/exports/client.ts +2 -1
  147. package/src/exports/internal.ts +1 -0
  148. package/src/index.ts +8 -16
  149. package/src/mcp/buildMcpServer.ts +131 -96
  150. package/src/mcp/builtin/collections/authTools.ts +45 -9
  151. package/src/mcp/builtin/collections/countTool.ts +74 -0
  152. package/src/mcp/builtin/collections/countVersionsTool.ts +70 -0
  153. package/src/mcp/builtin/collections/createTool.ts +55 -59
  154. package/src/mcp/builtin/collections/deleteTool.ts +19 -16
  155. package/src/mcp/builtin/collections/duplicateTool.ts +135 -0
  156. package/src/mcp/builtin/collections/findDistinctTool.ts +120 -0
  157. package/src/mcp/builtin/collections/findTool.ts +63 -33
  158. package/src/mcp/builtin/collections/findVersionByIDTool.ts +110 -0
  159. package/src/mcp/builtin/collections/findVersionsTool.ts +155 -0
  160. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  161. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +46 -0
  162. package/src/mcp/builtin/collections/restoreVersionTool.ts +108 -0
  163. package/src/mcp/builtin/collections/updateTool.ts +111 -110
  164. package/src/mcp/builtin/getConfigInfoTool.ts +69 -0
  165. package/src/mcp/builtin/globals/countVersionsTool.ts +69 -0
  166. package/src/mcp/builtin/globals/findTool.ts +26 -17
  167. package/src/mcp/builtin/globals/findVersionByIDTool.ts +104 -0
  168. package/src/mcp/builtin/globals/findVersionsTool.ts +148 -0
  169. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +41 -0
  170. package/src/mcp/builtin/globals/restoreVersionTool.ts +100 -0
  171. package/src/mcp/builtin/globals/updateTool.ts +50 -55
  172. package/src/mcp/builtin/validateEntityData.ts +132 -0
  173. package/src/mcp/builtinTools.ts +111 -41
  174. package/src/mcp/sanitizeMCPConfig.ts +116 -78
  175. package/src/stdio.ts +23 -8
  176. package/src/types.ts +77 -112
  177. package/src/utils/getPluginConfig.ts +1 -1
  178. package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
  179. package/src/utils/whereSchema.ts +24 -0
  180. package/dist/collection/getAccessField.d.ts +0 -12
  181. package/dist/collection/getAccessField.d.ts.map +0 -1
  182. package/dist/collection/getAccessField.js +0 -57
  183. package/dist/collection/getAccessField.js.map +0 -1
  184. package/dist/collection/index.d.ts +0 -6
  185. package/dist/collection/index.d.ts.map +0 -1
  186. package/dist/collection/index.js +0 -60
  187. package/dist/collection/index.js.map +0 -1
  188. package/dist/components/AccessField/index.client.d.ts +0 -10
  189. package/dist/components/AccessField/index.client.d.ts.map +0 -1
  190. package/dist/components/AccessField/index.client.js +0 -305
  191. package/dist/components/AccessField/index.client.js.map +0 -1
  192. package/dist/components/AccessField/index.css +0 -93
  193. package/dist/utils/schemaConversion/buildToolInput.d.ts +0 -29
  194. package/dist/utils/schemaConversion/buildToolInput.d.ts.map +0 -1
  195. package/dist/utils/schemaConversion/buildToolInput.js +0 -51
  196. package/dist/utils/schemaConversion/buildToolInput.js.map +0 -1
  197. package/src/collection/getAccessField.ts +0 -64
  198. package/src/collection/index.ts +0 -64
  199. package/src/components/AccessField/index.client.tsx +0 -344
  200. package/src/components/AccessField/index.css +0 -93
  201. package/src/utils/schemaConversion/buildToolInput.ts +0 -68
package/dist/types.d.ts CHANGED
@@ -1,32 +1,15 @@
1
- import type { CallToolResult, ContentBlock, JsonSchemaType, McpServer, ResourceTemplate, ServerContext, StandardSchemaWithJSON } from '@modelcontextprotocol/server';
2
- import type { AuthCollectionSlug, CollectionConfig, CollectionSlug, DefaultDocumentIDType, GlobalSlug, MaybePromise, PayloadRequest, TypedUser } from 'payload';
1
+ import type { CallToolResult, ContentBlock, JsonSchemaType, McpServer, ResourceTemplate, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from '@modelcontextprotocol/server';
2
+ import type { AuthCollectionSlug, CollectionSlug, GlobalSlug, MaybePromise, PayloadRequest, SanitizedPermissions, TypedUser } from 'payload';
3
+ import type { GetAuthorizedMCPArgs } from './endpoint/access.js';
3
4
  import type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName } from './mcp/builtinTools.js';
4
5
  export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName };
5
- /** Re-exported from `@modelcontextprotocol/server` — the JSON Schema shape the MCP runtime validates against. */
6
- export type { JsonSchemaType, StandardSchemaWithJSON };
6
+ /** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */
7
+ export type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations };
7
8
  /**
8
9
  * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
9
10
  * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).
10
11
  */
11
12
  export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON;
12
- /**
13
- * Serializable mirror of `SanitizedMCPPluginConfig` for client components —
14
- * the full sanitized config carries functions (tool handlers, etc.) that can't
15
- * cross the server→client boundary. Built by `sanitizeClientPluginConfig` and
16
- * passed to the `AccessField` component via `clientProps`.
17
- *
18
- * @internal
19
- */
20
- export type ClientMCPPluginConfig = {
21
- items: Array<{
22
- collectionSlug?: string;
23
- description: string;
24
- globalSlug?: string;
25
- key: string;
26
- label: string;
27
- type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool';
28
- }>;
29
- };
30
13
  export type MCPToolResponse = {
31
14
  content: ContentBlock[];
32
15
  /**
@@ -42,6 +25,16 @@ export type MCPResponseOverride = (response: MCPToolResponse, doc: Record<string
42
25
  * its inferred output; anything else falls back to `Record<string, unknown>`.
43
26
  */
44
27
  export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON ? StandardSchemaWithJSON extends TSchema ? Record<string, unknown> : StandardSchemaWithJSON.InferOutput<TSchema> : Record<string, unknown>;
28
+ export type MCPAccessArgs = {
29
+ permissions?: SanitizedPermissions;
30
+ req: PayloadRequest;
31
+ };
32
+ export type CollectionMCPAccessArgs = {
33
+ collectionSlug: CollectionSlug;
34
+ } & MCPAccessArgs;
35
+ export type GlobalMCPAccessArgs = {
36
+ globalSlug: GlobalSlug;
37
+ } & MCPAccessArgs;
45
38
  export type ToolHandlerArgs<TSchema = undefined> = {
46
39
  authorizedMCP: AuthorizedMCP;
47
40
  input: TypedInput<TSchema>;
@@ -55,6 +48,8 @@ export type GlobalToolHandlerArgs<TSchema = undefined> = {
55
48
  globalSlug: GlobalSlug;
56
49
  } & ToolHandlerArgs<TSchema>;
57
50
  export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
51
+ access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
52
+ annotations?: ToolAnnotations;
58
53
  description: string;
59
54
  handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
60
55
  input?: TSchema;
@@ -63,29 +58,31 @@ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema |
63
58
  */
64
59
  overrideResponse?: MCPResponseOverride;
65
60
  };
66
- /**
67
- * `TSchema` is the schema itself (Standard Schema, raw JSON Schema, or undefined).
68
- * The function-form variant of `input` carries a concrete `{ collectionSchema: JsonSchemaType }`
69
- * parameter type so callers can write `({ collectionSchema }) => …` without annotating it.
70
- */
71
61
  export type CollectionTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
62
+ access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>;
72
63
  handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
73
- input?: ((args: {
74
- collectionSchema: JsonSchemaType;
75
- }) => TSchema) | TSchema;
76
- } & Pick<Tool, 'description' | 'overrideResponse'>;
64
+ input?: TSchema;
65
+ } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>;
77
66
  export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
67
+ access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>;
78
68
  handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
79
- input?: ((args: {
80
- globalSchema: JsonSchemaType;
81
- }) => TSchema) | TSchema;
82
- } & Pick<Tool, 'description' | 'overrideResponse'>;
69
+ input?: TSchema;
70
+ } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>;
83
71
  /**
84
72
  * Configures (or disables) a built-in tool without replacing it.
85
73
  * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
86
74
  * required handler) from being silently accepted at a built-in key slot.
87
75
  */
88
- export type MCPBuiltInToolOverride = {
76
+ export type MCPBuiltInCollectionToolOverride = {
77
+ access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>;
78
+ annotations?: ToolAnnotations;
79
+ description?: string;
80
+ handler?: never;
81
+ overrideResponse?: MCPResponseOverride;
82
+ };
83
+ export type MCPBuiltInGlobalToolOverride = {
84
+ access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>;
85
+ annotations?: ToolAnnotations;
89
86
  description?: string;
90
87
  handler?: never;
91
88
  overrideResponse?: MCPResponseOverride;
@@ -97,19 +94,19 @@ export type MCPBuiltInToolOverride = {
97
94
  */
98
95
  export type MCPTopLevelToolEntry = Tool;
99
96
  export type MCPCollectionToolsMap = {
100
- [customToolName: string]: boolean | CollectionTool | MCPBuiltInToolOverride | undefined;
97
+ [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined;
101
98
  } & {
102
- [K in MCPCollectionBuiltinName]?: false | MCPBuiltInToolOverride;
99
+ [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride;
103
100
  };
104
101
  export type MCPAuthCollectionToolsMap = {
105
- [K in MCPCollectionAuthToolName]?: MCPBuiltInToolOverride | true;
102
+ [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true;
106
103
  } & MCPCollectionToolsMap;
107
104
  /** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
108
105
  export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug ? MCPAuthCollectionToolsMap : MCPCollectionToolsMap;
109
106
  export type MCPGlobalToolsMap = {
110
- [customToolName: string]: boolean | GlobalTool | MCPBuiltInToolOverride | undefined;
107
+ [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined;
111
108
  } & {
112
- [K in MCPGlobalBuiltinName]?: false | MCPBuiltInToolOverride;
109
+ [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride;
113
110
  };
114
111
  export type MCPTopLevelToolsMap = Record<string, Tool>;
115
112
  export type PromptHandlerArgs<TSchema = undefined> = {
@@ -118,6 +115,7 @@ export type PromptHandlerArgs<TSchema = undefined> = {
118
115
  serverContext: ServerContext;
119
116
  };
120
117
  export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
118
+ access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
121
119
  argsSchema: TSchema;
122
120
  description: string;
123
121
  handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
@@ -139,6 +137,7 @@ export type ResourceHandlerArgs = {
139
137
  uri: URL;
140
138
  };
141
139
  export type Resource = {
140
+ access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
142
141
  description: string;
143
142
  handler: (args: ResourceHandlerArgs) => MaybePromise<{
144
143
  contents: Array<{
@@ -172,7 +171,7 @@ export type MCPPluginConfig = {
172
171
  collections?: {
173
172
  [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>;
174
173
  };
175
- /** Skip MCP registration. The API key collection is still added (so DB / types stay stable). */
174
+ /** Skip MCP endpoint registration. */
176
175
  disabled?: boolean;
177
176
  globals?: {
178
177
  [Slug in GlobalSlug]?: MCPPluginGlobalConfig;
@@ -181,91 +180,46 @@ export type MCPPluginConfig = {
181
180
  serverOptions?: MCPServerOptions;
182
181
  verboseLogs?: boolean;
183
182
  };
184
- overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig;
185
- /** Replace the default API-key auth with a custom resolver. */
186
- overrideAuth?: (args: {
187
- getAPIKeyDoc: (overrideApiKey?: string) => Promise<MCPAPIKeysDoc>;
188
- getAuthorizedMCP: (args: {
189
- apiKeyDoc: MCPAPIKeysDoc;
190
- }) => AuthorizedMCP;
183
+ /** Replace the default MCP authorization resolver. */
184
+ overrideGetAuthorizedMCP?: (args: {
191
185
  pluginConfig: SanitizedMCPPluginConfig;
192
- req: PayloadRequest;
193
- }) => MaybePromise<AuthorizedMCP>;
186
+ } & GetAuthorizedMCPArgs) => MaybePromise<AuthorizedMCP>;
194
187
  prompts?: Record<string, Prompt>;
195
188
  resources?: Record<string, Resource>;
196
189
  /** Cross-cutting tools (not scoped to any collection or global). */
197
190
  tools?: MCPTopLevelToolsMap;
198
- userCollection?: CollectionSlug;
199
191
  };
200
192
  export type SanitizedMCPPluginConfig = {
201
193
  items: MCPItem[];
202
- userCollection: CollectionSlug;
203
- } & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>;
194
+ } & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideGetAuthorizedMCP'>;
204
195
  export type MCPServerOptions = {
205
196
  options?: ConstructorParameters<typeof McpServer>[1];
206
197
  serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>;
207
198
  };
208
199
  /**
209
- * Nested access tree as stored in the collection.
210
- * A `false` leaf disables that tool; missing keys defer to
211
- * defaults (built-in CRUD is on, opt-in tools are off).
212
- */
213
- export type MCPAPIKeysDocAccessTree = {
214
- collections?: {
215
- [CollectionSlug: CollectionSlug]: {
216
- [ToolKey: string]: boolean;
217
- };
218
- };
219
- globals?: {
220
- [GlobalSlug: GlobalSlug]: {
221
- [ToolKey: string]: boolean;
222
- };
223
- };
224
- prompts?: {
225
- [PromptKey: string]: boolean;
226
- };
227
- resources?: {
228
- [ResourceKey: string]: boolean;
229
- };
230
- tools?: {
231
- [ToolKey: string]: boolean;
232
- };
233
- };
234
- /**
235
- * Stored on `payload-mcp-api-keys` docs
236
- */
237
- export type MCPAPIKeysDoc = {
238
- access: MCPAPIKeysDocAccessTree;
239
- id: DefaultDocumentIDType;
240
- overrideAccess?: boolean;
241
- user: null | TypedUser;
242
- };
243
- /**
244
- * One MCP primitive — tool, prompt, or resource — paired with the metadata both
245
- * the endpoint and the API key collection need. Built by `sanitizeMCPConfig`,
246
- * filtered by `getAuthorizedMCP`, registered by the MCP endpoint.
200
+ * One MCP primitive plus the metadata needed for config-driven filtering and
201
+ * registration.
247
202
  *
248
- * - `key`: the config identifier (`find`, `echo`). Used for the API-key deny
249
- * lookup and as the admin checkbox field name. For collection/global tools,
250
- * the MCP wire name (`findPosts`) is derived from `key + slug` at
251
- * registration time.
252
- * - `label`: human-readable admin-UI display text for the checkbox.
253
- * - `tool` / `prompt` / `resource`: the live primitive (its own
254
- * `description` is what both MCP clients and the admin UI surface).
203
+ * - `configKey`: the config identifier, e.g. `find` or `echo`.
204
+ * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
205
+ * - `label`: human-readable display text.
255
206
  */
256
207
  export type MCPItemBase = {
257
- key: string;
208
+ configKey: string;
258
209
  label: string;
210
+ mcpName: string;
259
211
  };
260
- export type MCPItem = ({
212
+ export type CollectionMCPItem = {
261
213
  collectionSlug: CollectionSlug;
262
214
  tool: CollectionTool;
263
215
  type: 'collectionTool';
264
- } & MCPItemBase) | ({
216
+ } & MCPItemBase;
217
+ export type GlobalMCPItem = {
265
218
  globalSlug: GlobalSlug;
266
219
  tool: GlobalTool;
267
220
  type: 'globalTool';
268
- } & MCPItemBase) | ({
221
+ } & MCPItemBase;
222
+ export type MCPItem = ({
269
223
  prompt: Prompt;
270
224
  type: 'prompt';
271
225
  } & MCPItemBase) | ({
@@ -274,12 +228,12 @@ export type MCPItem = ({
274
228
  } & MCPItemBase) | ({
275
229
  tool: Tool;
276
230
  type: 'tool';
277
- } & MCPItemBase);
231
+ } & MCPItemBase) | CollectionMCPItem | GlobalMCPItem;
278
232
  /**
279
- * The caller's identity + the MCP items they can use for this request. Returned
280
- * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers
281
- * receive this via `args.authorizedMCP` so they can spread
282
- * `localAPIDefaults(authorizedMCP)` into every local API call.
233
+ * The caller's identity + the MCP items authorized for this request. Disabled
234
+ * items and items blocked by access callbacks or Payload operation access are
235
+ * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
236
+ * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
283
237
  */
284
238
  export type AuthorizedMCP = {
285
239
  items: MCPItem[];
@@ -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,EACvB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK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CAAC,CAAC,CAAC,CAAA;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CACjE,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,cAAc,CAAA;IACpB,IAAI,EAAE,gBAAgB,CAAA;CACvB,GAAG,WAAW,CAAA;AAEf,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,YAAY,CAAA;CACnB,GAAG,WAAW,CAAA;AAEf,MAAM,MAAM,OAAO,GACf,CAAC;IACC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,QAAQ,CAAA;CACf,GAAG,WAAW,CAAC,GAChB,CAAC;IACC,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,WAAW,CAAC,GAChB,CAAC;IACC,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,WAAW,CAAC,GAChB,iBAAiB,GACjB,aAAa,CAAA;AAEjB;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CAAA"}
package/dist/types.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * The caller's identity + the MCP items they can use for this request. Returned
3
- * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers
4
- * receive this via `args.authorizedMCP` so they can spread
5
- * `localAPIDefaults(authorizedMCP)` into every local API call.
2
+ * The caller's identity + the MCP items authorized for this request. Disabled
3
+ * items and items blocked by access callbacks or Payload operation access are
4
+ * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
5
+ * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
6
6
  */ export { };
7
7
 
8
8
  //# sourceMappingURL=types.js.map
package/dist/types.js.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} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n TypedUser,\n} from 'payload'\n\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` — the JSON Schema shape the MCP runtime validates against. */\nexport type { JsonSchemaType, StandardSchemaWithJSON }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\n/**\n * Serializable mirror of `SanitizedMCPPluginConfig` for client components —\n * the full sanitized config carries functions (tool handlers, etc.) that can't\n * cross the server→client boundary. Built by `sanitizeClientPluginConfig` and\n * passed to the `AccessField` component via `clientProps`.\n *\n * @internal\n */\nexport type ClientMCPPluginConfig = {\n items: Array<{\n collectionSlug?: string\n description: string\n globalSlug?: string\n key: string\n label: string\n type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'\n }>\n}\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\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 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 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\n/**\n * `TSchema` is the schema itself (Standard Schema, raw JSON Schema, or undefined).\n * The function-form variant of `input` carries a concrete `{ collectionSchema: JsonSchemaType }`\n * parameter type so callers can write `({ collectionSchema }) => …` without annotating it.\n */\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: ((args: { collectionSchema: JsonSchemaType }) => TSchema) | TSchema\n} & Pick<Tool, 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: ((args: { globalSchema: JsonSchemaType }) => TSchema) | TSchema\n } & Pick<Tool, '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 MCPBuiltInToolOverride = {\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 | MCPBuiltInToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInToolOverride | 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 | MCPBuiltInToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInToolOverride\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 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 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 registration. The API key collection is still added (so DB / types stay stable). */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n /** Replace the default API-key auth with a custom resolver. */\n overrideAuth?: (args: {\n getAPIKeyDoc: (overrideApiKey?: string) => Promise<MCPAPIKeysDoc>\n getAuthorizedMCP: (args: { apiKeyDoc: MCPAPIKeysDoc }) => AuthorizedMCP\n pluginConfig: SanitizedMCPPluginConfig\n req: PayloadRequest\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 userCollection?: CollectionSlug\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n userCollection: CollectionSlug\n} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * Nested access tree as stored in the collection.\n * A `false` leaf disables that tool; missing keys defer to\n * defaults (built-in CRUD is on, opt-in tools are off).\n */\nexport type MCPAPIKeysDocAccessTree = {\n collections?: {\n [CollectionSlug: CollectionSlug]: {\n [ToolKey: string]: boolean\n }\n }\n globals?: {\n [GlobalSlug: GlobalSlug]: {\n [ToolKey: string]: boolean\n }\n }\n prompts?: {\n [PromptKey: string]: boolean\n }\n resources?: {\n [ResourceKey: string]: boolean\n }\n tools?: {\n [ToolKey: string]: boolean\n }\n}\n\n/**\n * Stored on `payload-mcp-api-keys` docs\n */\nexport type MCPAPIKeysDoc = {\n access: MCPAPIKeysDocAccessTree\n id: DefaultDocumentIDType\n overrideAccess?: boolean\n user: null | TypedUser\n}\n\n/**\n * One MCP primitive — tool, prompt, or resource — paired with the metadata both\n * the endpoint and the API key collection need. Built by `sanitizeMCPConfig`,\n * filtered by `getAuthorizedMCP`, registered by the MCP endpoint.\n *\n * - `key`: the config identifier (`find`, `echo`). Used for the API-key deny\n * lookup and as the admin checkbox field name. For collection/global tools,\n * the MCP wire name (`findPosts`) is derived from `key + slug` at\n * registration time.\n * - `label`: human-readable admin-UI display text for the checkbox.\n * - `tool` / `prompt` / `resource`: the live primitive (its own\n * `description` is what both MCP clients and the admin UI surface).\n */\nexport type MCPItemBase = {\n key: string\n label: string\n}\n\nexport type MCPItem =\n | ({\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n } & MCPItemBase)\n | ({\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n } & MCPItemBase)\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\n/**\n * The caller's identity + the MCP items they can use for this request. Returned\n * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers\n * receive this via `args.authorizedMCP` so they can spread\n * `localAPIDefaults(authorizedMCP)` into every local API call.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAgVA;;;;;CAKC,GACD,WAIC"}
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 TypedUser,\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 literal, or a Standard Schema instance (Zod, Valibot, …).\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\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 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 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 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 access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\nexport type MCPBuiltInGlobalToolOverride = {\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 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 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 mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n /** Replace the default MCP authorization resolver. */\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' | '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 caller's identity + the MCP items authorized for this request. Disabled\n * items and items blocked by access callbacks or Payload operation access are\n * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so\n * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AA6SA;;;;;CAKC,GACD,WAIC"}
@@ -3,7 +3,7 @@ import type { SanitizedMCPPluginConfig } from '../types.js';
3
3
  /**
4
4
  * Returns the sanitized plugin config — the form produced by
5
5
  * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
6
- * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.
6
+ * Callers downstream of plugin init can rely on `items` and other defaults
7
7
  * being fully resolved.
8
8
  */
9
9
  export declare const getPluginConfig: (args: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the sanitized plugin config — the form produced by
3
3
  * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
4
- * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.
4
+ * Callers downstream of plugin init can rely on `items` and other defaults
5
5
  * being fully resolved.
6
6
  */ export const getPluginConfig = ({ config })=>{
7
7
  const plugin = config.plugins?.find((plugin)=>plugin.slug === '@payloadcms/plugin-mcp');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/getPluginConfig.ts"],"sourcesContent":["import type { PluginsMap, SanitizedConfig } from 'payload'\n\nimport type { SanitizedMCPPluginConfig } from '../types.js'\n\n/**\n * Returns the sanitized plugin config — the form produced by\n * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.\n * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.\n * being fully resolved.\n */\nexport const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({\n config,\n}) => {\n const plugin = config.plugins?.find(\n (plugin) => plugin.slug === '@payloadcms/plugin-mcp',\n ) as PluginsMap['@payloadcms/plugin-mcp']\n\n if (!plugin) {\n throw new Error('MCP Plugin not found in config.plugins.')\n }\n\n // @ts-expect-error\n return plugin.sanitizedOptions\n}\n"],"names":["getPluginConfig","config","plugin","plugins","find","slug","Error","sanitizedOptions"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,MAAMA,kBAAmF,CAAC,EAC/FC,MAAM,EACP;IACC,MAAMC,SAASD,OAAOE,OAAO,EAAEC,KAC7B,CAACF,SAAWA,OAAOG,IAAI,KAAK;IAG9B,IAAI,CAACH,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,mBAAmB;IACnB,OAAOJ,OAAOK,gBAAgB;AAChC,EAAC"}
1
+ {"version":3,"sources":["../../src/utils/getPluginConfig.ts"],"sourcesContent":["import type { PluginsMap, SanitizedConfig } from 'payload'\n\nimport type { SanitizedMCPPluginConfig } from '../types.js'\n\n/**\n * Returns the sanitized plugin config — the form produced by\n * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.\n * Callers downstream of plugin init can rely on `items` and other defaults\n * being fully resolved.\n */\nexport const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({\n config,\n}) => {\n const plugin = config.plugins?.find(\n (plugin) => plugin.slug === '@payloadcms/plugin-mcp',\n ) as PluginsMap['@payloadcms/plugin-mcp']\n\n if (!plugin) {\n throw new Error('MCP Plugin not found in config.plugins.')\n }\n\n // @ts-expect-error\n return plugin.sanitizedOptions\n}\n"],"names":["getPluginConfig","config","plugin","plugins","find","slug","Error","sanitizedOptions"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,MAAMA,kBAAmF,CAAC,EAC/FC,MAAM,EACP;IACC,MAAMC,SAASD,OAAOE,OAAO,EAAEC,KAC7B,CAACF,SAAWA,OAAOG,IAAI,KAAK;IAG9B,IAAI,CAACH,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,mBAAmB;IACnB,OAAOJ,OAAOK,gBAAgB;AAChC,EAAC"}
@@ -0,0 +1,11 @@
1
+ import { type CollectionSlug, type GlobalSlug, type PayloadRequest } from 'payload';
2
+ import type { JsonSchemaType } from '../../types.js';
3
+ export declare const getCollectionInputSchema: ({ collectionSlug, req, }: {
4
+ collectionSlug: CollectionSlug;
5
+ req: PayloadRequest;
6
+ }) => JsonSchemaType | null;
7
+ export declare const getGlobalInputSchema: ({ globalSlug, req, }: {
8
+ globalSlug: GlobalSlug;
9
+ req: PayloadRequest;
10
+ }) => JsonSchemaType | null;
11
+ //# sourceMappingURL=getEntityInputSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEntityInputSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/getEntityInputSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,cAAc,EAGpB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AASpD,eAAO,MAAM,wBAAwB,GAAI,0BAGtC;IACD,cAAc,EAAE,cAAc,CAAA;IAC9B,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,cAAc,GAAG,IAYpB,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,sBAGlC;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,cAAc,GAAG,IAYpB,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { entityToStandaloneJSONSchema } from 'payload';
2
+ import { getCollectionVirtualFieldNames, getGlobalVirtualFieldNames } from '../getVirtualFieldNames.js';
3
+ import { removeVirtualFieldsFromSchema } from './removeVirtualFieldsFromSchema.js';
4
+ import { sanitizeEntitySchema } from './sanitizeEntitySchema.js';
5
+ export const getCollectionInputSchema = ({ collectionSlug, req })=>{
6
+ const collection = req.payload.collections[collectionSlug]?.config;
7
+ if (!collection) {
8
+ return null;
9
+ }
10
+ return buildEntityInputSchema({
11
+ entity: collection,
12
+ req,
13
+ virtualFieldNames: getCollectionVirtualFieldNames(req.payload.config, collectionSlug)
14
+ });
15
+ };
16
+ export const getGlobalInputSchema = ({ globalSlug, req })=>{
17
+ const global = req.payload.config.globals.find((globalConfig)=>globalConfig.slug === globalSlug);
18
+ if (!global) {
19
+ return null;
20
+ }
21
+ return buildEntityInputSchema({
22
+ entity: global,
23
+ req,
24
+ virtualFieldNames: getGlobalVirtualFieldNames(req.payload.config, globalSlug)
25
+ });
26
+ };
27
+ const buildEntityInputSchema = ({ entity, req, virtualFieldNames })=>sanitizeEntitySchema(removeVirtualFieldsFromSchema(entityToStandaloneJSONSchema({
28
+ config: req.payload.config,
29
+ defaultIDType: req.payload.db.defaultIDType,
30
+ entity,
31
+ i18n: req.i18n
32
+ }), virtualFieldNames));
33
+
34
+ //# sourceMappingURL=getEntityInputSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/schemaConversion/getEntityInputSchema.ts"],"sourcesContent":["import {\n type CollectionSlug,\n entityToStandaloneJSONSchema,\n type GlobalSlug,\n type PayloadRequest,\n type SanitizedCollectionConfig,\n type SanitizedGlobalConfig,\n} from 'payload'\n\nimport type { JsonSchemaType } from '../../types.js'\n\nimport {\n getCollectionVirtualFieldNames,\n getGlobalVirtualFieldNames,\n} from '../getVirtualFieldNames.js'\nimport { removeVirtualFieldsFromSchema } from './removeVirtualFieldsFromSchema.js'\nimport { sanitizeEntitySchema } from './sanitizeEntitySchema.js'\n\nexport const getCollectionInputSchema = ({\n collectionSlug,\n req,\n}: {\n collectionSlug: CollectionSlug\n req: PayloadRequest\n}): JsonSchemaType | null => {\n const collection = req.payload.collections[collectionSlug]?.config\n\n if (!collection) {\n return null\n }\n\n return buildEntityInputSchema({\n entity: collection,\n req,\n virtualFieldNames: getCollectionVirtualFieldNames(req.payload.config, collectionSlug),\n })\n}\n\nexport const getGlobalInputSchema = ({\n globalSlug,\n req,\n}: {\n globalSlug: GlobalSlug\n req: PayloadRequest\n}): JsonSchemaType | null => {\n const global = req.payload.config.globals.find((globalConfig) => globalConfig.slug === globalSlug)\n\n if (!global) {\n return null\n }\n\n return buildEntityInputSchema({\n entity: global,\n req,\n virtualFieldNames: getGlobalVirtualFieldNames(req.payload.config, globalSlug),\n })\n}\n\nconst buildEntityInputSchema = ({\n entity,\n req,\n virtualFieldNames,\n}: {\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n req: PayloadRequest\n virtualFieldNames: string[]\n}): JsonSchemaType =>\n sanitizeEntitySchema(\n removeVirtualFieldsFromSchema(\n entityToStandaloneJSONSchema({\n config: req.payload.config,\n defaultIDType: req.payload.db.defaultIDType,\n entity,\n i18n: req.i18n,\n }) as unknown as JsonSchemaType,\n virtualFieldNames,\n ),\n )\n"],"names":["entityToStandaloneJSONSchema","getCollectionVirtualFieldNames","getGlobalVirtualFieldNames","removeVirtualFieldsFromSchema","sanitizeEntitySchema","getCollectionInputSchema","collectionSlug","req","collection","payload","collections","config","buildEntityInputSchema","entity","virtualFieldNames","getGlobalInputSchema","globalSlug","global","globals","find","globalConfig","slug","defaultIDType","db","i18n"],"mappings":"AAAA,SAEEA,4BAA4B,QAKvB,UAAS;AAIhB,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,6BAA4B;AACnC,SAASC,6BAA6B,QAAQ,qCAAoC;AAClF,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhE,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,cAAc,EACdC,GAAG,EAIJ;IACC,MAAMC,aAAaD,IAAIE,OAAO,CAACC,WAAW,CAACJ,eAAe,EAAEK;IAE5D,IAAI,CAACH,YAAY;QACf,OAAO;IACT;IAEA,OAAOI,uBAAuB;QAC5BC,QAAQL;QACRD;QACAO,mBAAmBb,+BAA+BM,IAAIE,OAAO,CAACE,MAAM,EAAEL;IACxE;AACF,EAAC;AAED,OAAO,MAAMS,uBAAuB,CAAC,EACnCC,UAAU,EACVT,GAAG,EAIJ;IACC,MAAMU,SAASV,IAAIE,OAAO,CAACE,MAAM,CAACO,OAAO,CAACC,IAAI,CAAC,CAACC,eAAiBA,aAAaC,IAAI,KAAKL;IAEvF,IAAI,CAACC,QAAQ;QACX,OAAO;IACT;IAEA,OAAOL,uBAAuB;QAC5BC,QAAQI;QACRV;QACAO,mBAAmBZ,2BAA2BK,IAAIE,OAAO,CAACE,MAAM,EAAEK;IACpE;AACF,EAAC;AAED,MAAMJ,yBAAyB,CAAC,EAC9BC,MAAM,EACNN,GAAG,EACHO,iBAAiB,EAKlB,GACCV,qBACED,8BACEH,6BAA6B;QAC3BW,QAAQJ,IAAIE,OAAO,CAACE,MAAM;QAC1BW,eAAef,IAAIE,OAAO,CAACc,EAAE,CAACD,aAAa;QAC3CT;QACAW,MAAMjB,IAAIiB,IAAI;IAChB,IACAV"}
@@ -0,0 +1,9 @@
1
+ import type { Where } from 'payload';
2
+ import { z } from 'zod';
3
+ /**
4
+ * - Validates the `where` input of collection tools against Payload's `Where` shape
5
+ * - Field keys map to operator objects restricted to `validOperators`
6
+ * - `and` / `or` nest recursively
7
+ */
8
+ export declare const whereSchema: z.ZodType<Where>;
9
+ //# sourceMappingURL=whereSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whereSchema.d.ts","sourceRoot":"","sources":["../../src/utils/whereSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAGpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CASqD,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { validOperators } from 'payload/shared';
2
+ import { z } from 'zod';
3
+ const whereFieldSchema = z.partialRecord(z.enum(validOperators), z.unknown()).describe('Field query operators');
4
+ /**
5
+ * - Validates the `where` input of collection tools against Payload's `Where` shape
6
+ * - Field keys map to operator objects restricted to `validOperators`
7
+ * - `and` / `or` nest recursively
8
+ */ export const whereSchema = z.lazy(()=>z.object({
9
+ and: z.array(whereSchema).optional(),
10
+ or: z.array(whereSchema).optional()
11
+ }).catchall(whereFieldSchema)).describe('Where clause using field names with Payload query operators, plus and/or groups');
12
+
13
+ //# sourceMappingURL=whereSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/whereSchema.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { validOperators } from 'payload/shared'\nimport { z } from 'zod'\n\nconst whereFieldSchema = z\n .partialRecord(z.enum(validOperators), z.unknown())\n .describe('Field query operators')\n\n/**\n * - Validates the `where` input of collection tools against Payload's `Where` shape\n * - Field keys map to operator objects restricted to `validOperators`\n * - `and` / `or` nest recursively\n */\nexport const whereSchema: z.ZodType<Where> = z\n .lazy(() =>\n z\n .object({\n and: z.array(whereSchema).optional(),\n or: z.array(whereSchema).optional(),\n })\n .catchall(whereFieldSchema),\n )\n .describe('Where clause using field names with Payload query operators, plus and/or groups')\n"],"names":["validOperators","z","whereFieldSchema","partialRecord","enum","unknown","describe","whereSchema","lazy","object","and","array","optional","or","catchall"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAEvB,MAAMC,mBAAmBD,EACtBE,aAAa,CAACF,EAAEG,IAAI,CAACJ,iBAAiBC,EAAEI,OAAO,IAC/CC,QAAQ,CAAC;AAEZ;;;;CAIC,GACD,OAAO,MAAMC,cAAgCN,EAC1CO,IAAI,CAAC,IACJP,EACGQ,MAAM,CAAC;QACNC,KAAKT,EAAEU,KAAK,CAACJ,aAAaK,QAAQ;QAClCC,IAAIZ,EAAEU,KAAK,CAACJ,aAAaK,QAAQ;IACnC,GACCE,QAAQ,CAACZ,mBAEbI,QAAQ,CAAC,mFAAkF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-mcp",
3
- "version": "4.0.0-internal.40de3ec",
3
+ "version": "4.0.0-internal.4cbdd50",
4
4
  "description": "MCP (Model Context Protocol) capabilities with Payload",
5
5
  "keywords": [
6
6
  "plugin",
@@ -21,9 +21,6 @@
21
21
  "url": "https://payloadcms.com"
22
22
  }
23
23
  ],
24
- "sideEffects": [
25
- "*.css"
26
- ],
27
24
  "type": "module",
28
25
  "exports": {
29
26
  ".": {
@@ -40,6 +37,11 @@
40
37
  "import": "./dist/stdio.js",
41
38
  "types": "./dist/stdio.d.ts",
42
39
  "default": "./dist/stdio.js"
40
+ },
41
+ "./internal": {
42
+ "import": "./dist/internal.js",
43
+ "types": "./dist/internal.d.ts",
44
+ "default": "./dist/internal.js"
43
45
  }
44
46
  },
45
47
  "main": "./dist/index.js",
@@ -59,16 +61,11 @@
59
61
  "zod": "^4.0.0"
60
62
  },
61
63
  "devDependencies": {
62
- "@types/react": "19.2.14",
63
- "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
64
64
  "@payloadcms/eslint-config": "3.28.0",
65
- "@payloadcms/ui": "4.0.0-internal.40de3ec",
66
- "payload": "4.0.0-internal.40de3ec"
65
+ "payload": "4.0.0-internal.4cbdd50"
67
66
  },
68
67
  "peerDependencies": {
69
- "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
70
- "payload": "4.0.0-internal.40de3ec",
71
- "@payloadcms/ui": "4.0.0-internal.40de3ec"
68
+ "payload": "4.0.0-internal.4cbdd50"
72
69
  },
73
70
  "//deps_notes": {
74
71
  "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.",
@@ -0,0 +1,3 @@
1
+ import type { MCPAccessArgs } from './types.js'
2
+
3
+ export const defaultAccess = ({ req }: MCPAccessArgs): boolean => Boolean(req.user)