@payloadcms/plugin-mcp 4.0.0-internal.cea8867 → 4.0.0-internal.d927017

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 (58) hide show
  1. package/bin.js +8 -6
  2. package/dist/bin/index.d.ts +2 -0
  3. package/dist/bin/index.d.ts.map +1 -0
  4. package/dist/bin/index.js +12 -0
  5. package/dist/bin/index.js.map +1 -0
  6. package/dist/bin/initializeViteHMR.d.ts +8 -0
  7. package/dist/bin/initializeViteHMR.d.ts.map +1 -0
  8. package/dist/bin/initializeViteHMR.js +63 -0
  9. package/dist/bin/initializeViteHMR.js.map +1 -0
  10. package/dist/bin/viteConfigBoundary.d.ts +6 -0
  11. package/dist/bin/viteConfigBoundary.d.ts.map +1 -0
  12. package/dist/bin/viteConfigBoundary.js +25 -0
  13. package/dist/bin/viteConfigBoundary.js.map +1 -0
  14. package/dist/defaultAccess.d.ts.map +1 -1
  15. package/dist/defineTool.d.ts +8 -8
  16. package/dist/defineTool.d.ts.map +1 -1
  17. package/dist/endpoint/access.d.ts.map +1 -1
  18. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  19. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  20. package/dist/mcp/builtin/collections/createTool.js +1 -11
  21. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  22. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
  23. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
  24. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  25. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +2 -23
  26. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  27. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  28. package/dist/mcp/builtin/collections/updateTool.js +6 -12
  29. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  30. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
  31. package/dist/mcp/builtinTools.d.ts.map +1 -1
  32. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  33. package/dist/stdio.d.ts +2 -1
  34. package/dist/stdio.d.ts.map +1 -1
  35. package/dist/stdio.js +4 -3
  36. package/dist/stdio.js.map +1 -1
  37. package/dist/utils/camelCase.d.ts.map +1 -1
  38. package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
  39. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -1
  40. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
  41. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
  42. package/dist/utils/toStandardSchema.d.ts.map +1 -1
  43. package/package.json +17 -4
  44. package/src/bin/index.ts +16 -0
  45. package/src/bin/initializeViteHMR.ts +60 -0
  46. package/src/bin/viteConfigBoundary.ts +39 -0
  47. package/src/mcp/builtin/collections/createTool.ts +1 -5
  48. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +1 -14
  49. package/src/mcp/builtin/collections/updateTool.ts +4 -6
  50. package/src/stdio.ts +4 -3
  51. package/dist/mcp/builtin/collections/fileInput.d.ts +0 -20
  52. package/dist/mcp/builtin/collections/fileInput.d.ts.map +0 -1
  53. package/dist/mcp/builtin/collections/fileInput.js +0 -100
  54. package/dist/mcp/builtin/collections/fileInput.js.map +0 -1
  55. package/dist/mcp/builtin/collections/fileInput.spec.js +0 -72
  56. package/dist/mcp/builtin/collections/fileInput.spec.js.map +0 -1
  57. package/src/mcp/builtin/collections/fileInput.spec.ts +0 -79
  58. package/src/mcp/builtin/collections/fileInput.ts +0 -139
package/bin.js CHANGED
@@ -19,12 +19,10 @@ const filename = fileURLToPath(import.meta.url)
19
19
  const dirname = path.dirname(filename)
20
20
  const baseURL = pathToFileURL(dirname).toString() + '/'
21
21
 
