@payloadcms/plugin-mcp 4.0.0-internal.4cbdd50 → 4.0.0-internal.4e1f822
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.
- package/LICENSE.md +1 -1
- package/bin.js +7 -0
- package/dist/defaultAccess.d.ts.map +1 -1
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts +2 -7
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +6 -13
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +57 -17
- package/dist/endpoint/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +5 -5
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +67 -33
- package/dist/mcp/buildMcpServer.js.map +1 -1
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/authTools.js +79 -56
- package/dist/mcp/builtin/collections/authTools.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/countTool.js +10 -16
- package/dist/mcp/builtin/collections/countTool.js.map +1 -1
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/countVersionsTool.js +10 -15
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +104 -54
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +41 -45
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.js +27 -38
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +123 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +86 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findDistinctTool.js +12 -28
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +23 -46
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +18 -28
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findVersionsTool.js +17 -32
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +51 -11
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.js +15 -28
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +62 -86
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
- package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
- package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
- package/dist/mcp/builtin/formatEntityError.js +55 -0
- package/dist/mcp/builtin/formatEntityError.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +5 -7
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.js +10 -15
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +12 -18
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +14 -26
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findVersionsTool.js +14 -31
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +28 -10
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.js +16 -24
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +28 -37
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +6 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +9 -3
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +5 -1
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -4
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +61 -42
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +61 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +8 -12
- package/src/endpoint/access.ts +5 -13
- package/src/endpoint/index.ts +45 -16
- package/src/index.ts +4 -4
- package/src/mcp/buildMcpServer.ts +79 -49
- package/src/mcp/builtin/collections/authTools.ts +77 -69
- package/src/mcp/builtin/collections/countTool.ts +10 -23
- package/src/mcp/builtin/collections/countVersionsTool.ts +10 -20
- package/src/mcp/builtin/collections/createTool.ts +110 -77
- package/src/mcp/builtin/collections/deleteTool.ts +36 -65
- package/src/mcp/builtin/collections/duplicateTool.ts +34 -86
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +169 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +12 -65
- package/src/mcp/builtin/collections/findTool.ts +23 -106
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +16 -60
- package/src/mcp/builtin/collections/findVersionsTool.ts +15 -87
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +48 -14
- package/src/mcp/builtin/collections/restoreVersionTool.ts +15 -58
- package/src/mcp/builtin/collections/updateTool.ts +61 -100
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/formatEntityError.ts +77 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +4 -5
- package/src/mcp/builtin/globals/countVersionsTool.ts +10 -19
- package/src/mcp/builtin/globals/findTool.ts +14 -53
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +14 -54
- package/src/mcp/builtin/globals/findVersionsTool.ts +15 -94
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +30 -8
- package/src/mcp/builtin/globals/restoreVersionTool.ts +15 -47
- package/src/mcp/builtin/globals/updateTool.ts +39 -62
- package/src/mcp/builtinTools.ts +9 -2
- package/src/mcp/sanitizeMCPConfig.ts +5 -1
- package/src/stdio.ts +61 -43
- package/src/types.ts +61 -13
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
- package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
- package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
- package/dist/mcp/builtin/validateEntityData.js +0 -82
- package/dist/mcp/builtin/validateEntityData.js.map +0 -1
- package/dist/utils/getVirtualFieldNames.d.ts +0 -14
- package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
- package/dist/utils/getVirtualFieldNames.js +0 -35
- package/dist/utils/getVirtualFieldNames.js.map +0 -1
- package/dist/utils/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -11
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -34
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
- package/dist/utils/transformPointDataToPayload.d.ts +0 -7
- package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
- package/dist/utils/transformPointDataToPayload.js +0 -28
- package/dist/utils/transformPointDataToPayload.js.map +0 -1
- package/dist/utils/whereSchema.d.ts +0 -9
- package/dist/utils/whereSchema.d.ts.map +0 -1
- package/dist/utils/whereSchema.js +0 -13
- package/dist/utils/whereSchema.js.map +0 -1
- package/src/@types/assets.d.ts +0 -3
- package/src/mcp/builtin/collections/formatCollectionError.ts +0 -84
- package/src/mcp/builtin/validateEntityData.ts +0 -132
- package/src/utils/getVirtualFieldNames.ts +0 -53
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -78
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
- package/src/utils/transformPointDataToPayload.ts +0 -40
- package/src/utils/whereSchema.ts +0 -24
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAccessResults, isEntityHidden } from 'payload';
|
|
1
|
+
import { getAccessResults, getConfigInfoInputSchema, isEntityHidden } from 'payload';
|
|
2
2
|
import { defineTool } from '../../defineTool.js';
|
|
3
3
|
export const getConfigInfoTool = defineTool({
|
|
4
4
|
annotations: {
|
|
@@ -8,14 +8,12 @@ export const getConfigInfoTool = defineTool({
|
|
|
8
8
|
readOnlyHint: true,
|
|
9
9
|
title: 'Config Info'
|
|
10
10
|
},
|
|
11
|
-
description: 'List the Payload collection and global slugs visible to this MCP client.'
|
|
11
|
+
description: 'List the Payload collection and global slugs visible to this MCP client.',
|
|
12
|
+
input: getConfigInfoInputSchema
|
|
12
13
|
}).handler(async ({ authorizedMCP, req })=>{
|
|
13
|
-
const user =
|
|
14
|
+
const user = req.user;
|
|
14
15
|
const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({
|
|
15
|
-
req
|
|
16
|
-
...req,
|
|
17
|
-
user
|
|
18
|
-
}
|
|
16
|
+
req
|
|
19
17
|
});
|
|
20
18
|
const authorizedCollectionSlugs = new Set();
|
|
21
19
|
const authorizedGlobalSlugs = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mcp/builtin/getConfigInfoTool.ts"],"sourcesContent":["import { getAccessResults, isEntityHidden } from 'payload'\n\nimport { defineTool } from '../../defineTool.js'\n\nexport const getConfigInfoTool = defineTool({\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Config Info',\n },\n description: 'List the Payload collection and global slugs visible to this MCP client.',\n}).handler(async ({ authorizedMCP, req }) => {\n const user =
|
|
1
|
+
{"version":3,"sources":["../../../src/mcp/builtin/getConfigInfoTool.ts"],"sourcesContent":["import { getAccessResults, getConfigInfoInputSchema, isEntityHidden } from 'payload'\n\nimport { defineTool } from '../../defineTool.js'\n\nexport const getConfigInfoTool = defineTool({\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Config Info',\n },\n description: 'List the Payload collection and global slugs visible to this MCP client.',\n input: getConfigInfoInputSchema,\n}).handler(async ({ authorizedMCP, req }) => {\n const user = req.user\n const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({ req })\n const authorizedCollectionSlugs = new Set<string>()\n const authorizedGlobalSlugs = new Set<string>()\n\n for (const item of authorizedMCP.items) {\n if (item.type === 'collectionTool') {\n authorizedCollectionSlugs.add(item.collectionSlug)\n } else if (item.type === 'globalTool') {\n authorizedGlobalSlugs.add(item.globalSlug)\n }\n }\n\n const collections: string[] = []\n const globals: string[] = []\n\n for (const collection of req.payload.config.collections) {\n if (!authorizedCollectionSlugs.has(collection.slug)) {\n continue\n }\n if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {\n continue\n }\n if (!authorizedMCP.overrideAccess && !permissions?.collections?.[collection.slug]?.read) {\n continue\n }\n\n collections.push(collection.slug)\n }\n\n for (const global of req.payload.config.globals) {\n if (!authorizedGlobalSlugs.has(global.slug)) {\n continue\n }\n if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {\n continue\n }\n if (!authorizedMCP.overrideAccess && !permissions?.globals?.[global.slug]?.read) {\n continue\n }\n\n globals.push(global.slug)\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Collections: ${collections.join(', ') || 'none'}\\nGlobals: ${globals.join(', ') || 'none'}`,\n },\n ],\n }\n})\n"],"names":["getAccessResults","getConfigInfoInputSchema","isEntityHidden","defineTool","getConfigInfoTool","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","user","permissions","overrideAccess","authorizedCollectionSlugs","Set","authorizedGlobalSlugs","item","items","type","add","collectionSlug","globalSlug","collections","globals","collection","payload","config","has","slug","hidden","admin","read","push","global","content","text","join"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,wBAAwB,EAAEC,cAAc,QAAQ,UAAS;AAEpF,SAASC,UAAU,QAAQ,sBAAqB;AAEhD,OAAO,MAAMC,oBAAoBD,WAAW;IAC1CE,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;IACbC,OAAOX;AACT,GAAGY,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAEC,GAAG,EAAE;IACtC,MAAMC,OAAOD,IAAIC,IAAI;IACrB,MAAMC,cAAcH,cAAcI,cAAc,GAAG,OAAO,MAAMlB,iBAAiB;QAAEe;IAAI;IACvF,MAAMI,4BAA4B,IAAIC;IACtC,MAAMC,wBAAwB,IAAID;IAElC,KAAK,MAAME,QAAQR,cAAcS,KAAK,CAAE;QACtC,IAAID,KAAKE,IAAI,KAAK,kBAAkB;YAClCL,0BAA0BM,GAAG,CAACH,KAAKI,cAAc;QACnD,OAAO,IAAIJ,KAAKE,IAAI,KAAK,cAAc;YACrCH,sBAAsBI,GAAG,CAACH,KAAKK,UAAU;QAC3C;IACF;IAEA,MAAMC,cAAwB,EAAE;IAChC,MAAMC,UAAoB,EAAE;IAE5B,KAAK,MAAMC,cAAcf,IAAIgB,OAAO,CAACC,MAAM,CAACJ,WAAW,CAAE;QACvD,IAAI,CAACT,0BAA0Bc,GAAG,CAACH,WAAWI,IAAI,GAAG;YACnD;QACF;QACA,IAAIlB,QAAQd,eAAe;YAAEiC,QAAQL,WAAWM,KAAK,CAACD,MAAM;YAAEnB;QAAK,IAAI;YACrE;QACF;QACA,IAAI,CAACF,cAAcI,cAAc,IAAI,CAACD,aAAaW,aAAa,CAACE,WAAWI,IAAI,CAAC,EAAEG,MAAM;YACvF;QACF;QAEAT,YAAYU,IAAI,CAACR,WAAWI,IAAI;IAClC;IAEA,KAAK,MAAMK,UAAUxB,IAAIgB,OAAO,CAACC,MAAM,CAACH,OAAO,CAAE;QAC/C,IAAI,CAACR,sBAAsBY,GAAG,CAACM,OAAOL,IAAI,GAAG;YAC3C;QACF;QACA,IAAIlB,QAAQd,eAAe;YAAEiC,QAAQI,OAAOH,KAAK,CAACD,MAAM;YAAEnB;QAAK,IAAI;YACjE;QACF;QACA,IAAI,CAACF,cAAcI,cAAc,IAAI,CAACD,aAAaY,SAAS,CAACU,OAAOL,IAAI,CAAC,EAAEG,MAAM;YAC/E;QACF;QAEAR,QAAQS,IAAI,CAACC,OAAOL,IAAI;IAC1B;IAEA,OAAO;QACLM,SAAS;YACP;gBACEhB,MAAM;gBACNiB,MAAM,CAAC,aAAa,EAAEb,YAAYc,IAAI,CAAC,SAAS,OAAO,WAAW,EAAEb,QAAQa,IAAI,CAAC,SAAS,QAAQ;YACpG;SACD;IACH;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"countVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,uBAAuB,wCAkDlC,CAAA"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { countGlobalVersionsInputSchema } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineGlobalTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
|
-
import { whereSchema } from '../../../utils/whereSchema.js';
|
|
7
5
|
const DEFAULT_DESCRIPTION = 'Count global versions in any version-enabled global by passing the global slug and optional where clause.';
|
|
8
6
|
export const countGlobalVersionsTool = defineGlobalTool({
|
|
9
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
|
|
10
8
|
annotations: {
|
|
11
9
|
destructiveHint: false,
|
|
12
10
|
idempotentHint: true,
|
|
@@ -15,22 +13,19 @@ export const countGlobalVersionsTool = defineGlobalTool({
|
|
|
15
13
|
title: 'Count Global Versions'
|
|
16
14
|
},
|
|
17
15
|
description: DEFAULT_DESCRIPTION,
|
|
18
|
-
input:
|
|
19
|
-
|
|
20
|
-
where: whereSchema.describe('Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}').optional()
|
|
21
|
-
})
|
|
22
|
-
}).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
|
|
16
|
+
input: countGlobalVersionsInputSchema
|
|
17
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
23
18
|
const payload = req.payload;
|
|
24
19
|
const logger = getLogger({
|
|
25
20
|
payload
|
|
26
21
|
});
|
|
27
22
|
const { locale, where } = input;
|
|
28
|
-
logger.info(`Counting versions for global: ${
|
|
23
|
+
logger.info(`Counting versions for global: ${slug}`);
|
|
29
24
|
try {
|
|
30
25
|
const result = await payload.countGlobalVersions({
|
|
31
|
-
global:
|
|
26
|
+
global: slug,
|
|
27
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
32
28
|
req,
|
|
33
|
-
...localAPIDefaults(authorizedMCP),
|
|
34
29
|
...locale ? {
|
|
35
30
|
locale
|
|
36
31
|
} : {},
|
|
@@ -42,19 +37,19 @@ export const countGlobalVersionsTool = defineGlobalTool({
|
|
|
42
37
|
content: [
|
|
43
38
|
{
|
|
44
39
|
type: 'text',
|
|
45
|
-
text: `Global "${
|
|
40
|
+
text: `Global "${slug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
46
41
|
}
|
|
47
42
|
],
|
|
48
43
|
doc: result
|
|
49
44
|
};
|
|
50
45
|
} catch (error) {
|
|
51
46
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
52
|
-
logger.error(`Error counting versions for global ${
|
|
47
|
+
logger.error(`Error counting versions for global ${slug}: ${errorMessage}`);
|
|
53
48
|
return {
|
|
54
49
|
content: [
|
|
55
50
|
{
|
|
56
51
|
type: 'text',
|
|
57
|
-
text: `❌ **Error counting versions for global "${
|
|
52
|
+
text: `❌ **Error counting versions for global "${slug}":** ${errorMessage}`
|
|
58
53
|
}
|
|
59
54
|
],
|
|
60
55
|
isError: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"sourcesContent":["import { countGlobalVersionsInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Count global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const countGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Count Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: countGlobalVersionsInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { locale, where } = input\n\n logger.info(`Counting versions for global: ${slug}`)\n\n try {\n const result = await payload.countGlobalVersions({\n global: slug,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(locale ? { locale } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${slug}\" contains ${result.totalDocs} matching versions.\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error counting versions for global ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error counting versions for global \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["countGlobalVersionsInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","countGlobalVersionsTool","access","args","Boolean","permissions","globals","slug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","locale","where","info","result","countGlobalVersions","global","overrideAccess","content","type","text","totalDocs","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,8BAA8B,QAAQ,UAAS;AAExD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,0BAA0BH,iBAAiB;IACtDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzEC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IACnC,MAAM,EAAEE,MAAM,EAAEC,KAAK,EAAE,GAAGP;IAE1BK,OAAOG,IAAI,CAAC,CAAC,8BAA8B,EAAEjB,MAAM;IAEnD,IAAI;QACF,MAAMkB,SAAS,MAAML,QAAQM,mBAAmB,CAAC;YAC/CC,QAAQpB;YACRqB,gBAAgBV,cAAcU,cAAc;YAC5CT;YACA,GAAIG,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;QAEA,OAAO;YACLM,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAExB,KAAK,WAAW,EAAEkB,OAAOO,SAAS,CAAC,iCAAiC,EAAEC,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBACzH;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DlB,OAAOe,KAAK,CAAC,CAAC,mCAAmC,EAAE7B,KAAK,EAAE,EAAE8B,cAAc;QAC1E,OAAO;YACLR,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,wCAAwC,EAAExB,KAAK,KAAK,EAAE8B,cAAc;gBAC7E;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,wCAyDzB,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findGlobalInputSchema } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineGlobalTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
5
|
const DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.';
|
|
7
6
|
export const findGlobalTool = defineGlobalTool({
|
|
8
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.read),
|
|
9
8
|
annotations: {
|
|
10
9
|
destructiveHint: false,
|
|
11
10
|
idempotentHint: true,
|
|
@@ -14,30 +13,25 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
14
13
|
title: 'Find Global'
|
|
15
14
|
},
|
|
16
15
|
description: DEFAULT_DESCRIPTION,
|
|
17
|
-
input:
|
|
18
|
-
|
|
19
|
-
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
20
|
-
locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
|
|
21
|
-
populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
|
|
22
|
-
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}').optional()
|
|
23
|
-
})
|
|
24
|
-
}).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
|
|
16
|
+
input: findGlobalInputSchema
|
|
17
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
25
18
|
const payload = req.payload;
|
|
26
19
|
const logger = getLogger({
|
|
27
20
|
payload
|
|
28
21
|
});
|
|
29
22
|
const { depth, fallbackLocale, locale, populate, select } = input;
|
|
30
|
-
logger.info(`Reading global: ${
|
|
23
|
+
logger.info(`Reading global: ${slug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`);
|
|
31
24
|
try {
|
|
32
25
|
const findOptions = {
|
|
33
|
-
slug
|
|
26
|
+
slug,
|
|
34
27
|
depth,
|
|
35
|
-
|
|
28
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
29
|
+
req
|
|
36
30
|
};
|
|
37
31
|
if (locale) {
|
|
38
32
|
findOptions.locale = locale;
|
|
39
33
|
}
|
|
40
|
-
if (fallbackLocale) {
|
|
34
|
+
if (fallbackLocale !== undefined) {
|
|
41
35
|
findOptions.fallbackLocale = fallbackLocale;
|
|
42
36
|
}
|
|
43
37
|
if (select) {
|
|
@@ -51,19 +45,19 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
51
45
|
content: [
|
|
52
46
|
{
|
|
53
47
|
type: 'text',
|
|
54
|
-
text: `Global "${
|
|
48
|
+
text: `Global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
55
49
|
}
|
|
56
50
|
],
|
|
57
51
|
doc: result
|
|
58
52
|
};
|
|
59
53
|
} catch (error) {
|
|
60
54
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
61
|
-
logger.error(`Error reading global ${
|
|
55
|
+
logger.error(`Error reading global ${slug}: ${errorMessage}`);
|
|
62
56
|
return {
|
|
63
57
|
content: [
|
|
64
58
|
{
|
|
65
59
|
type: 'text',
|
|
66
|
-
text: `❌ **Error reading global "${
|
|
60
|
+
text: `❌ **Error reading global "${slug}":** ${errorMessage}`
|
|
67
61
|
}
|
|
68
62
|
]
|
|
69
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"sourcesContent":["import { findGlobalInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'\n\nexport const findGlobalTool = defineGlobalTool({\n access: (args) => defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.read),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global',\n },\n description: DEFAULT_DESCRIPTION,\n input: findGlobalInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { depth, fallbackLocale, locale, populate, select } = input\n\n logger.info(`Reading global: ${slug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`)\n\n try {\n const findOptions: Parameters<typeof payload.findGlobal>[0] = {\n slug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n }\n\n if (locale) {\n findOptions.locale = locale\n }\n if (fallbackLocale !== undefined) {\n findOptions.fallbackLocale = fallbackLocale\n }\n if (select) {\n findOptions.select = select\n }\n if (populate) {\n findOptions.populate = populate\n }\n const result = await payload.findGlobal(findOptions)\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${slug}\":\\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 reading global ${slug}: ${errorMessage}`)\n return {\n content: [{ type: 'text', text: `❌ **Error reading global \"${slug}\":** ${errorMessage}` }],\n }\n }\n})\n"],"names":["findGlobalInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalTool","access","args","Boolean","permissions","globals","slug","read","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","depth","fallbackLocale","locale","populate","select","info","findOptions","overrideAccess","undefined","result","findGlobal","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,UAAS;AAE/C,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBAAsB;AAE5B,OAAO,MAAMC,iBAAiBH,iBAAiB;IAC7CI,QAAQ,CAACC,OAASN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzFC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IAEnC,MAAM,EAAEE,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGV;IAE5DK,OAAOM,IAAI,CAAC,CAAC,gBAAgB,EAAEpB,KAAK,SAAS,EAAEe,QAAQE,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;IAE5F,IAAI;QACF,MAAMI,cAAwD;YAC5DrB;YACAe;YACAO,gBAAgBX,cAAcW,cAAc;YAC5CV;QACF;QAEA,IAAIK,QAAQ;YACVI,YAAYJ,MAAM,GAAGA;QACvB;QACA,IAAID,mBAAmBO,WAAW;YAChCF,YAAYL,cAAc,GAAGA;QAC/B;QACA,IAAIG,QAAQ;YACVE,YAAYF,MAAM,GAAGA;QACvB;QACA,IAAID,UAAU;YACZG,YAAYH,QAAQ,GAAGA;QACzB;QACA,MAAMM,SAAS,MAAMX,QAAQY,UAAU,CAACJ;QAExC,OAAO;YACLK,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAE5B,KAAK,gBAAgB,EAAE6B,KAAKC,SAAS,CAACN,QAAQ,QAAQ,CAAC;gBAC1E;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DrB,OAAOkB,KAAK,CAAC,CAAC,qBAAqB,EAAEhC,KAAK,EAAE,EAAEiC,cAAc;QAC5D,OAAO;YACLP,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,0BAA0B,EAAE5B,KAAK,KAAK,EAAEiC,cAAc;gBAAC;aAAE;QAC5F;IACF;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByIDTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findVersionByIDTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,yBAAyB,wCAsDpC,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findGlobalVersionByIDInputSchema } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineGlobalTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
5
|
const DEFAULT_DESCRIPTION = 'Find a specific global version in any version-enabled global by passing the global slug and version ID.';
|
|
7
6
|
export const findGlobalVersionByIDTool = defineGlobalTool({
|
|
8
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
|
|
9
8
|
annotations: {
|
|
10
9
|
destructiveHint: false,
|
|
11
10
|
idempotentHint: true,
|
|
@@ -14,62 +13,51 @@ export const findGlobalVersionByIDTool = defineGlobalTool({
|
|
|
14
13
|
title: 'Find Global Version By ID'
|
|
15
14
|
},
|
|
16
15
|
description: DEFAULT_DESCRIPTION,
|
|
17
|
-
input:
|
|
18
|
-
|
|
19
|
-
depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in the global version document').optional().default(0),
|
|
20
|
-
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
21
|
-
locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
|
|
22
|
-
populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
|
|
23
|
-
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.siteName": true}').optional(),
|
|
24
|
-
showHiddenFields: z.boolean().describe('Optional: include hidden fields in the returned global version document').optional()
|
|
25
|
-
})
|
|
26
|
-
}).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
|
|
16
|
+
input: findGlobalVersionByIDInputSchema
|
|
17
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
27
18
|
const payload = req.payload;
|
|
28
19
|
const logger = getLogger({
|
|
29
20
|
payload
|
|
30
21
|
});
|
|
31
|
-
const { id, depth, fallbackLocale, locale, populate, select
|
|
32
|
-
logger.info(`Finding version for global: ${
|
|
22
|
+
const { id, depth, fallbackLocale, locale, populate, select } = input;
|
|
23
|
+
logger.info(`Finding version for global: ${slug} with ID: ${id}`);
|
|
33
24
|
try {
|
|
34
25
|
const result = await payload.findGlobalVersionByID({
|
|
35
26
|
id,
|
|
36
|
-
slug
|
|
27
|
+
slug,
|
|
37
28
|
depth,
|
|
29
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
38
30
|
req,
|
|
39
|
-
...
|
|
40
|
-
...fallbackLocale ? {
|
|
31
|
+
...fallbackLocale !== undefined ? {
|
|
41
32
|
fallbackLocale
|
|
42
33
|
} : {},
|
|
43
34
|
...locale ? {
|
|
44
35
|
locale
|
|
45
36
|
} : {},
|
|
46
37
|
...populate ? {
|
|
47
|
-
populate
|
|
38
|
+
populate
|
|
48
39
|
} : {},
|
|
49
40
|
...select ? {
|
|
50
|
-
select
|
|
51
|
-
} : {},
|
|
52
|
-
...showHiddenFields !== undefined ? {
|
|
53
|
-
showHiddenFields
|
|
41
|
+
select
|
|
54
42
|
} : {}
|
|
55
43
|
});
|
|
56
44
|
return {
|
|
57
45
|
content: [
|
|
58
46
|
{
|
|
59
47
|
type: 'text',
|
|
60
|
-
text: `Version "${id}" from global "${
|
|
48
|
+
text: `Version "${id}" from global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
61
49
|
}
|
|
62
50
|
],
|
|
63
51
|
doc: result
|
|
64
52
|
};
|
|
65
53
|
} catch (error) {
|
|
66
54
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
67
|
-
logger.error(`Error finding version ${id} for global ${
|
|
55
|
+
logger.error(`Error finding version ${id} for global ${slug}: ${errorMessage}`);
|
|
68
56
|
return {
|
|
69
57
|
content: [
|
|
70
58
|
{
|
|
71
59
|
type: 'text',
|
|
72
|
-
text: `❌ **Error finding version "${id}" for global "${
|
|
60
|
+
text: `❌ **Error finding version "${id}" for global "${slug}":** ${errorMessage}`
|
|
73
61
|
}
|
|
74
62
|
],
|
|
75
63
|
isError: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"sourcesContent":["import { findGlobalVersionByIDInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find a specific global version in any version-enabled global by passing the global slug and version ID.'\n\nexport const findGlobalVersionByIDTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Version By ID',\n },\n description: DEFAULT_DESCRIPTION,\n input: findGlobalVersionByIDInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, select } = input\n\n logger.info(`Finding version for global: ${slug} with ID: ${id}`)\n\n try {\n const result = await payload.findGlobalVersionByID({\n id,\n slug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate } : {}),\n ...(select ? { select } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" from global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding version ${id} for global ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding version \"${id}\" for global \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["findGlobalVersionByIDInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalVersionByIDTool","access","args","Boolean","permissions","globals","slug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","id","depth","fallbackLocale","locale","populate","select","info","result","findGlobalVersionByID","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,gCAAgC,QAAQ,UAAS;AAE1D,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,4BAA4BH,iBAAiB;IACxDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzEC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IACnC,MAAM,EAAEE,EAAE,EAAEC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGX;IAEhEK,OAAOO,IAAI,CAAC,CAAC,4BAA4B,EAAErB,KAAK,UAAU,EAAEe,IAAI;IAEhE,IAAI;QACF,MAAMO,SAAS,MAAMT,QAAQU,qBAAqB,CAAC;YACjDR;YACAf;YACAgB;YACAQ,gBAAgBb,cAAca,cAAc;YAC5CZ;YACA,GAAIK,mBAAmBQ,YAAY;gBAAER;YAAe,IAAI,CAAC,CAAC;YAC1D,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,WAAW;gBAAEA;YAAS,IAAI,CAAC,CAAC;YAChC,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;QAC9B;QAEA,OAAO;YACLM,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,SAAS,EAAEb,GAAG,eAAe,EAAEf,KAAK,gBAAgB,EAAE6B,KAAKC,SAAS,CAACR,QAAQ,QAAQ,CAAC;gBAC/F;aACD;YACDS,KAAKT;QACP;IACF,EAAE,OAAOU,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DrB,OAAOkB,KAAK,CAAC,CAAC,sBAAsB,EAAEjB,GAAG,YAAY,EAAEf,KAAK,EAAE,EAAEiC,cAAc;QAC9E,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,2BAA2B,EAAEb,GAAG,cAAc,EAAEf,KAAK,KAAK,EAAEiC,cAAc;gBACnF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,sBAAsB,wCA2DjC,CAAA"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findGlobalVersionsInputSchema } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineGlobalTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
|
-
import { whereSchema } from '../../../utils/whereSchema.js';
|
|
7
5
|
const DEFAULT_DESCRIPTION = 'Find global versions in any version-enabled global by passing the global slug and optional where clause.';
|
|
8
6
|
export const findGlobalVersionsTool = defineGlobalTool({
|
|
9
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
|
|
10
8
|
annotations: {
|
|
11
9
|
destructiveHint: false,
|
|
12
10
|
idempotentHint: true,
|
|
@@ -15,35 +13,23 @@ export const findGlobalVersionsTool = defineGlobalTool({
|
|
|
15
13
|
title: 'Find Global Versions'
|
|
16
14
|
},
|
|
17
15
|
description: DEFAULT_DESCRIPTION,
|
|
18
|
-
input:
|
|
19
|
-
|
|
20
|
-
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
21
|
-
limit: z.number().int().min(1).max(100).describe('Maximum number of versions to return (default: 10, max: 100)').optional().default(10),
|
|
22
|
-
locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
|
|
23
|
-
page: z.number().int().min(1).describe('Page number for pagination (default: 1)').optional().default(1),
|
|
24
|
-
pagination: z.boolean().describe('Optional: set to false to skip the count query overhead').optional(),
|
|
25
|
-
populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
|
|
26
|
-
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.siteName": true}').optional(),
|
|
27
|
-
showHiddenFields: z.boolean().describe('Optional: include hidden fields in returned global version documents').optional(),
|
|
28
|
-
sort: z.string().describe('Field to sort by (e.g., "-updatedAt", "-version.updatedAt" for descending)').optional(),
|
|
29
|
-
where: whereSchema.describe('Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}').optional()
|
|
30
|
-
})
|
|
31
|
-
}).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
|
|
16
|
+
input: findGlobalVersionsInputSchema
|
|
17
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
32
18
|
const payload = req.payload;
|
|
33
19
|
const logger = getLogger({
|
|
34
20
|
payload
|
|
35
21
|
});
|
|
36
|
-
const { depth, fallbackLocale, limit, locale, page, pagination, populate, select,
|
|
37
|
-
logger.info(`Finding versions for global: ${
|
|
22
|
+
const { depth, fallbackLocale, limit, locale, page, pagination, populate, select, sort, where } = input;
|
|
23
|
+
logger.info(`Finding versions for global: ${slug}, limit: ${limit}, page: ${page}`);
|
|
38
24
|
try {
|
|
39
25
|
const result = await payload.findGlobalVersions({
|
|
40
|
-
slug
|
|
26
|
+
slug,
|
|
41
27
|
depth,
|
|
42
28
|
limit,
|
|
29
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
43
30
|
page,
|
|
44
31
|
req,
|
|
45
|
-
...
|
|
46
|
-
...fallbackLocale ? {
|
|
32
|
+
...fallbackLocale !== undefined ? {
|
|
47
33
|
fallbackLocale
|
|
48
34
|
} : {},
|
|
49
35
|
...locale ? {
|
|
@@ -53,13 +39,10 @@ export const findGlobalVersionsTool = defineGlobalTool({
|
|
|
53
39
|
pagination
|
|
54
40
|
} : {},
|
|
55
41
|
...populate ? {
|
|
56
|
-
populate
|
|
42
|
+
populate
|
|
57
43
|
} : {},
|
|
58
44
|
...select ? {
|
|
59
|
-
select
|
|
60
|
-
} : {},
|
|
61
|
-
...showHiddenFields !== undefined ? {
|
|
62
|
-
showHiddenFields
|
|
45
|
+
select
|
|
63
46
|
} : {},
|
|
64
47
|
...sort ? {
|
|
65
48
|
sort
|
|
@@ -72,19 +55,19 @@ export const findGlobalVersionsTool = defineGlobalTool({
|
|
|
72
55
|
content: [
|
|
73
56
|
{
|
|
74
57
|
type: 'text',
|
|
75
|
-
text: `Versions for global "${
|
|
58
|
+
text: `Versions for global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
76
59
|
}
|
|
77
60
|
],
|
|
78
61
|
doc: result
|
|
79
62
|
};
|
|
80
63
|
} catch (error) {
|
|
81
64
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
82
|
-
logger.error(`Error finding versions for global ${
|
|
65
|
+
logger.error(`Error finding versions for global ${slug}: ${errorMessage}`);
|
|
83
66
|
return {
|
|
84
67
|
content: [
|
|
85
68
|
{
|
|
86
69
|
type: 'text',
|
|
87
|
-
text: `❌ **Error finding versions for global "${
|
|
70
|
+
text: `❌ **Error finding versions for global "${slug}":** ${errorMessage}`
|
|
88
71
|
}
|
|
89
72
|
],
|
|
90
73
|
isError: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"sourcesContent":["import { findGlobalVersionsInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const findGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: findGlobalVersionsInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { depth, fallbackLocale, limit, locale, page, pagination, populate, select, sort, where } =\n input\n\n logger.info(`Finding versions for global: ${slug}, limit: ${limit}, page: ${page}`)\n\n try {\n const result = await payload.findGlobalVersions({\n slug,\n depth,\n limit,\n overrideAccess: authorizedMCP.overrideAccess,\n page,\n req,\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(pagination !== undefined ? { pagination } : {}),\n ...(populate ? { populate } : {}),\n ...(select ? { select } : {}),\n ...(sort ? { sort } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Versions for global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding versions for global ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding versions for global \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["findGlobalVersionsInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalVersionsTool","access","args","Boolean","permissions","globals","slug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","depth","fallbackLocale","limit","locale","page","pagination","populate","select","sort","where","info","result","findGlobalVersions","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,6BAA6B,QAAQ,UAAS;AAEvD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,yBAAyBH,iBAAiB;IACrDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzEC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IACnC,MAAM,EAAEE,KAAK,EAAEC,cAAc,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAC7Ff;IAEFK,OAAOW,IAAI,CAAC,CAAC,6BAA6B,EAAEzB,KAAK,SAAS,EAAEiB,MAAM,QAAQ,EAAEE,MAAM;IAElF,IAAI;QACF,MAAMO,SAAS,MAAMb,QAAQc,kBAAkB,CAAC;YAC9C3B;YACAe;YACAE;YACAW,gBAAgBjB,cAAciB,cAAc;YAC5CT;YACAP;YACA,GAAII,mBAAmBa,YAAY;gBAAEb;YAAe,IAAI,CAAC,CAAC;YAC1D,GAAIE,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIE,eAAeS,YAAY;gBAAET;YAAW,IAAI,CAAC,CAAC;YAClD,GAAIC,WAAW;gBAAEA;YAAS,IAAI,CAAC,CAAC;YAChC,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,OAAO;gBAAEA;YAAK,IAAI,CAAC,CAAC;YACxB,GAAIC,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;QAEA,OAAO;YACLM,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,qBAAqB,EAAEhC,KAAK,gBAAgB,EAAEiC,KAAKC,SAAS,CAACR,QAAQ,QAAQ,CAAC;gBACvF;aACD;YACDS,KAAKT;QACP;IACF,EAAE,OAAOU,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DzB,OAAOsB,KAAK,CAAC,CAAC,kCAAkC,EAAEpC,KAAK,EAAE,EAAEqC,cAAc;QACzE,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,uCAAuC,EAAEhC,KAAK,KAAK,EAAEqC,cAAc;gBAC5E;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGlobalSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getGlobalSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,wCAyD9B,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { getAccessResults, getGlobalInputSchema, getGlobalSchemaInputSchema } from 'payload';
|
|
1
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
2
3
|
import { defineGlobalTool } from '../../../defineTool.js';
|
|
3
|
-
import { getGlobalInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js';
|
|
4
4
|
export const getGlobalSchemaTool = defineGlobalTool({
|
|
5
5
|
access: (args)=>{
|
|
6
|
-
const permissions = args.permissions?.globals?.[args.
|
|
7
|
-
return defaultAccess(args) && Boolean(permissions?.
|
|
6
|
+
const permissions = args.permissions?.globals?.[args.slug];
|
|
7
|
+
return defaultAccess(args) && Boolean(permissions?.update);
|
|
8
8
|
},
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -13,18 +13,36 @@ export const getGlobalSchemaTool = defineGlobalTool({
|
|
|
13
13
|
readOnlyHint: true,
|
|
14
14
|
title: 'Get Global Schema'
|
|
15
15
|
},
|
|
16
|
-
description: 'Get the input schema for updating a global.'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
description: 'Get the input schema for updating a global.',
|
|
17
|
+
input: getGlobalSchemaInputSchema
|
|
18
|
+
}).handler(async ({ slug, authorizedMCP, req })=>{
|
|
19
|
+
const permissions = authorizedMCP.overrideAccess ? null : (await getAccessResults({
|
|
20
20
|
req
|
|
21
|
+
})).globals?.[slug];
|
|
22
|
+
if (!authorizedMCP.overrideAccess && !permissions?.update) {
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: 'text',
|
|
27
|
+
text: `Error: MCP access to "getGlobalSchema" is not enabled for global "${slug}"`
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
isError: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const inputSchema = getGlobalInputSchema({
|
|
34
|
+
globalSlug: slug,
|
|
35
|
+
req,
|
|
36
|
+
...permissions ? {
|
|
37
|
+
permissions
|
|
38
|
+
} : {}
|
|
21
39
|
});
|
|
22
40
|
if (!inputSchema) {
|
|
23
41
|
return {
|
|
24
42
|
content: [
|
|
25
43
|
{
|
|
26
44
|
type: 'text',
|
|
27
|
-
text: `Error: Global "${
|
|
45
|
+
text: `Error: Global "${slug}" not found`
|
|
28
46
|
}
|
|
29
47
|
],
|
|
30
48
|
isError: true
|
|
@@ -34,11 +52,11 @@ export const getGlobalSchemaTool = defineGlobalTool({
|
|
|
34
52
|
content: [
|
|
35
53
|
{
|
|
36
54
|
type: 'text',
|
|
37
|
-
text: `Schema for global "${
|
|
55
|
+
text: `Schema for global "${slug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``
|
|
38
56
|
}
|
|
39
57
|
],
|
|
40
58
|
structuredContent: {
|
|
41
|
-
|
|
59
|
+
slug,
|
|
42
60
|
schema: inputSchema
|
|
43
61
|
}
|
|
44
62
|
};
|