22
- const start = async () => {
22
+ const loadBin = async () => {
23
23
  if (disableTranspile) {
24
24
  process.argv = process.argv.filter((arg) => arg !== '--disable-transpile')
25
- const { runMcpStdio } = await import('./dist/stdio.js')
26
- await runMcpStdio()
27
- return
25
+ return import('./dist/bin/index.js')
28
26
  }
29
27
 
30
28
  // tsx 4.22.4's synchronous loader leaks its namespace query onto Node built-ins on Node 23.5+.
@@ -35,8 +33,12 @@ const start = async () => {
35
33
  }
36
34
 
37
35
  const { tsImport } = await import('tsx/esm/api')
38
- const { runMcpStdio } = await tsImport('./dist/stdio.js', baseURL)
39
- await runMcpStdio()
36
+ return tsImport('@payloadcms/plugin-mcp/bin', baseURL)
37
+ }
38
+
39
+ const start = async () => {
40
+ const { bin } = await loadBin()
41
+ await bin()
40
42
  }
41
43
 
42
44
  start().catch((err) => {
@@ -0,0 +1,2 @@
1
+ export declare const bin: () => Promise<void>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,QAAa,OAAO,CAAC,IAAI,CAaxC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { runMcpStdio } from '../stdio.js';
2
+ export const bin = async ()=>{
3
+ let viteHMR;
4
+ if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' && process.env.DISABLE_PAYLOAD_HMR !== 'true') {
5
+ const { initializeViteHMR } = await import('./initializeViteHMR.js');
6
+ viteHMR = await initializeViteHMR();
7
+ }
8
+ await runMcpStdio(viteHMR?.config);
9
+ await viteHMR?.connect();
10
+ };
11
+
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["import { runMcpStdio } from '../stdio.js'\n\nexport const bin = async (): Promise<void> => {\n let viteHMR\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.NODE_ENV !== 'test' &&\n process.env.DISABLE_PAYLOAD_HMR !== 'true'\n ) {\n const { initializeViteHMR } = await import('./initializeViteHMR.js')\n viteHMR = await initializeViteHMR()\n }\n\n await runMcpStdio(viteHMR?.config)\n await viteHMR?.connect()\n}\n"],"names":["runMcpStdio","bin","viteHMR","process","env","NODE_ENV","DISABLE_PAYLOAD_HMR","initializeViteHMR","config","connect"],"mappings":"AAAA,SAASA,WAAW,QAAQ,cAAa;AAEzC,OAAO,MAAMC,MAAM;IACjB,IAAIC;IACJ,IACEC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzBF,QAAQC,GAAG,CAACC,QAAQ,KAAK,UACzBF,QAAQC,GAAG,CAACE,mBAAmB,KAAK,QACpC;QACA,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;QAC3CL,UAAU,MAAMK;IAClB;IAEA,MAAMP,YAAYE,SAASM;IAC3B,MAAMN,SAASO;AACjB,EAAC"}
@@ -0,0 +1,8 @@
1
+ import type { SanitizedConfig } from 'payload';
2
+ type ViteHMR = {
3
+ config: SanitizedConfig;
4
+ connect: () => Promise<void>;
5
+ };
6
+ export declare const initializeViteHMR: () => Promise<ViteHMR>;
7
+ export {};
8
+ //# sourceMappingURL=initializeViteHMR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initializeViteHMR.d.ts","sourceRoot":"","sources":["../../src/bin/initializeViteHMR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAY9C,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,OAAO,CA0CzD,CAAA"}
@@ -0,0 +1,63 @@
1
+ /* eslint-disable no-console */ import { fileURLToPath } from 'node:url';
2
+ import { getPayload, reload } from 'payload';
3
+ import { findConfig } from 'payload/node';
4
+ import { createServer, createServerModuleRunner, normalizePath } from 'vite';
5
+ import { resolveProjectRoot } from '../utils/resolveProjectRoot.js';
6
+ export const initializeViteHMR = async ()=>{
7
+ const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url));
8
+ if (projectRoot) {
9
+ process.chdir(projectRoot);
10
+ }
11
+ const vite = await createServer({
12
+ clearScreen: false,
13
+ configFile: false,
14
+ envDir: false,
15
+ logLevel: 'error',
16
+ optimizeDeps: {
17
+ noDiscovery: true
18
+ },
19
+ publicDir: false,
20
+ resolve: {
21
+ alias: {
22
+ 'payload-mcp:config': normalizePath(findConfig())
23
+ },
24
+ tsconfigPaths: true
25
+ },
26
+ server: {
27
+ middlewareMode: true,
28
+ ws: false
29
+ },
30
+ ssr: {
31
+ noExternal: [
32
+ /^@payloadcms\//,
33
+ /^payload$/
34
+ ]
35
+ }
36
+ });
37
+ const runner = createServerModuleRunner(vite.environments.ssr);
38
+ const boundaryPath = fileURLToPath(new URL('./viteConfigBoundary.js', import.meta.url));
39
+ const boundary = await runner.import(boundaryPath);
40
+ const config = boundary.getConfig();
41
+ return {
42
+ config,
43
+ connect: async ()=>{
44
+ const payload = await getPayload({
45
+ config,
46
+ cron: false,
47
+ disableOnInit: true
48
+ });
49
+ let payloadReloadQueue = Promise.resolve();
50
+ const reloadPayload = (nextConfig)=>{
51
+ payloadReloadQueue = payloadReloadQueue.then(()=>reload(nextConfig, payload, false)).catch((error)=>console.error('[payload-mcp] config reload failed:', error));
52
+ return payloadReloadQueue;
53
+ };
54
+ boundary.subscribe(reloadPayload);
55
+ const latestConfig = boundary.getConfig();
56
+ if (config !== latestConfig) {
57
+ await reloadPayload(latestConfig);
58
+ }
59
+ }
60
+ };
61
+ };
62
+
63
+ //# sourceMappingURL=initializeViteHMR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bin/initializeViteHMR.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\n/* eslint-disable no-console */\nimport { fileURLToPath } from 'node:url'\nimport { getPayload, reload } from 'payload'\nimport { findConfig } from 'payload/node'\nimport { createServer, createServerModuleRunner, normalizePath } from 'vite'\n\nimport type * as ConfigBoundary from './viteConfigBoundary.js'\n\nimport { resolveProjectRoot } from '../utils/resolveProjectRoot.js'\n\ntype ViteHMR = {\n config: SanitizedConfig\n connect: () => Promise<void>\n}\n\nexport const initializeViteHMR = async (): Promise<ViteHMR> => {\n const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url))\n if (projectRoot) {\n process.chdir(projectRoot)\n }\n\n const vite = await createServer({\n clearScreen: false,\n configFile: false,\n envDir: false,\n logLevel: 'error',\n optimizeDeps: { noDiscovery: true },\n publicDir: false,\n resolve: { alias: { 'payload-mcp:config': normalizePath(findConfig()) }, tsconfigPaths: true },\n server: { middlewareMode: true, ws: false },\n ssr: { noExternal: [/^@payloadcms\\//, /^payload$/] },\n })\n const runner = createServerModuleRunner(vite.environments.ssr)\n const boundaryPath = fileURLToPath(new URL('./viteConfigBoundary.js', import.meta.url))\n const boundary = await runner.import<typeof ConfigBoundary>(boundaryPath)\n const config = boundary.getConfig()\n\n return {\n config,\n connect: async () => {\n const payload = await getPayload({ config, cron: false, disableOnInit: true })\n let payloadReloadQueue = Promise.resolve()\n const reloadPayload = (nextConfig: SanitizedConfig): Promise<void> => {\n payloadReloadQueue = payloadReloadQueue\n .then(() => reload(nextConfig, payload, false))\n .catch((error) => console.error('[payload-mcp] config reload failed:', error))\n return payloadReloadQueue\n }\n\n boundary.subscribe(reloadPayload)\n\n const latestConfig = boundary.getConfig()\n if (config !== latestConfig) {\n await reloadPayload(latestConfig)\n }\n },\n }\n}\n"],"names":["fileURLToPath","getPayload","reload","findConfig","createServer","createServerModuleRunner","normalizePath","resolveProjectRoot","initializeViteHMR","projectRoot","url","process","chdir","vite","clearScreen","configFile","envDir","logLevel","optimizeDeps","noDiscovery","publicDir","resolve","alias","tsconfigPaths","server","middlewareMode","ws","ssr","noExternal","runner","environments","boundaryPath","URL","boundary","import","config","getConfig","connect","payload","cron","disableOnInit","payloadReloadQueue","Promise","reloadPayload","nextConfig","then","catch","error","console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gB,SAAS,CAACN;YAEnB,MAAMO,eAAejB,SAASG,SAAS;YACvC,IAAID,WAAWe,cAAc;gBAC3B,MAAMP,cAAcO;YACtB;QACF;IACF;AACF,EAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SanitizedConfig } from 'payload';
2
+ type ConfigListener = (config: SanitizedConfig) => Promise<void> | void;
3
+ export declare const getConfig: () => SanitizedConfig;
4
+ export declare const subscribe: (nextListener: ConfigListener) => void;
5
+ export {};
6
+ //# sourceMappingURL=viteConfigBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viteConfigBoundary.d.ts","sourceRoot":"","sources":["../../src/bin/viteConfigBoundary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM9C,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAavE,eAAO,MAAM,SAAS,QAAO,eAAyB,CAAA;AAEtD,eAAO,MAAM,SAAS,GAAI,cAAc,cAAc,KAAG,IAExD,CAAA"}
@@ -0,0 +1,25 @@
1
+ /// <reference types="vite/client" />
2
+ /* eslint-disable no-console */ // @ts-expect-error - The Vite initializer resolves this ID to the Payload config.
3
+ import * as configModule from 'payload-mcp:config';
4
+ let listener;
5
+ let configQueue = Promise.resolve();
6
+ const resolveConfig = async (module)=>{
7
+ const config = module;
8
+ return await (config.default ?? module);
9
+ };
10
+ let config = await resolveConfig(configModule);
11
+ export const getConfig = ()=>config;
12
+ export const subscribe = (nextListener)=>{
13
+ listener = nextListener;
14
+ };
15
+ import.meta.hot?.accept('payload-mcp:config', (nextModule)=>{
16
+ if (!nextModule) {
17
+ return;
18
+ }
19
+ configQueue = configQueue.then(async ()=>{
20
+ config = await resolveConfig(nextModule);
21
+ await listener?.(config);
22
+ }).catch((error)=>console.error('[payload-mcp] config reload failed:', error));
23
+ });
24
+
25
+ //# sourceMappingURL=viteConfigBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bin/viteConfigBoundary.ts"],"sourcesContent":["/// <reference types=\"vite/client\" />\n\nimport type { SanitizedConfig } from 'payload'\n\n/* eslint-disable no-console */\n// @ts-expect-error - The Vite initializer resolves this ID to the Payload config.\nimport * as configModule from 'payload-mcp:config'\n\ntype ConfigListener = (config: SanitizedConfig) => Promise<void> | void\n\nlet listener: ConfigListener | undefined\nlet configQueue = Promise.resolve()\n\nconst resolveConfig = async (module: unknown): Promise<SanitizedConfig> => {\n const config = module as { default?: unknown }\n\n return (await (config.default ?? module)) as SanitizedConfig\n}\n\nlet config = await resolveConfig(configModule)\n\nexport const getConfig = (): SanitizedConfig => config\n\nexport const subscribe = (nextListener: ConfigListener): void => {\n listener = nextListener\n}\n\nimport.meta.hot?.accept('payload-mcp:config', (nextModule) => {\n if (!nextModule) {\n return\n }\n\n configQueue = configQueue\n .then(async () => {\n config = await resolveConfig(nextModule)\n await listener?.(config)\n })\n .catch((error) => console.error('[payload-mcp] config reload failed:', error))\n})\n"],"names":["configModule","listener","configQueue","Promise","resolve","resolveConfig","module","config","default","getConfig","subscribe","nextListener","hot","accept","nextModule","then","catch","error","console"],"mappings":"AAAA,qCAAqC;AAIrC,6BAA6B,GAC7B,kFAAkF;AAClF,YAAYA,kBAAkB,qBAAoB;AAIlD,IAAIC;AACJ,IAAIC,cAAcC,QAAQC,OAAO;AAEjC,MAAMC,gBAAgB,OAAOC;IAC3B,MAAMC,SAASD;IAEf,OAAQ,MAAOC,CAAAA,OAAOC,OAAO,IAAIF,MAAK;AACxC;AAEA,IAAIC,SAAS,MAAMF,cAAcL;AAEjC,OAAO,MAAMS,YAAY,IAAuBF,OAAM;AAEtD,OAAO,MAAMG,YAAY,CAACC;IACxBV,WAAWU;AACb,EAAC;AAED,YAAYC,GAAG,EAAEC,OAAO,sBAAsB,CAACC;IAC7C,IAAI,CAACA,YAAY;QACf;IACF;IAEAZ,cAAcA,YACXa,IAAI,CAAC;QACJR,SAAS,MAAMF,cAAcS;QAC7B,MAAMb,WAAWM;IACnB,GACCS,KAAK,CAAC,CAACC,QAAUC,QAAQD,KAAK,CAAC,uCAAuCA;AAC3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultAccess.d.ts","sourceRoot":"","sources":["../src/defaultAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,aAAa,YAAa,aAAa,KAAG,OAA4B,CAAA"}
1
+ {"version":3,"file":"defaultAccess.d.ts","sourceRoot":"","sources":["../src/defaultAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,aAAa,GAAI,SAAS,aAAa,KAAG,OAA4B,CAAA"}
@@ -11,16 +11,16 @@ import type { CollectionTool, GlobalTool, Prompt, Tool, ToolInputSchema } from '
11
11
  * Config and handler signatures are derived from `Tool` / `CollectionTool` / `GlobalTool` /
12
12
  * `Prompt` via `Omit` + indexed access so there's no duplication with `types.ts`.
13
13
  */
14
- export declare const defineTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<Tool<TSchema>, 'handler'>) => {
15
- handler: (fn: Tool<TSchema>['handler']) => Tool;
14
+ export declare const defineTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<Tool<TSchema>, "handler">) => {
15
+ handler: (fn: Tool<TSchema>["handler"]) => Tool;
16
16
  };
17
- export declare const defineCollectionTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<CollectionTool<TSchema>, 'handler'>) => {
18
- handler: (fn: CollectionTool<TSchema>['handler']) => CollectionTool;
17
+ export declare const defineCollectionTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<CollectionTool<TSchema>, "handler">) => {
18
+ handler: (fn: CollectionTool<TSchema>["handler"]) => CollectionTool;
19
19
  };
20
- export declare const defineGlobalTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<GlobalTool<TSchema>, 'handler'>) => {
21
- handler: (fn: GlobalTool<TSchema>['handler']) => GlobalTool;
20
+ export declare const defineGlobalTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<GlobalTool<TSchema>, "handler">) => {
21
+ handler: (fn: GlobalTool<TSchema>["handler"]) => GlobalTool;
22
22
  };
23
- export declare const definePrompt: <TSchema extends ToolInputSchema = ToolInputSchema>(args: Omit<Prompt<TSchema>, 'handler'>) => {
24
- handler: (fn: Prompt<TSchema>['handler']) => Prompt;
23
+ export declare const definePrompt: <TSchema extends ToolInputSchema = ToolInputSchema>(args: Omit<Prompt<TSchema>, "handler">) => {
24
+ handler: (fn: Prompt<TSchema>["handler"]) => Prompt;
25
25
  };
26
26
  //# sourceMappingURL=defineTool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineTool.d.ts","sourceRoot":"","sources":["../src/defineTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE3F;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,UAAU,GACrB,OAAO,SAAS,eAAe,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,QAEnE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KACnC;IAAE,OAAO,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;CAElD,CAAA;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,SAAS,eAAe,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,QAEnE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KAC7C;IAAE,OAAO,EAAE,CAAC,EAA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","sourceRoot":"","sources":["../../src/endpoint/access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIzD,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,aAAa,CAkCnF,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,iCAIlC;IACD,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,OAAO,EAAE,CAkBpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildMcpServer.d.ts","sourceRoot":"","sources":["../../src/mcp/buildMcpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAGvD,OAAO,KAAK,EACV,aAAa,EAMb,wBAAwB,EAEzB,MAAM,aAAa,CAAA;AAKpB;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,0CAIxB;IACD,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,wBAAwB,CAAA;IACtC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,SAkNH,CAAA"}
1
+ {"version":3,"file":"buildMcpServer.d.ts","sourceRoot":"","sources":["../../src/mcp/buildMcpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAGvD,OAAO,KAAK,EACV,aAAa,EAMb,wBAAwB,EAEzB,MAAM,aAAa,CAAA;AAKpB;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,uCAI5B;IACD,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,wBAAwB,CAAA;IACtC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,SAkNH,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,kBAAkB,4CAqG7B,CAAA"}
1
+ {"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,kBAAkB,4CAkG7B,CAAA"}
@@ -5,7 +5,6 @@ import { getLogger } from '../../../utils/getLogger.js';
5
5
  import { getCollectionVirtualFieldNames, stripVirtualFields } from '../../../utils/getVirtualFieldNames.js';
6
6
  import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
7
7
  import { validateCollectionData } from '../validateEntityData.js';
8
- import { fileInputSchema, resolveFileInput } from './fileInput.js';
9
8
  import { formatCollectionError } from './formatCollectionError.js';
10
9
  const DEFAULT_DESCRIPTION = 'Create a document in any collection by passing the collection slug and data.';
11
10
  export const createDocumentTool = defineCollectionTool({
@@ -23,7 +22,6 @@ export const createDocumentTool = defineCollectionTool({
23
22
  depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in response').optional().default(0),
24
23
  draft: z.boolean().describe('Only if getCollectionSchema includes _status; otherwise _status does not exist. true forces data._status to "draft"; with false, data._status controls draft or published.').optional().default(false),
25
24
  fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
26
- file: fileInputSchema.optional(),
27
25
  locale: z.string().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale').optional(),
28
26
  select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return, e.g., {"title": true}').optional()
29
27
  })
@@ -32,7 +30,7 @@ export const createDocumentTool = defineCollectionTool({
32
30
  const logger = getLogger({
33
31
  payload
34
32
  });
35
- const { data, depth, draft, fallbackLocale, file: fileInput, locale, select } = input;
33
+ const { data, depth, draft, fallbackLocale, locale, select } = input;
36
34
  logger.info(`Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`);
37
35
  try {
38
36
  const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug);
@@ -46,11 +44,6 @@ export const createDocumentTool = defineCollectionTool({
46
44
  return validationError;
47
45
  }
48
46
  const parsedData = transformPointDataToPayload(inputData);
49
- const file = await resolveFileInput({
50
- collectionSlug,
51
- input: fileInput,
52
- req
53
- });
54
47
  const result = await payload.create({
55
48
  collection: collectionSlug,
56
49
  data: parsedData,
@@ -58,9 +51,6 @@ export const createDocumentTool = defineCollectionTool({
58
51
  draft,
59
52
  overrideAccess: authorizedMCP.overrideAccess,
60
53
  req,
61
- ...file ? {
62
- file
63
- } : {},
64
54
  ...locale ? {
65
55
  locale
66
56
  } : {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { fileInputSchema, resolveFileInput } from './fileInput.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Create a document in any collection by passing the collection slug and data.'\n\nexport const createDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.create),\n annotations: {\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Create Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n data: z\n .record(z.string(), z.unknown())\n .describe(\n 'The document fields to create. Only include fields permitted by the schema returned by getCollectionSchema.',\n ),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n 'Only if getCollectionSchema includes _status; otherwise _status does not exist. true forces data._status to \"draft\"; with false, data._status controls draft or published.',\n )\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n file: fileInputSchema.optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return, e.g., {\"title\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, file: fileInput, locale, select } = input\n\n logger.info(\n `Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({ collectionSlug, data: inputData, req })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n const file = await resolveFileInput({ collectionSlug, input: fileInput, req })\n\n const result = await payload.create({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(file ? { file } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n logger.info(`Successfully created document in ${collectionSlug} with ID: ${result.id}`)\n\n return {\n content: [\n {\n type: 'text',\n text: `Document created successfully in collection \"${collectionSlug}\"!\\nCreated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error creating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'creating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","transformPointDataToPayload","validateCollectionData","fileInputSchema","resolveFileInput","formatCollectionError","DEFAULT_DESCRIPTION","createDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","create","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","data","record","string","unknown","describe","depth","number","int","min","max","optional","default","draft","boolean","fallbackLocale","file","locale","select","handler","authorizedMCP","req","payload","logger","fileInput","info","virtualFieldNames","config","inputData","validationError","parsedData","result","collection","overrideAccess","id","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,iBAAgB;AAClE,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,sBACJ;AAEF,OAAO,MAAMC,qBAAqBV,qBAAqB;IACrDW,QAAQ,CAACC,OACPb,cAAca,SAASC,QAAQD,KAAKE,WAAW,EAAEC,aAAa,CAACH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YnD,mBAAmBwB,MAAMyB;QAC3C,MAAMG,kBAAkBlD,uBAAuB;YAAEW;YAAgBW,MAAM2B;YAAWP;QAAI;QAEtF,IAAIQ,iBAAiB;YACnB,OAAOA;QACT;QAEA,MAAMC,aAAapD,4BAA4BkD;QAC/C,MAAMZ,OAAO,MAAMnC,iBAAiB;YAAES;YAAgBS,OAAOyB;YAAWH;QAAI;QAE5E,MAAMU,SAAS,MAAMT,QAAQ/B,MAAM,CAAC;YAClCyC,YAAY1C;YACZW,MAAM6B;YACNxB;YACAO;YACAoB,gBAAgBb,cAAca,cAAc;YAC5CZ;YACA,GAAIL,OAAO;gBAAEA;YAAK,IAAI,CAAC,CAAC;YACxB,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIF,iBAAiB;gBAAEA;YAAe,IAAI,CAAC,CAAC;YAC5C,GAAIG,SAAS;gBAAEA,QAAQA;YAAqB,IAAI,CAAC,CAAC;QACpD;QAEAK,OAAOE,IAAI,CAAC,CAAC,iCAAiC,EAAEnC,eAAe,UAAU,EAAEyC,OAAOG,EAAE,EAAE;QAEtF,OAAO;YACLC,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6CAA6C,EAAE/C,eAAe,mCAAmC,EAAEgD,KAAKC,SAAS,CAACR,QAAQ,QAAQ,CAAC;gBAC5I;aACD;YACDS,KAAKT;QACP;IACF,EAAE,OAAOU,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DrB,OAAOkB,KAAK,CAAC,CAAC,2BAA2B,EAAEnD,eAAe,EAAE,EAAEoD,cAAc;QAC5E,OAAO5D,sBAAsB;YAAE+D,QAAQ;YAAYvD;YAAgBmD;YAAOpB;QAAI;IAChF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Create a document in any collection by passing the collection slug and data.'\n\nexport const createDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.create),\n annotations: {\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Create Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n data: z\n .record(z.string(), z.unknown())\n .describe(\n 'The document fields to create. Only include fields permitted by the schema returned by getCollectionSchema.',\n ),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n 'Only if getCollectionSchema includes _status; otherwise _status does not exist. true forces data._status to \"draft\"; with false, data._status controls draft or published.',\n )\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return, e.g., {\"title\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, locale, select } = input\n\n logger.info(\n `Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({ collectionSlug, data: inputData, req })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const result = await payload.create({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n logger.info(`Successfully created document in ${collectionSlug} with ID: ${result.id}`)\n\n return {\n content: [\n {\n type: 'text',\n text: `Document created successfully in collection \"${collectionSlug}\"!\\nCreated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error creating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'creating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","transformPointDataToPayload","validateCollectionData","formatCollectionError","DEFAULT_DESCRIPTION","createDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","create","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","data","record","string","unknown","describe","depth","number","int","min","max","optional","default","draft","boolean","fallbackLocale","locale","select","handler","authorizedMCP","req","payload","logger","info","virtualFieldNames","config","inputData","validationError","parsedData","result","collection","overrideAccess","id","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,2BAA2B,QAAQ,gDAA+C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3
3
  export declare const formatCollectionError: ({ action, collectionSlug, error, req, }: {
4
- action: 'creating' | 'duplicating' | 'updating';
4
+ action: "creating" | "duplicating" | "updating";
5
5
  collectionSlug: CollectionSlug;
6
6
  error: unknown;
7
7
  req: PayloadRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"formatCollectionError.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/formatCollectionError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAgCxD,eAAO,MAAM,qBAAqB,4CAK/B;IACD,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,UAAU,CAAA;IAC/C,cAAc,EAAE,cAAc,CAAA;IAC9B,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAuCH,CAAA"}
1
+ {"version":3,"file":"formatCollectionError.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/formatCollectionError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAgCxD,eAAO,MAAM,qBAAqB,GAAI,yCAKnC;IACD,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,UAAU,CAAA;IAC/C,cAAc,EAAE,cAAc,CAAA;IAC9B,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAuCH,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getCollectionSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,4CAqElC,CAAA"}
1
+ {"version":3,"file":"getCollectionSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,4CAwDlC,CAAA"}
@@ -48,37 +48,16 @@ export const getCollectionSchemaTool = defineCollectionTool({
48
48
  isError: true
49
49
  };
50
50
  }
51
- const uploadConfig = req.payload.collections[collectionSlug]?.config.upload;
52
- const maxFileSize = req.payload.config.upload.limits?.fileSize;
53
- const upload = uploadConfig ? {
54
- enabled: true,
55
- filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,
56
- mimeTypes: uploadConfig.mimeTypes ?? [
57
- '*/*'
58
- ],
59
- sources: [
60
- ...uploadConfig.pasteURL !== false ? [
61
- 'url'
62
- ] : [],
63
- 'base64'
64
- ],
65
- ...typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? {
66
- maxFileSize
67
- } : {}
68
- } : {
69
- enabled: false
70
- };
71
51
  return {
72
52
  content: [
73
53
  {
74
54
  type: 'text',
75
- text: `Schema for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\`\nUpload configuration:\n\`\`\`json\n${JSON.stringify(upload)}\n\`\`\``
55
+ text: `Schema for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``
76
56
  }
77
57
  ],
78
58
  structuredContent: {
79
59
  collectionSlug,
80
- schema: inputSchema,
81
- upload
60
+ schema: inputSchema
82
61
  }
83
62
  };
84
63
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.collectionSlug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description: 'Get the input schema for creating or updating documents in a collection.',\n}).handler(async ({ authorizedMCP, collectionSlug, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[collectionSlug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${collectionSlug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${collectionSlug}\" not found` }],\n isError: true,\n }\n }\n\n const uploadConfig = req.payload.collections[collectionSlug]?.config.upload\n const maxFileSize = req.payload.config.upload.limits?.fileSize\n const upload = uploadConfig\n ? {\n enabled: true,\n filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,\n mimeTypes: uploadConfig.mimeTypes ?? ['*/*'],\n sources: [...(uploadConfig.pasteURL !== false ? ['url'] : []), 'base64'],\n ...(typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? { maxFileSize } : {}),\n }\n : { enabled: false }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${collectionSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\`\\nUpload configuration:\\n\\`\\`\\`json\\n${JSON.stringify(upload)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n collectionSlug,\n schema: inputSchema,\n upload,\n },\n }\n})\n"],"names":["getAccessResults","defaultAccess","defineCollectionTool","getCollectionInputSchema","getCollectionSchemaTool","access","args","permissions","collections","collectionSlug","Boolean","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","uploadConfig","payload","config","upload","maxFileSize","limits","fileSize","enabled","filesRequiredOnCreate","mimeTypes","sources","pasteURL","Number","isFinite","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,UAAS;AAE1C,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,wBAAwB,QAAQ,0DAAyD;AAElG,OAAO,MAAMC,0BAA0BF,qBAAqB;IAC1DG,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,aAAa,CAACF,KAAKG,cAAc,CAAC;QAExE,OAAOR,cAAcK,SAASI,QAAQH,aAAaI,UAAUJ,aAAaK;IAC5E;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;AACf,GAAGC,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAEZ,cAAc,EAAEa,GAAG,EAAE;IACtD,MAAMf,cAAcc,cAAcE,cAAc,GAC5C,OACA,AAAC,CAAA,MAAMvB,iBAAiB;QAAEsB;IAAI,EAAC,EAAGd,WAAW,EAAE,CAACC,eAAe;IAEnE,IAAI,CAACY,cAAcE,cAAc,IAAI,CAAChB,aAAaI,UAAU,CAACJ,aAAaK,QAAQ;QACjF,OAAO;YACLY,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,0EAA0E,EAAEjB,eAAe,CAAC,CAAC;gBACtG;aACD;YACDkB,SAAS;QACX;IACF;IAEA,MAAMC,cAAczB,yBAAyB;QAC3CM;QACAa;QACA,GAAIf,cAAc;YAAEA;QAAY,IAAI,CAAC,CAAC;IACxC;IAEA,IAAI,CAACqB,aAAa;QAChB,OAAO;YACLJ,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,mBAAmB,EAAEjB,eAAe,WAAW,CAAC;gBAAC;aAAE;YACpFkB,SAAS;QACX;IACF;IAEA,MAAME,eAAeP,IAAIQ,OAAO,CAACtB,WAAW,CAACC,eAAe,EAAEsB,OAAOC;IACrE,MAAMC,cAAcX,IAAIQ,OAAO,CAACC,MAAM,CAACC,MAAM,CAACE,MAAM,EAAEC;IACtD,MAAMH,SAASH,eACX;QACEO,SAAS;QACTC,uBAAuBR,aAAaQ,qBAAqB,KAAK;QAC9DC,WAAWT,aAAaS,SAAS,IAAI;YAAC;SAAM;QAC5CC,SAAS;eAAKV,aAAaW,QAAQ,KAAK,QAAQ;gBAAC;aAAM,GAAG,EAAE;YAAG;SAAS;QACxE,GAAI,OAAOP,gBAAgB,YAAYQ,OAAOC,QAAQ,CAACT,eAAe;YAAEA;QAAY,IAAI,CAAC,CAAC;IAC5F,IACA;QAAEG,SAAS;IAAM;IAErB,OAAO;QACLZ,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,uBAAuB,EAAEjB,eAAe,gBAAgB,EAAEkC,KAAKC,SAAS,CAAChB,aAAa,6CAA6C,EAAEe,KAAKC,SAAS,CAACZ,QAAQ,QAAQ,CAAC;YAC9K;SACD;QACDa,mBAAmB;YACjBpC;YACAqC,QAAQlB;YACRI;QACF;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.collectionSlug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description: 'Get the input schema for creating or updating documents in a collection.',\n}).handler(async ({ authorizedMCP, collectionSlug, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[collectionSlug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${collectionSlug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${collectionSlug}\" not found` }],\n isError: true,\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${collectionSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n collectionSlug,\n schema: inputSchema,\n },\n }\n})\n"],"names":["getAccessResults","defaultAccess","defineCollectionTool","getCollectionInputSchema","getCollectionSchemaTool","access","args","permissions","collections","collectionSlug","Boolean","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,UAAS;AAE1C,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,wBAAwB,QAAQ,0DAAyD;AAElG,OAAO,MAAMC,0BAA0BF,qBAAqB;IAC1DG,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,aAAa,CAACF,KAAKG,cAAc,CAAC;QAExE,OAAOR,cAAcK,SAASI,QAAQH,aAAaI,UAAUJ,aAAaK;IAC5E;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;AACf,GAAGC,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAEZ,cAAc,EAAEa,GAAG,EAAE;IACtD,MAAMf,cAAcc,cAAcE,cAAc,GAC5C,OACA,AAAC,CAAA,MAAMvB,iBAAiB;QAAEsB;IAAI,EAAC,EAAGd,WAAW,EAAE,CAACC,eAAe;IAEnE,IAAI,CAACY,cAAcE,cAAc,IAAI,CAAChB,aAAaI,UAAU,CAACJ,aAAaK,QAAQ;QACjF,OAAO;YACLY,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,0EAA0E,EAAEjB,eAAe,CAAC,CAAC;gBACtG;aACD;YACDkB,SAAS;QACX;IACF;IAEA,MAAMC,cAAczB,yBAAyB;QAC3CM;QACAa;QACA,GAAIf,cAAc;YAAEA;QAAY,IAAI,CAAC,CAAC;IACxC;IAEA,IAAI,CAACqB,aAAa;QAChB,OAAO;YACLJ,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,mBAAmB,EAAEjB,eAAe,WAAW,CAAC;gBAAC;aAAE;YACpFkB,SAAS;QACX;IACF;IAEA,OAAO;QACLH,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,uBAAuB,EAAEjB,eAAe,gBAAgB,EAAEoB,KAAKC,SAAS,CAACF,aAAa,QAAQ,CAAC;YACxG;SACD;QACDG,mBAAmB;YACjBtB;YACAuB,QAAQJ;QACV;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,kBAAkB,4CA6M7B,CAAA"}
1
+ {"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB,4CA4M7B,CAAA"}
@@ -7,7 +7,6 @@ import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEnt
7
7
  import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
8
8
  import { whereSchema } from '../../../utils/whereSchema.js';
9
9
  import { validateCollectionData } from '../validateEntityData.js';
10
- import { fileInputSchema, resolveFileInput } from './fileInput.js';
11
10
  import { formatCollectionError } from './formatCollectionError.js';
12
11
  const DEFAULT_DESCRIPTION = 'Update documents in any collection by passing the collection slug and data.';
13
12
  export const updateDocumentTool = defineCollectionTool({
@@ -29,7 +28,7 @@ export const updateDocumentTool = defineCollectionTool({
29
28
  depth: z.number().describe('How many levels deep to populate relationships').optional().default(0),
30
29
  draft: z.boolean().describe('Only if getCollectionSchema includes _status; otherwise _status does not exist. true saves only a draft version; false updates main and versions. data._status: "published" overrides true.').optional().default(false),
31
30
  fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
32
- file: fileInputSchema.optional(),
31
+ filePath: z.string().describe('File path for file uploads').optional(),
33
32
  locale: z.string().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale').optional(),
34
33
  overrideLock: z.boolean().describe('Whether to override document locks').optional().default(true),
35
34
  overwriteExistingFiles: z.boolean().describe('Whether to overwrite existing files').optional().default(false),
@@ -42,7 +41,7 @@ export const updateDocumentTool = defineCollectionTool({
42
41
  const logger = getLogger({
43
42
  payload
44
43
  });
45
- const { id, data, depth, draft, fallbackLocale, file: fileInput, locale, overrideLock, overwriteExistingFiles, publishAllLocales, select, where } = input;
44
+ const { id, data, depth, draft, fallbackLocale, filePath, locale, overrideLock, overwriteExistingFiles, publishAllLocales, select, where } = input;
46
45
  logger.info(`Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
47
46
  try {
48
47
  if (!id && !where) {
@@ -67,11 +66,6 @@ export const updateDocumentTool = defineCollectionTool({
67
66
  return validationError;
68
67
  }
69
68
  const parsedData = transformPointDataToPayload(inputData);
70
- const file = await resolveFileInput({
71
- collectionSlug,
72
- input: fileInput,
73
- req
74
- });
75
69
  const whereClause = where ?? {};
76
70
  if (id) {
77
71
  const result = await payload.update({
@@ -83,8 +77,8 @@ export const updateDocumentTool = defineCollectionTool({
83
77
  overrideAccess: authorizedMCP.overrideAccess,
84
78
  overrideLock,
85
79
  req,
86
- ...file ? {
87
- file
80
+ ...filePath ? {
81
+ filePath
88
82
  } : {},
89
83
  ...overwriteExistingFiles ? {
90
84
  overwriteExistingFiles
@@ -121,8 +115,8 @@ export const updateDocumentTool = defineCollectionTool({
121
115
  overrideLock,
122
116
  req,
123
117
  where: whereClause,
124
- ...file ? {
125
- file
118
+ ...filePath ? {
119
+ filePath
126
120
  } : {},
127
121
  ...overwriteExistingFiles ? {
128
122
  overwriteExistingFiles
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"sourcesContent":["import type { SelectType, Where } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { fileInputSchema, resolveFileInput } from './fileInput.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Update documents in any collection by passing the collection slug and data.'\n\nexport const updateDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),\n data: z\n .record(z.string(), z.unknown())\n .describe(\n 'The fields to update. Only include fields permitted by the schema returned by getCollectionSchema.',\n ),\n depth: z\n .number()\n .describe('How many levels deep to populate relationships')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n 'Only if getCollectionSchema includes _status; otherwise _status does not exist. true saves only a draft version; false updates main and versions. data._status: \"published\" overrides true.',\n )\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n file: fileInputSchema.optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n overrideLock: z\n .boolean()\n .describe('Whether to override document locks')\n .optional()\n .default(true),\n overwriteExistingFiles: z\n .boolean()\n .describe('Whether to overwrite existing files')\n .optional()\n .default(false),\n publishAllLocales: z\n .boolean()\n .describe(\n 'For collections with localized publishing status, whether publishing should affect every locale. Set false with locale to publish only that locale.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n where: whereSchema\n .describe(\n 'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n data,\n depth,\n draft,\n fallbackLocale,\n file: fileInput,\n locale,\n overrideLock,\n overwriteExistingFiles,\n publishAllLocales,\n select,\n where,\n } = input\n\n logger.info(\n `Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (!id && !where) {\n return {\n content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],\n }\n }\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({\n collectionSlug,\n data: inputData,\n partial: true,\n req,\n })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n const file = await resolveFileInput({ collectionSlug, input: fileInput, req })\n\n const whereClause: Where = where ?? {}\n\n if (id) {\n const result = await payload.update({\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n ...(file ? { file } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(publishAllLocales !== undefined ? { publishAllLocales } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document updated successfully in collection \"${collectionSlug}\"!\\nUpdated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n }\n\n const result = await payload.update({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n where: whereClause,\n ...(file ? { file } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(publishAllLocales !== undefined ? { publishAllLocales } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n const docs = result.docs || []\n const errors = result.errors || []\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\\nUpdated: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n\n const errorSchema = getCollectionInputSchema({ collectionSlug, req })\n\n if (errorSchema) {\n responseText += `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(errorSchema)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n isError: true,\n ...(errorSchema\n ? {\n structuredContent: {\n collectionSlug,\n docs,\n errors,\n schema: errorSchema,\n },\n }\n : {}),\n }\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'updating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","getCollectionInputSchema","transformPointDataToPayload","whereSchema","validateCollectionData","fileInputSchema","resolveFileInput","formatCollectionError","DEFAULT_DESCRIPTION","updateDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","data","record","unknown","depth","default","draft","boolean","fallbackLocale","file","locale","overrideLock","overwriteExistingFiles","publishAllLocales","select","where","handler","authorizedMCP","req","payload","logger","fileInput","info","content","type","text","virtualFieldNames","config","inputData","validationError","partial","parsedData","whereClause","result","collection","overrideAccess","undefined","JSON","stringify","doc","docs","errors","responseText","length","errorSchema","isError","structuredContent","schema","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,wBAAwB,QAAQ,0DAAyD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../../../../src/mcp/builtin/collections/updateTool.ts"],"sourcesContent":["import type { SelectType, Where } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Update documents in any collection by passing the collection slug and data.'\n\nexport const updateDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),\n data: z\n .record(z.string(), z.unknown())\n .describe(\n 'The fields to update. Only include fields permitted by the schema returned by getCollectionSchema.',\n ),\n depth: z\n .number()\n .describe('How many levels deep to populate relationships')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n 'Only if getCollectionSchema includes _status; otherwise _status does not exist. true saves only a draft version; false updates main and versions. data._status: \"published\" overrides true.',\n )\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n filePath: z.string().describe('File path for file uploads').optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n overrideLock: z\n .boolean()\n .describe('Whether to override document locks')\n .optional()\n .default(true),\n overwriteExistingFiles: z\n .boolean()\n .describe('Whether to overwrite existing files')\n .optional()\n .default(false),\n publishAllLocales: z\n .boolean()\n .describe(\n 'For collections with localized publishing status, whether publishing should affect every locale. Set false with locale to publish only that locale.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n where: whereSchema\n .describe(\n 'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n data,\n depth,\n draft,\n fallbackLocale,\n filePath,\n locale,\n overrideLock,\n overwriteExistingFiles,\n publishAllLocales,\n select,\n where,\n } = input\n\n logger.info(\n `Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (!id && !where) {\n return {\n content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],\n }\n }\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({\n collectionSlug,\n data: inputData,\n partial: true,\n req,\n })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const whereClause: Where = where ?? {}\n\n if (id) {\n const result = await payload.update({\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n ...(filePath ? { filePath } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(publishAllLocales !== undefined ? { publishAllLocales } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document updated successfully in collection \"${collectionSlug}\"!\\nUpdated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n }\n\n const result = await payload.update({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n where: whereClause,\n ...(filePath ? { filePath } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(publishAllLocales !== undefined ? { publishAllLocales } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n const docs = result.docs || []\n const errors = result.errors || []\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\\nUpdated: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n\n const errorSchema = getCollectionInputSchema({ collectionSlug, req })\n\n if (errorSchema) {\n responseText += `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(errorSchema)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n isError: true,\n ...(errorSchema\n ? {\n structuredContent: {\n collectionSlug,\n docs,\n errors,\n schema: errorSchema,\n },\n }\n : {}),\n }\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'updating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","getCollectionInputSchema","transformPointDataToPayload","whereSchema","validateCollectionData","formatCollectionError","DEFAULT_DESCRIPTION","updateDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","data","record","unknown","depth","default","draft","boolean","fallbackLocale","filePath","locale","overrideLock","overwriteExistingFiles","publishAllLocales","select","where","handler","authorizedMCP","req","payload","logger","info","content","type","text","virtualFieldNames","config","inputData","validationError","partial","parsedData","whereClause","result","collection","overrideAccess","undefined","JSON","stringify","doc","docs","errors","responseText","length","errorSchema","isError","structuredContent","schema","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,wBAAwB,QAAQ,0DAAyD;AAClG,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,WAAW,QAAQ,gCAA+B;AAC3D,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,sBACJ;AAEF,OAAO,MAAMC,qBAAqBV,qBAAqB;IACrDW,QAAQ,CAACC,OACPb,cAAca,SAASC,QAAQD,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,cAAc,CAAC,EAAEC;IACvFC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAO3B,EAAE4B,MAAM,CAAC;QACdC,IAAI7B,EAAE8B,KAAK,CAAC;YAAC9B,EAAE+B,MAAM;YAAI/B,EAAEgC,MAAM;SAAG,EAAEC,QAAQ,CAAC,oC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B;oBAAa;iBAAE;gBAC/CH,KAAK;oBAAEC;oBAAMC;gBAAO;gBACpBI,SAAS;gBACT,GAAID,cACA;oBACEE,mBAAmB;wBACjB7D;wBACAuD;wBACAC;wBACAM,QAAQH;oBACV;gBACF,IACA,CAAC,CAAC;YACR;QACF;QAEA,OAAO;YACLrB,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAMiB;gBAAa;aAAE;YAC/CH,KAAK;gBAAEC;gBAAMC;YAAO;QACtB;IACF,EAAE,OAAOO,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9D9B,OAAO2B,KAAK,CAAC,CAAC,2BAA2B,EAAE/D,eAAe,EAAE,EAAEgE,cAAc;QAC5E,OAAOxE,sBAAsB;YAAE2E,QAAQ;YAAYnE;YAAgB+D;YAAO7B;QAAI;IAChF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateEntityData.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/validateEntityData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAI1F,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAuBrE,eAAO,MAAM,sBAAsB,4CAKhC;IACD,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA;AAEJ,eAAO,MAAM,kBAAkB,+BAI5B;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA"}
1
+ {"version":3,"file":"validateEntityData.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/validateEntityData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAI1F,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAuBrE,eAAO,MAAM,sBAAsB,GAAI,yCAKpC;IACD,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA;AAEJ,eAAO,MAAM,kBAAkB,GAAI,4BAIhC;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AA+BnE,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,aAAa;;QACP,OAAO;QAAmB,IAAI;;CACU,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAA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E,sBAAsB,CAAC,CAAC,CACzE,CAAA;AAED,eAAO,MAAM,0BAA0B,EAA0C,KAAK,CACpF,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAC9C,CAAA;AAED,eAAO,MAAM,+BAA+B,EAA+C,KAAK,CAC9F,CAAC,yBAAyB,EAAE,CAAC,OAAO,wBAAwB,EAAE,yBAAyB,CAAC,CAAC,CAC1F,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAsC,KAAK,CAC5E,CAAC,oBAAoB,EAAE,aAAa,CAAC,CACtC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeMCPConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/sanitizeMCPConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAGN,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAMV,eAAe,EACf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAcpB;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,8BAG3B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBA6DH,CAAA"}
1
+ {"version":3,"file":"sanitizeMCPConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/sanitizeMCPConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAGN,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAMV,eAAe,EACf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAcpB;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,2BAG/B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBA6DH,CAAA"}
package/dist/stdio.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import type { SanitizedConfig } from 'payload';
1
2
  /**
2
3
  * Starts Payload's MCP server over stdin and stdout.
3
4
  *
4
5
  * Set `PAYLOAD_MCP_AUTHORIZATION` to authenticate. In development,
5
6
  * `PAYLOAD_MCP_OVERRIDE_ACCESS=true` skips access checks.
6
7
  */
7
- export declare const runMcpStdio: () => Promise<void>;
8
+ export declare const runMcpStdio: (configOverride?: SanitizedConfig) => Promise<void>;
8
9
  //# sourceMappingURL=stdio.d.ts.map