@payloadcms/plugin-mcp 3.71.0-internal.ef75fa0 → 3.71.1
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/dist/collections/createApiKeysCollection.d.ts.map +1 -1
- package/dist/collections/createApiKeysCollection.js +1 -1
- package/dist/collections/createApiKeysCollection.js.map +1 -1
- package/dist/defaults.d.ts +4 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +5 -0
- package/dist/defaults.js.map +1 -0
- package/dist/endpoints/mcp.d.ts.map +1 -1
- package/dist/endpoints/mcp.js +4 -10
- package/dist/endpoints/mcp.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/collections/createApiKeysCollection.ts +2 -6
- package/src/defaults.ts +3 -0
- package/src/endpoints/mcp.ts +4 -14
- package/src/index.ts +6 -0
- package/src/types.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApiKeysCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createApiKeysCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"createApiKeysCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createApiKeysCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAA;AAE/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKxD,eAAO,MAAM,uBAAuB,gBACrB,qBAAqB,CAAC,aAAa,CAAC,WACxC,qBAAqB,CAAC,SAAS,CAAC,eAC5B,KAAK,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,iCACtC,WAAW,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,6BAC/D,qBAAqB,KACnC,gBAuWF,CAAA"}
|
|
@@ -37,7 +37,7 @@ export const createAPIKeysCollection = (collections, globals, customTools = [],
|
|
|
37
37
|
label: camelCasedName
|
|
38
38
|
};
|
|
39
39
|
}) || [];
|
|
40
|
-
const userCollection = pluginOptions.userCollection
|
|
40
|
+
const userCollection = pluginOptions.userCollection;
|
|
41
41
|
return {
|
|
42
42
|
slug: 'payload-mcp-api-keys',
|
|
43
43
|
admin: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/createApiKeysCollection.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../types.js'\n\nimport { toCamelCase } from '../utils/camelCase.js'\nimport { createApiKeyFields } from '../utils/createApiKeyFields.js'\n\nexport const createAPIKeysCollection = (\n collections: PluginMCPServerConfig['collections'],\n globals: PluginMCPServerConfig['globals'],\n customTools: Array<{ description: string; name: string }> = [],\n experimentalTools: NonNullable<PluginMCPServerConfig['experimental']>['tools'] = {},\n pluginOptions: PluginMCPServerConfig,\n): CollectionConfig => {\n const customToolsFields = customTools.map((tool) => {\n const camelCasedName = toCamelCase(tool.name)\n return {\n name: camelCasedName,\n type: 'checkbox' as const,\n admin: {\n description: tool.description,\n },\n defaultValue: true,\n label: camelCasedName,\n }\n })\n\n const customResourceFields =\n pluginOptions.mcp?.resources?.map((resource) => {\n const camelCasedName = toCamelCase(resource.name)\n return {\n name: camelCasedName,\n type: 'checkbox' as const,\n admin: {\n description: resource.description,\n },\n defaultValue: true,\n label: camelCasedName,\n }\n }) || []\n\n const customPromptFields =\n pluginOptions.mcp?.prompts?.map((prompt) => {\n const camelCasedName = toCamelCase(prompt.name)\n return {\n name: camelCasedName,\n type: 'checkbox' as const,\n admin: {\n description: prompt.description,\n },\n defaultValue: true,\n label: camelCasedName,\n }\n }) || []\n\n const userCollection = pluginOptions.userCollection\n ? typeof pluginOptions.userCollection === 'string'\n ? pluginOptions.userCollection\n : pluginOptions.userCollection.slug\n : 'users'\n\n return {\n slug: 'payload-mcp-api-keys',\n admin: {\n description:\n 'API keys control which collections, resources, tools, and prompts MCP clients can access',\n group: 'MCP',\n useAsTitle: 'label',\n },\n auth: {\n disableLocalStrategy: true,\n useAPIKey: true,\n },\n fields: [\n {\n name: 'user',\n type: 'relationship',\n admin: {\n description: 'The user that the API key is associated with.',\n },\n relationTo: userCollection,\n required: true,\n },\n {\n name: 'label',\n type: 'text',\n admin: {\n description: 'A useful label for the API key.',\n },\n },\n {\n name: 'description',\n type: 'text',\n admin: {\n description: 'The purpose of the API key.',\n },\n },\n\n ...createApiKeyFields({\n config: collections,\n configType: 'collection',\n }),\n\n ...createApiKeyFields({\n config: globals,\n configType: 'global',\n }),\n\n ...(customTools.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to tools',\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'payload-mcp-tool',\n type: 'group' as const,\n fields: customToolsFields,\n label: false as const,\n },\n ],\n label: 'Tools',\n },\n ]\n : []),\n\n ...(pluginOptions.mcp?.resources && pluginOptions.mcp?.resources.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to resources',\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'payload-mcp-resource',\n type: 'group' as const,\n fields: customResourceFields,\n label: false as const,\n },\n ],\n label: 'Resources',\n },\n ]\n : []),\n\n ...(pluginOptions.mcp?.prompts && pluginOptions.mcp?.prompts.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to prompts',\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'payload-mcp-prompt',\n type: 'group' as const,\n fields: customPromptFields,\n label: false as const,\n },\n ],\n label: 'Prompts',\n },\n ]\n : []),\n\n // Experimental Tools\n ...(process.env.NODE_ENV === 'development' &&\n (experimentalTools?.collections?.enabled ||\n experimentalTools?.jobs?.enabled ||\n experimentalTools?.config?.enabled ||\n experimentalTools?.auth?.enabled)\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to experimental tools',\n position: 'sidebar' as const,\n },\n fields: [\n ...(experimentalTools?.collections?.enabled\n ? [\n {\n name: 'collections',\n type: 'group' as const,\n fields: [\n {\n name: 'find',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to find and list Payload collections with optional content and document counts.',\n },\n defaultValue: false,\n },\n {\n name: 'create',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to create new Payload collections with specified fields and configuration.',\n },\n defaultValue: false,\n },\n {\n name: 'update',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to update existing Payload collections with new fields, modifications, or configuration changes.',\n },\n defaultValue: false,\n },\n {\n name: 'delete',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to delete Payload collections and optionally update the configuration.',\n },\n defaultValue: false,\n },\n ],\n },\n ]\n : []),\n ...(experimentalTools?.jobs?.enabled\n ? [\n {\n name: 'jobs',\n type: 'group' as const,\n fields: [\n {\n name: 'create',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to create new Payload jobs (tasks and workflows) with custom schemas and configuration.',\n },\n defaultValue: false,\n },\n {\n name: 'run',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to execute Payload jobs with custom input data and queue options.',\n },\n defaultValue: false,\n },\n {\n name: 'update',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to update existing Payload jobs with new schemas, configuration, or handler code.',\n },\n defaultValue: false,\n },\n ],\n },\n ]\n : []),\n ...(experimentalTools?.config?.enabled\n ? [\n {\n name: 'config',\n type: 'group' as const,\n fields: [\n {\n name: 'find',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to read and display a Payload configuration file.',\n },\n defaultValue: false,\n },\n {\n name: 'update',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to update a Payload configuration file with various modifications.',\n },\n defaultValue: false,\n },\n ],\n },\n ]\n : []),\n ...(experimentalTools?.auth?.enabled\n ? [\n {\n name: 'auth',\n type: 'group' as const,\n fields: [\n {\n name: 'auth',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to check authentication status for a user by setting custom headers. (e.g. {\"Authorization\": \"Bearer <token>\"})',\n },\n defaultValue: false,\n label: 'Check Auth Status',\n },\n {\n name: 'login',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to authenticate a user with email and password.',\n },\n defaultValue: false,\n label: 'User Login',\n },\n {\n name: 'verify',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to verify a user email with a verification token.',\n },\n defaultValue: false,\n label: 'Email Verification',\n },\n {\n name: 'resetPassword',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to reset a user password with a reset token.',\n },\n defaultValue: false,\n label: 'Reset Password',\n },\n {\n name: 'forgotPassword',\n type: 'checkbox' as const,\n admin: {\n description: 'Allow LLMs to send a password reset email to a user.',\n },\n defaultValue: false,\n label: 'Forgot Password',\n },\n {\n name: 'unlock',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to unlock a user account that has been locked due to failed login attempts.',\n },\n defaultValue: false,\n label: 'Unlock Account',\n },\n ],\n },\n ]\n : []),\n ],\n label: 'Experimental Tools',\n },\n ]\n : []),\n ],\n labels: {\n plural: 'API Keys',\n singular: 'API Key',\n },\n }\n}\n"],"names":["toCamelCase","createApiKeyFields","createAPIKeysCollection","collections","globals","customTools","experimentalTools","pluginOptions","customToolsFields","map","tool","camelCasedName","name","type","admin","description","defaultValue","label","customResourceFields","mcp","resources","resource","customPromptFields","prompts","prompt","userCollection","slug","group","useAsTitle","auth","disableLocalStrategy","useAPIKey","fields","relationTo","required","config","configType","length","position","process","env","NODE_ENV","enabled","jobs","labels","plural","singular"],"mappings":"AAIA,SAASA,WAAW,QAAQ,wBAAuB;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LC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aAAa;wCACf;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;iCACD;4BACH;yBACD,GACD,EAAE;qBACP;oBACDA,OAAO;gBACT;aACD,GACD,EAAE;SACP;QACD2B,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/collections/createApiKeysCollection.ts"],"sourcesContent":["import type { CollectionConfig, CollectionSlug } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../types.js'\n\nimport { toCamelCase } from '../utils/camelCase.js'\nimport { createApiKeyFields } from '../utils/createApiKeyFields.js'\n\nexport const createAPIKeysCollection = (\n collections: PluginMCPServerConfig['collections'],\n globals: PluginMCPServerConfig['globals'],\n customTools: Array<{ description: string; name: string }> = [],\n experimentalTools: NonNullable<PluginMCPServerConfig['experimental']>['tools'] = {},\n pluginOptions: PluginMCPServerConfig,\n): CollectionConfig => {\n const customToolsFields = customTools.map((tool) => {\n const camelCasedName = toCamelCase(tool.name)\n return {\n name: camelCasedName,\n type: 'checkbox' as const,\n admin: {\n description: tool.description,\n },\n defaultValue: true,\n label: camelCasedName,\n }\n })\n\n const customResourceFields =\n pluginOptions.mcp?.resources?.map((resource) => {\n const camelCasedName = toCamelCase(resource.name)\n return {\n name: camelCasedName,\n type: 'checkbox' as const,\n admin: {\n description: resource.description,\n },\n defaultValue: true,\n label: camelCasedName,\n }\n }) || []\n\n const customPromptFields =\n pluginOptions.mcp?.prompts?.map((prompt) => {\n const camelCasedName = toCamelCase(prompt.name)\n return {\n name: camelCasedName,\n type: 'checkbox' as const,\n admin: {\n description: prompt.description,\n },\n defaultValue: true,\n label: camelCasedName,\n }\n }) || []\n\n const userCollection = pluginOptions.userCollection\n\n return {\n slug: 'payload-mcp-api-keys',\n admin: {\n description:\n 'API keys control which collections, resources, tools, and prompts MCP clients can access',\n group: 'MCP',\n useAsTitle: 'label',\n },\n auth: {\n disableLocalStrategy: true,\n useAPIKey: true,\n },\n fields: [\n {\n name: 'user',\n type: 'relationship',\n admin: {\n description: 'The user that the API key is associated with.',\n },\n relationTo: userCollection as CollectionSlug,\n required: true,\n },\n {\n name: 'label',\n type: 'text',\n admin: {\n description: 'A useful label for the API key.',\n },\n },\n {\n name: 'description',\n type: 'text',\n admin: {\n description: 'The purpose of the API key.',\n },\n },\n\n ...createApiKeyFields({\n config: collections,\n configType: 'collection',\n }),\n\n ...createApiKeyFields({\n config: globals,\n configType: 'global',\n }),\n\n ...(customTools.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to tools',\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'payload-mcp-tool',\n type: 'group' as const,\n fields: customToolsFields,\n label: false as const,\n },\n ],\n label: 'Tools',\n },\n ]\n : []),\n\n ...(pluginOptions.mcp?.resources && pluginOptions.mcp?.resources.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to resources',\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'payload-mcp-resource',\n type: 'group' as const,\n fields: customResourceFields,\n label: false as const,\n },\n ],\n label: 'Resources',\n },\n ]\n : []),\n\n ...(pluginOptions.mcp?.prompts && pluginOptions.mcp?.prompts.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to prompts',\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'payload-mcp-prompt',\n type: 'group' as const,\n fields: customPromptFields,\n label: false as const,\n },\n ],\n label: 'Prompts',\n },\n ]\n : []),\n\n // Experimental Tools\n ...(process.env.NODE_ENV === 'development' &&\n (experimentalTools?.collections?.enabled ||\n experimentalTools?.jobs?.enabled ||\n experimentalTools?.config?.enabled ||\n experimentalTools?.auth?.enabled)\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n description: 'Manage client access to experimental tools',\n position: 'sidebar' as const,\n },\n fields: [\n ...(experimentalTools?.collections?.enabled\n ? [\n {\n name: 'collections',\n type: 'group' as const,\n fields: [\n {\n name: 'find',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to find and list Payload collections with optional content and document counts.',\n },\n defaultValue: false,\n },\n {\n name: 'create',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to create new Payload collections with specified fields and configuration.',\n },\n defaultValue: false,\n },\n {\n name: 'update',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to update existing Payload collections with new fields, modifications, or configuration changes.',\n },\n defaultValue: false,\n },\n {\n name: 'delete',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to delete Payload collections and optionally update the configuration.',\n },\n defaultValue: false,\n },\n ],\n },\n ]\n : []),\n ...(experimentalTools?.jobs?.enabled\n ? [\n {\n name: 'jobs',\n type: 'group' as const,\n fields: [\n {\n name: 'create',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to create new Payload jobs (tasks and workflows) with custom schemas and configuration.',\n },\n defaultValue: false,\n },\n {\n name: 'run',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to execute Payload jobs with custom input data and queue options.',\n },\n defaultValue: false,\n },\n {\n name: 'update',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to update existing Payload jobs with new schemas, configuration, or handler code.',\n },\n defaultValue: false,\n },\n ],\n },\n ]\n : []),\n ...(experimentalTools?.config?.enabled\n ? [\n {\n name: 'config',\n type: 'group' as const,\n fields: [\n {\n name: 'find',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to read and display a Payload configuration file.',\n },\n defaultValue: false,\n },\n {\n name: 'update',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to update a Payload configuration file with various modifications.',\n },\n defaultValue: false,\n },\n ],\n },\n ]\n : []),\n ...(experimentalTools?.auth?.enabled\n ? [\n {\n name: 'auth',\n type: 'group' as const,\n fields: [\n {\n name: 'auth',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to check authentication status for a user by setting custom headers. (e.g. {\"Authorization\": \"Bearer <token>\"})',\n },\n defaultValue: false,\n label: 'Check Auth Status',\n },\n {\n name: 'login',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to authenticate a user with email and password.',\n },\n defaultValue: false,\n label: 'User Login',\n },\n {\n name: 'verify',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to verify a user email with a verification token.',\n },\n defaultValue: false,\n label: 'Email Verification',\n },\n {\n name: 'resetPassword',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to reset a user password with a reset token.',\n },\n defaultValue: false,\n label: 'Reset Password',\n },\n {\n name: 'forgotPassword',\n type: 'checkbox' as const,\n admin: {\n description: 'Allow LLMs to send a password reset email to a user.',\n },\n defaultValue: false,\n label: 'Forgot Password',\n },\n {\n name: 'unlock',\n type: 'checkbox' as const,\n admin: {\n description:\n 'Allow LLMs to unlock a user account that has been locked due to failed login attempts.',\n },\n defaultValue: false,\n label: 'Unlock Account',\n },\n ],\n },\n ]\n : []),\n ],\n label: 'Experimental Tools',\n },\n ]\n : []),\n ],\n labels: {\n plural: 'API Keys',\n singular: 'API Key',\n },\n }\n}\n"],"names":["toCamelCase","createApiKeyFields","createAPIKeysCollection","collections","globals","customTools","experimentalTools","pluginOptions","customToolsFields","map","tool","camelCasedName","name","type","admin","description","defaultValue","label","customResourceFields","mcp","resources","resource","customPromptFields","prompts","prompt","userCollection","slug","group","useAsTitle","auth","disableLocalStrategy","useAPIKey","fields","relationTo","required","config","configType","length","position","process","env","NODE_ENV","enabled","jobs","labels","plural","singular"],"mappings":"AAIA,SAASA,WAAW,QAAQ,wBAAuB;AACnD,SAASC,kBAAkB,QAAQ,iCAAgC;AAEnE,OAAO,MAAMC,0BAA0B,CACrCC,aACAC,SACAC,cAA4D,EAAE,EAC9DC,oBAAiF,CAAC,CAAC,EACnFC;IAEA,MAAMC,oBAAoBH,YAAYI,GAAG,CAAC,CAACC;QACzC,MAAMC,iBAAiBX,YAAYU,KAAKE,IAAI;QAC5C,OAAO;YACLA,MAAMD;YACNE,MAAM;YACNC,OAAO;gBACLC,aAAaL,KAAKK,WAAW;YAC/B;YACAC,cAAc;YACdC,OAAON;QACT;IACF;IAEA,MAAMO,uBACJX,cAAcY,GAAG,EAAEC,WAAWX,IAAI,CAACY;QACjC,MAAMV,iBAAiBX,YAAYqB,SAAST,IAAI;QAChD,OAAO;YACLA,MAAMD;YACNE,MAAM;YACNC,OAAO;gBACLC,aAAaM,SAASN,WAAW;YACnC;YACAC,cAAc;YACdC,OAAON;QACT;IACF,MAAM,EAAE;IAEV,MAAMW,qBACJf,cAAcY,GAAG,EAAEI,SAASd,IAAI,CAACe;QAC/B,MAAMb,iBAAiBX,YAAYwB,OAAOZ,IAAI;QAC9C,OAAO;YACLA,MAAMD;YACNE,MAAM;YACNC,OAAO;gBACLC,aAAaS,OAAOT,WAAW;YACjC;YACAC,cAAc;YACdC,OAAON;QACT;IACF,MAAM,EAAE;IAEV,MAAMc,iBAAiBlB,cAAckB,cAAc;IAEnD,OAAO;QACLC,MAAM;QACNZ,OAAO;YACLC,aACE;YACFY,OAAO;YACPC,YAAY;QACd;QACAC,MAAM;YACJC,sBAAsB;YACtBC,WAAW;QACb;QACAC,QAAQ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4BACH;yBACD,GACD,EAAE;2BACFV,mBAAmBuB,MAAMa,UACzB;4BACE;gCACE9B,MAAM;gCACNC,MAAM;gCACNmB,QAAQ;oCACN;wCACEpB,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aAAa;wCACf;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEL,MAAM;wCACNC,MAAM;wCACNC,OAAO;4CACLC,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;iCACD;4BACH;yBACD,GACD,EAAE;qBACP;oBACDA,OAAO;gBACT;aACD,GACD,EAAE;SACP;QACD2B,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;CAEpB,CAAA"}
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaults = {\n userCollection: 'users',\n}\n"],"names":["defaults","userCollection"],"mappings":"AAAA,OAAO,MAAMA,WAAW;IACtBC,gBAAgB;AAClB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/endpoints/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAiD,MAAM,SAAS,CAAA;AAE5F,OAAO,KAAK,EAAqB,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAK3E,eAAO,MAAM,oBAAoB,kBAAmB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/endpoints/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAiD,MAAM,SAAS,CAAA;AAE5F,OAAO,KAAK,EAAqB,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAK3E,eAAO,MAAM,oBAAoB,kBAAmB,qBAAqB,mBA8DxE,CAAA"}
|
package/dist/endpoints/mcp.js
CHANGED
|
@@ -15,15 +15,10 @@ export const initializeMCPHandler = (pluginOptions)=>{
|
|
|
15
15
|
throw new UnauthorizedError();
|
|
16
16
|
}
|
|
17
17
|
const sha256APIKeyIndex = crypto.createHmac('sha256', payload.secret).update(apiKey || '').digest('hex');
|
|
18
|
-
const apiKeyConstraints = [
|
|
19
|
-
{
|
|
20
|
-
apiKeyIndex: {
|
|
21
|
-
equals: sha256APIKeyIndex
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
18
|
const where = {
|
|
26
|
-
|
|
19
|
+
apiKeyIndex: {
|
|
20
|
+
equals: sha256APIKeyIndex
|
|
21
|
+
}
|
|
27
22
|
};
|
|
28
23
|
const { docs } = await payload.find({
|
|
29
24
|
collection: 'payload-mcp-api-keys',
|
|
@@ -39,8 +34,7 @@ export const initializeMCPHandler = (pluginOptions)=>{
|
|
|
39
34
|
payload.logger.info('[payload-mcp] API Key is valid');
|
|
40
35
|
}
|
|
41
36
|
const user = docs[0]?.user;
|
|
42
|
-
|
|
43
|
-
user.collection = customUserCollection ?? 'users';
|
|
37
|
+
user.collection = pluginOptions.userCollection;
|
|
44
38
|
user._strategy = 'mcp-api-key';
|
|
45
39
|
return docs[0];
|
|
46
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/endpoints/mcp.ts"],"sourcesContent":["import crypto from 'crypto'\nimport { type PayloadHandler, type TypedUser, UnauthorizedError, type Where } from 'payload'\n\nimport type { MCPAccessSettings, PluginMCPServerConfig } from '../types.js'\n\nimport { createRequestFromPayloadRequest } from '../mcp/createRequest.js'\nimport { getMCPHandler } from '../mcp/getMcpHandler.js'\n\nexport const initializeMCPHandler = (pluginOptions: PluginMCPServerConfig) => {\n const mcpHandler: PayloadHandler = async (req) => {\n const { payload } = req\n const MCPOptions = pluginOptions.mcp || {}\n const MCPHandlerOptions = MCPOptions.handlerOptions || {}\n const useVerboseLogs = MCPHandlerOptions.verboseLogs ?? false\n\n req.payloadAPI = 'MCP' as const\n\n const getDefaultMcpAccessSettings = async (overrideApiKey?: null | string) => {\n const apiKey =\n (overrideApiKey ?? req.headers.get('Authorization')?.startsWith('Bearer '))\n ? req.headers.get('Authorization')?.replace('Bearer ', '').trim()\n : null\n\n if (apiKey === null) {\n throw new UnauthorizedError()\n }\n\n const sha256APIKeyIndex = crypto\n .createHmac('sha256', payload.secret)\n .update(apiKey || '')\n .digest('hex')\n\n const
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/mcp.ts"],"sourcesContent":["import crypto from 'crypto'\nimport { type PayloadHandler, type TypedUser, UnauthorizedError, type Where } from 'payload'\n\nimport type { MCPAccessSettings, PluginMCPServerConfig } from '../types.js'\n\nimport { createRequestFromPayloadRequest } from '../mcp/createRequest.js'\nimport { getMCPHandler } from '../mcp/getMcpHandler.js'\n\nexport const initializeMCPHandler = (pluginOptions: PluginMCPServerConfig) => {\n const mcpHandler: PayloadHandler = async (req) => {\n const { payload } = req\n const MCPOptions = pluginOptions.mcp || {}\n const MCPHandlerOptions = MCPOptions.handlerOptions || {}\n const useVerboseLogs = MCPHandlerOptions.verboseLogs ?? false\n\n req.payloadAPI = 'MCP' as const\n\n const getDefaultMcpAccessSettings = async (overrideApiKey?: null | string) => {\n const apiKey =\n (overrideApiKey ?? req.headers.get('Authorization')?.startsWith('Bearer '))\n ? req.headers.get('Authorization')?.replace('Bearer ', '').trim()\n : null\n\n if (apiKey === null) {\n throw new UnauthorizedError()\n }\n\n const sha256APIKeyIndex = crypto\n .createHmac('sha256', payload.secret)\n .update(apiKey || '')\n .digest('hex')\n\n const where: Where = {\n apiKeyIndex: {\n equals: sha256APIKeyIndex,\n },\n }\n\n const { docs } = await payload.find({\n collection: 'payload-mcp-api-keys',\n depth: 1,\n limit: 1,\n pagination: false,\n where,\n })\n\n if (docs.length === 0) {\n throw new UnauthorizedError()\n }\n\n if (useVerboseLogs) {\n payload.logger.info('[payload-mcp] API Key is valid')\n }\n\n const user = docs[0]?.user as TypedUser\n user.collection = pluginOptions.userCollection as string\n user._strategy = 'mcp-api-key' as const\n\n return docs[0] as unknown as MCPAccessSettings\n }\n\n const mcpAccessSettings = pluginOptions.overrideAuth\n ? await pluginOptions.overrideAuth(req, getDefaultMcpAccessSettings)\n : await getDefaultMcpAccessSettings()\n\n const handler = getMCPHandler(pluginOptions, mcpAccessSettings, req)\n const request = createRequestFromPayloadRequest(req)\n return await handler(request)\n }\n return mcpHandler\n}\n"],"names":["crypto","UnauthorizedError","createRequestFromPayloadRequest","getMCPHandler","initializeMCPHandler","pluginOptions","mcpHandler","req","payload","MCPOptions","mcp","MCPHandlerOptions","handlerOptions","useVerboseLogs","verboseLogs","payloadAPI","getDefaultMcpAccessSettings","overrideApiKey","apiKey","headers","get","startsWith","replace","trim","sha256APIKeyIndex","createHmac","secret","update","digest","where","apiKeyIndex","equals","docs","find","collection","depth","limit","pagination","length","logger","info","user","userCollection","_strategy","mcpAccessSettings","overrideAuth","handler","request"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,SAA8CC,iBAAiB,QAAoB,UAAS;AAI5F,SAASC,+BAA+B,QAAQ,0BAAyB;AACzE,SAASC,aAAa,QAAQ,0BAAyB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AAeuC,mBAAmBrC;QAChE,MAAMwC,UAAU7C,gCAAgCK;QAChD,OAAO,MAAMuC,QAAQC;IACvB;IACA,OAAOzC;AACT,EAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAK1E,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,cAAc;QAC7B,UAAU,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAA;KACjD;CACF;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAK1E,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,cAAc;QAC7B,UAAU,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAA;KACjD;CACF;AAID,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC;;;;;GAKG;AACH,eAAO,MAAM,SAAS,kBACJ,qBAAqB,cAC5B,MAAM,KAAG,MAmFjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAPIKeysCollection } from './collections/createApiKeysCollection.js';
|
|
2
2
|
import { initializeMCPHandler } from './endpoints/mcp.js';
|
|
3
|
+
import { defaults } from './defaults.js';
|
|
3
4
|
/**
|
|
4
5
|
* The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.
|
|
5
6
|
*
|
|
@@ -18,6 +19,8 @@ import { initializeMCPHandler } from './endpoints/mcp.js';
|
|
|
18
19
|
name: tool.name,
|
|
19
20
|
description: tool.description
|
|
20
21
|
})) || [];
|
|
22
|
+
// User Collection
|
|
23
|
+
pluginOptions.userCollection = pluginOptions.userCollection ?? config?.admin?.user ?? defaults.userCollection;
|
|
21
24
|
const experimentalTools = pluginOptions?.experimental?.tools || {};
|
|
22
25
|
/**
|
|
23
26
|
* API Keys
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport type { MCPAccessSettings, PluginMCPServerConfig } from './types.js'\n\nimport { createAPIKeysCollection } from './collections/createApiKeysCollection.js'\nimport { initializeMCPHandler } from './endpoints/mcp.js'\n\ndeclare module 'payload' {\n export interface PayloadRequest {\n payloadAPI: 'GraphQL' | 'local' | 'MCP' | 'REST'\n }\n}\n\nexport type { MCPAccessSettings }\n/**\n * The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.\n *\n * @param pluginOptions - The options for the MCP plugin.\n * @experimental This plugin is experimental and may change in the future.\n */\nexport const mcpPlugin =\n (pluginOptions: PluginMCPServerConfig) =>\n (config: Config): Config => {\n if (!config.collections) {\n config.collections = []\n }\n\n // Collections\n const collections = pluginOptions.collections || {}\n // Globals\n const globals = pluginOptions.globals || {}\n // Extract custom tools for the global config\n const customTools =\n pluginOptions.mcp?.tools?.map((tool) => ({\n name: tool.name,\n description: tool.description,\n })) || []\n\n const experimentalTools = pluginOptions?.experimental?.tools || {}\n\n /**\n * API Keys\n * --------\n * High resolution control over MCP capabilities is crucial when using Payload with LLMs.\n *\n * This API Keys collection has ways for admins to create API keys and allow or disallow the MCP capabilities.\n * This is useful when Admins want to allow or disallow the use of the MCP capabilities in real time.\n * For example:\n * - If a collection has all of its capabilities enabled, admins can allow or disallow the create, update, delete, and find capabilities on that collection.\n * - If a collection only has the find capability enabled, admins can only allow or disallow the find capability on that collection.\n * - If a global has all of its capabilities enabled, admins can allow or disallow the find and update capabilities on that global.\n * - If a custom tool has gone haywire, admins can disallow that tool.\n *\n */\n const apiKeyCollection = createAPIKeysCollection(\n collections,\n globals,\n customTools,\n experimentalTools,\n pluginOptions,\n )\n if (pluginOptions.overrideApiKeyCollection) {\n config.collections.push(pluginOptions.overrideApiKeyCollection(apiKeyCollection))\n } else {\n config.collections.push(apiKeyCollection)\n }\n\n /**\n * If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.\n * If your plugin heavily modifies the database schema, you may want to remove this property.\n */\n if (pluginOptions.disabled) {\n return config\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n /**\n * This is the primary MCP Server Endpoint.\n * Payload will automatically add the /api prefix to the path, so the full path is `/api/mcp`\n * NOTE: This is only transport method until we add full support for SSE which will be another endpoint at `/api/sse`\n */\n config.endpoints.push({\n handler: initializeMCPHandler(pluginOptions),\n method: 'post',\n path: '/mcp',\n })\n\n /**\n * The GET response is always: {\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Method not allowed.\"},\"id\":null} -- even with an API key\n * This is expected behavior and MCP clients should always use the POST endpoint.\n */\n config.endpoints.push({\n handler: initializeMCPHandler(pluginOptions),\n method: 'get',\n path: '/mcp',\n })\n\n return config\n }\n"],"names":["createAPIKeysCollection","initializeMCPHandler","mcpPlugin","pluginOptions","config","collections","globals","customTools","mcp","tools","map","tool","name","description","experimentalTools","experimental","apiKeyCollection","overrideApiKeyCollection","push","disabled","endpoints","handler","method","path"],"mappings":"AAIA,SAASA,uBAAuB,QAAQ,2CAA0C;AAClF,SAASC,oBAAoB,QAAQ,qBAAoB;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport type { MCPAccessSettings, PluginMCPServerConfig } from './types.js'\n\nimport { createAPIKeysCollection } from './collections/createApiKeysCollection.js'\nimport { initializeMCPHandler } from './endpoints/mcp.js'\n\ndeclare module 'payload' {\n export interface PayloadRequest {\n payloadAPI: 'GraphQL' | 'local' | 'MCP' | 'REST'\n }\n}\n\nimport { defaults } from './defaults.js'\n\nexport type { MCPAccessSettings }\n/**\n * The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.\n *\n * @param pluginOptions - The options for the MCP plugin.\n * @experimental This plugin is experimental and may change in the future.\n */\nexport const mcpPlugin =\n (pluginOptions: PluginMCPServerConfig) =>\n (config: Config): Config => {\n if (!config.collections) {\n config.collections = []\n }\n\n // Collections\n const collections = pluginOptions.collections || {}\n // Globals\n const globals = pluginOptions.globals || {}\n // Extract custom tools for the global config\n const customTools =\n pluginOptions.mcp?.tools?.map((tool) => ({\n name: tool.name,\n description: tool.description,\n })) || []\n\n // User Collection\n pluginOptions.userCollection =\n pluginOptions.userCollection ?? config?.admin?.user ?? defaults.userCollection\n\n const experimentalTools = pluginOptions?.experimental?.tools || {}\n\n /**\n * API Keys\n * --------\n * High resolution control over MCP capabilities is crucial when using Payload with LLMs.\n *\n * This API Keys collection has ways for admins to create API keys and allow or disallow the MCP capabilities.\n * This is useful when Admins want to allow or disallow the use of the MCP capabilities in real time.\n * For example:\n * - If a collection has all of its capabilities enabled, admins can allow or disallow the create, update, delete, and find capabilities on that collection.\n * - If a collection only has the find capability enabled, admins can only allow or disallow the find capability on that collection.\n * - If a global has all of its capabilities enabled, admins can allow or disallow the find and update capabilities on that global.\n * - If a custom tool has gone haywire, admins can disallow that tool.\n *\n */\n const apiKeyCollection = createAPIKeysCollection(\n collections,\n globals,\n customTools,\n experimentalTools,\n pluginOptions,\n )\n if (pluginOptions.overrideApiKeyCollection) {\n config.collections.push(pluginOptions.overrideApiKeyCollection(apiKeyCollection))\n } else {\n config.collections.push(apiKeyCollection)\n }\n\n /**\n * If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.\n * If your plugin heavily modifies the database schema, you may want to remove this property.\n */\n if (pluginOptions.disabled) {\n return config\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n /**\n * This is the primary MCP Server Endpoint.\n * Payload will automatically add the /api prefix to the path, so the full path is `/api/mcp`\n * NOTE: This is only transport method until we add full support for SSE which will be another endpoint at `/api/sse`\n */\n config.endpoints.push({\n handler: initializeMCPHandler(pluginOptions),\n method: 'post',\n path: '/mcp',\n })\n\n /**\n * The GET response is always: {\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Method not allowed.\"},\"id\":null} -- even with an API key\n * This is expected behavior and MCP clients should always use the POST endpoint.\n */\n config.endpoints.push({\n handler: initializeMCPHandler(pluginOptions),\n method: 'get',\n path: '/mcp',\n })\n\n return config\n }\n"],"names":["createAPIKeysCollection","initializeMCPHandler","defaults","mcpPlugin","pluginOptions","config","collections","globals","customTools","mcp","tools","map","tool","name","description","userCollection","admin","user","experimentalTools","experimental","apiKeyCollection","overrideApiKeyCollection","push","disabled","endpoints","handler","method","path"],"mappings":"AAIA,SAASA,uBAAuB,QAAQ,2CAA0C;AAClF,SAASC,oBAAoB,QAAQ,qBAAoB;AAQzD,SAASC,QAAQ,QAAQ,gBAAe;AAGxC;;;;;CAKC,GACD,OAAO,MAAMC,YACX,CAACC,gBACD,CAACC;QACC,IAAI,CAACA,OAAOC,WAAW,EAAE;YACvBD,OAAOC,WAAW,GAAG,EAAE;QACzB;QAEA,cAAc;QACd,MAAMA,cAAcF,cAAcE,WAAW,IAAI,CAAC;QAClD,UAAU;QACV,MAAMC,UAAUH,cAAcG,OAAO,IAAI,CAAC;QAC1C,6CAA6C;QAC7C,MAAMC,cACJJ,cAAcK,GAAG,EAAEC,OAAOC,IAAI,CAACC,OAAU,CAAA;gBACvCC,MAAMD,KAAKC,IAAI;gBACfC,aAAaF,KAAKE,WAAW;YAC/B,CAAA,MAAO,EAAE;QAEX,kBAAkB;QAClBV,cAAcW,cAAc,GAC1BX,cAAcW,cAAc,IAAIV,QAAQW,OAAOC,QAAQf,SAASa,cAAc;QAEhF,MAAMG,oBAAoBd,eAAee,cAAcT,SAAS,CAAC;QAEjE;;;;;;;;;;;;;KAaC,GACD,MAAMU,mBAAmBpB,wBACvBM,aACAC,SACAC,aACAU,mBACAd;QAEF,IAAIA,cAAciB,wBAAwB,EAAE;YAC1ChB,OAAOC,WAAW,CAACgB,IAAI,CAAClB,cAAciB,wBAAwB,CAACD;QACjE,OAAO;YACLf,OAAOC,WAAW,CAACgB,IAAI,CAACF;QAC1B;QAEA;;;KAGC,GACD,IAAIhB,cAAcmB,QAAQ,EAAE;YAC1B,OAAOlB;QACT;QAEA,IAAI,CAACA,OAAOmB,SAAS,EAAE;YACrBnB,OAAOmB,SAAS,GAAG,EAAE;QACvB;QAEA;;;;KAIC,GACDnB,OAAOmB,SAAS,CAACF,IAAI,CAAC;YACpBG,SAASxB,qBAAqBG;YAC9BsB,QAAQ;YACRC,MAAM;QACR;QAEA;;;KAGC,GACDtB,OAAOmB,SAAS,CAACF,IAAI,CAAC;YACpBG,SAASxB,qBAAqBG;YAC9BsB,QAAQ;YACRC,MAAM;QACR;QAEA,OAAOtB;IACT,EAAC"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAE/E,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CACnB,MAAM,CACJ,cAAc,EACd;QACE;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB;;WAEG;QACH,OAAO,EACH;YACE,MAAM,CAAC,EAAE,OAAO,CAAA;YAChB,MAAM,CA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ED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n GlobalSlug,\n PayloadRequest,\n TypedUser,\n} from 'payload'\nimport type { z } from 'zod'\n\nimport { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport type PluginMCPServerConfig = {\n /**\n * Set the collections that should be available as resources via MCP.\n */\n collections?: Partial<\n Record<\n CollectionSlug,\n {\n /**\n * Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.\n */\n enabled:\n | {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * Disable the MCP plugin.\n */\n disabled?: boolean\n /**\n * Experimental features\n * **These features are for experimental purposes -- They are Disabled in Production by Default**\n */\n experimental?: {\n /**\n * These are MCP tools that can be used by a client to modify Payload.\n */\n tools: {\n /**\n * **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.\n */\n auth?: {\n /**\n * Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Collection MCP tools allow for the creation, modification, and deletion of Payload collections. This is for developing ideas that help Developers with collection tasks.\n */\n collections?: {\n /**\n * Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.\n */\n collectionsDirPath: string\n /**\n * Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.\n */\n config?: {\n /**\n * Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.\n */\n configFilePath: string\n /**\n * Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.\n */\n jobs?: {\n /**\n * Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.\n * @default false\n */\n enabled: boolean\n /**\n * Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.\n */\n jobsDirPath: string\n }\n }\n }\n /**\n * Set the globals that should be available as resources via MCP.\n * Globals are singleton configuration objects (e.g., site settings, navigation).\n * Note: Globals only support find and update operations.\n */\n globals?: Partial<\n Record<\n GlobalSlug,\n {\n /**\n * Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.\n * Note: Globals only support find and update operations as they are singletons.\n */\n enabled:\n | {\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * MCP Server options.\n */\n mcp?: {\n handlerOptions?: MCPHandlerOptions\n /**\n * Add custom MCP Prompts.\n */\n prompts?: {\n /**\n * Set the args schema of the prompt. This is the args schema that will be passed to the prompt. This is used by MCP clients to determine the arguments that will be passed to the prompt.\n */\n argsSchema: z.ZodRawShape\n /**\n * Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.\n */\n description: string\n /**\n * Set the handler of the prompt. This is the function that will be called when the prompt is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }\n | Promise<{\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }>\n /**\n * Set the function name of the prompt.\n */\n name: string\n /**\n * Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.\n */\n title: string\n }[]\n\n /**\n * Add custom MCP Resource.\n */\n resources?: {\n /**\n * Set the description of the resource. This is used by MCP clients to determine when to use the resource.\n * example: 'Data is a resource that contains special data.'\n */\n description: string\n /**\n * Set the handler of the resource. This is the function that will be called when the resource is used.\n * The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).\n */\n handler: (...args: any[]) =>\n | {\n contents: Array<{\n text: string\n uri: string\n }>\n }\n | Promise<{\n contents: Array<{\n text: string\n uri: string\n }>\n }>\n /**\n * Set the mime type of the resource.\n * example: 'text/plain'\n */\n mimeType: string\n /**\n * Set the function name of the resource.\n * example: 'data'\n */\n name: string\n /**\n * Set the title of the resource. LLMs will interperate the title to determine when to use the resource.\n * example: 'Data'\n */\n title: string\n /**\n * Set the uri of the resource.\n * example: 'data://app'\n */\n uri: ResourceTemplate | string\n }[]\n serverOptions?: MCPServerOptions\n /**\n * Add custom MCP Tools.\n */\n tools?: {\n /**\n * Set the description of the tool. This is used by MCP clients to determine when to use the tool.\n */\n description: string\n /**\n * Set the handler of the tool. This is the function that will be called when the tool is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }\n | Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }>\n /**\n * Set the name of the tool. This is the name that will be used to identify the tool. LLMs will interperate the name to determine when to use the tool.\n */\n name: string\n /**\n * Set the parameters of the tool. This is the parameters that will be passed to the tool.\n */\n parameters: z.ZodRawShape\n }[]\n }\n\n /**\n * Override the API key collection.\n * This allows you to add fields to the API key collection or modify the collection in any way you want.\n * @param collection - The API key collection.\n * @returns The modified API key collection.\n */\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n\n /**\n * Override the authentication method.\n * This allows you to use a custom authentication method instead of the default API key authentication.\n * @param req - The request object.\n * @returns The MCP access settings.\n */\n overrideAuth?: (\n req: PayloadRequest,\n getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,\n ) => MCPAccessSettings | Promise<MCPAccessSettings>\n\n /**\n * Set the users collection that API keys should be associated with.\n */\n userCollection?: CollectionConfig | string\n}\n\n/**\n * MCP Handler options.\n */\nexport type MCPHandlerOptions = {\n /**\n * Set the base path of the MCP handler. This is the path that will be used to access the MCP handler.\n * @default /api\n */\n basePath?: string\n /**\n * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.\n * @default 60\n */\n maxDuration?: number\n /**\n * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.\n * @default process.env.REDIS_URL\n * INFO: Disabled until developer clarity is reached for server side streaming and we have an auth pattern for all SSE patterns\n */\n // redisUrl?: string\n /**\n * Set verbose logging.\n * @default false\n */\n verboseLogs?: boolean\n}\n\n/**\n * MCP Server options.\n */\nexport type MCPServerOptions = {\n /**\n * Set the server info of the MCP server.\n */\n serverInfo?: {\n /**\n * Set the name of the MCP server.\n * @default 'Payload MCP Server'\n */\n name: string\n /**\n * Set the version of the MCP server.\n * @default '1.0.0'\n */\n version: string\n }\n}\n\nexport type MCPAccessSettings = {\n auth?: {\n auth?: boolean\n forgotPassword?: boolean\n login?: boolean\n resetPassword?: boolean\n unlock?: boolean\n verify?: boolean\n }\n collections?: {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n config?: {\n find?: boolean\n update?: boolean\n }\n custom?: Record<string, boolean>\n globals?: {\n find?: boolean\n update?: boolean\n }\n jobs?: {\n create?: boolean\n run?: boolean\n update?: boolean\n }\n 'payload-mcp-prompt'?: Record<string, boolean>\n 'payload-mcp-resource'?: Record<string, boolean>\n 'payload-mcp-tool'?: Record<string, boolean>\n user: TypedUser\n} & Record<string, unknown>\n\nexport type EntityConfig = PluginMCPServerConfig['collections'] | PluginMCPServerConfig['globals']\n\nexport type FieldDefinition = {\n description?: string\n name: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type: string\n}\n\nexport type FieldModification = {\n changes: {\n description?: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type?: string\n }\n fieldName: string\n}\n\nexport type CollectionConfigUpdates = {\n access?: {\n create?: string\n delete?: string\n read?: string\n update?: string\n }\n description?: string\n slug?: string\n timestamps?: boolean\n versioning?: boolean\n}\n\nexport type AdminConfig = {\n avatar?: string\n css?: string\n dateFormat?: string\n inactivityRoute?: string\n livePreview?: {\n breakpoints?: Array<{\n height: number\n label: string\n name: string\n width: number\n }>\n }\n logoutRoute?: string\n meta?: {\n favicon?: string\n ogImage?: string\n titleSuffix?: string\n }\n user?: string\n}\n\nexport type DatabaseConfig = {\n connectOptions?: string\n type?: 'mongodb' | 'postgres'\n url?: string\n}\n\nexport type PluginUpdates = {\n add?: string[]\n remove?: string[]\n}\n\nexport type GeneralConfig = {\n cookiePrefix?: string\n cors?: string\n csrf?: string\n graphQL?: {\n disable?: boolean\n schemaOutputFile?: string\n }\n rateLimit?: {\n max?: number\n skip?: string\n window?: number\n }\n secret?: string\n serverURL?: string\n typescript?: {\n declare?: boolean\n outputFile?: string\n }\n}\n\nexport interface SchemaField {\n description?: string\n name: string\n options?: string[]\n required?: boolean\n type: string\n}\n\nexport interface TaskSequenceItem {\n description?: string\n retries?: number\n taskId: string\n taskSlug: string\n timeout?: number\n}\n\nexport interface JobConfigUpdate {\n description?: string\n queue?: string\n retries?: number\n timeout?: number\n}\n"],"names":[],"mappings":"AA2gBA,WAKC"}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n GlobalSlug,\n PayloadRequest,\n TypedUser,\n} from 'payload'\nimport type { z } from 'zod'\n\nimport { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport type PluginMCPServerConfig = {\n /**\n * Set the collections that should be available as resources via MCP.\n */\n collections?: Partial<\n Record<\n CollectionSlug,\n {\n /**\n * Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.\n */\n enabled:\n | {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * Disable the MCP plugin.\n */\n disabled?: boolean\n /**\n * Experimental features\n * **These features are for experimental purposes -- They are Disabled in Production by Default**\n */\n experimental?: {\n /**\n * These are MCP tools that can be used by a client to modify Payload.\n */\n tools: {\n /**\n * **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.\n */\n auth?: {\n /**\n * Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Collection MCP tools allow for the creation, modification, and deletion of Payload collections. This is for developing ideas that help Developers with collection tasks.\n */\n collections?: {\n /**\n * Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.\n */\n collectionsDirPath: string\n /**\n * Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.\n */\n config?: {\n /**\n * Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.\n */\n configFilePath: string\n /**\n * Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.\n */\n jobs?: {\n /**\n * Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.\n * @default false\n */\n enabled: boolean\n /**\n * Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.\n */\n jobsDirPath: string\n }\n }\n }\n /**\n * Set the globals that should be available as resources via MCP.\n * Globals are singleton configuration objects (e.g., site settings, navigation).\n * Note: Globals only support find and update operations.\n */\n globals?: Partial<\n Record<\n GlobalSlug,\n {\n /**\n * Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.\n * Note: Globals only support find and update operations as they are singletons.\n */\n enabled:\n | {\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * MCP Server options.\n */\n mcp?: {\n handlerOptions?: MCPHandlerOptions\n /**\n * Add custom MCP Prompts.\n */\n prompts?: {\n /**\n * Set the args schema of the prompt. This is the args schema that will be passed to the prompt. This is used by MCP clients to determine the arguments that will be passed to the prompt.\n */\n argsSchema: z.ZodRawShape\n /**\n * Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.\n */\n description: string\n /**\n * Set the handler of the prompt. This is the function that will be called when the prompt is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }\n | Promise<{\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }>\n /**\n * Set the function name of the prompt.\n */\n name: string\n /**\n * Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.\n */\n title: string\n }[]\n\n /**\n * Add custom MCP Resource.\n */\n resources?: {\n /**\n * Set the description of the resource. This is used by MCP clients to determine when to use the resource.\n * example: 'Data is a resource that contains special data.'\n */\n description: string\n /**\n * Set the handler of the resource. This is the function that will be called when the resource is used.\n * The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).\n */\n handler: (...args: any[]) =>\n | {\n contents: Array<{\n text: string\n uri: string\n }>\n }\n | Promise<{\n contents: Array<{\n text: string\n uri: string\n }>\n }>\n /**\n * Set the mime type of the resource.\n * example: 'text/plain'\n */\n mimeType: string\n /**\n * Set the function name of the resource.\n * example: 'data'\n */\n name: string\n /**\n * Set the title of the resource. LLMs will interperate the title to determine when to use the resource.\n * example: 'Data'\n */\n title: string\n /**\n * Set the uri of the resource.\n * example: 'data://app'\n */\n uri: ResourceTemplate | string\n }[]\n serverOptions?: MCPServerOptions\n /**\n * Add custom MCP Tools.\n */\n tools?: {\n /**\n * Set the description of the tool. This is used by MCP clients to determine when to use the tool.\n */\n description: string\n /**\n * Set the handler of the tool. This is the function that will be called when the tool is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }\n | Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }>\n /**\n * Set the name of the tool. This is the name that will be used to identify the tool. LLMs will interperate the name to determine when to use the tool.\n */\n name: string\n /**\n * Set the parameters of the tool. This is the parameters that will be passed to the tool.\n */\n parameters: z.ZodRawShape\n }[]\n }\n\n /**\n * Override the API key collection.\n * This allows you to add fields to the API key collection or modify the collection in any way you want.\n * @param collection - The API key collection.\n * @returns The modified API key collection.\n */\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n\n /**\n * Override the authentication method.\n * This allows you to use a custom authentication method instead of the default API key authentication.\n * @param req - The request object.\n * @returns The MCP access settings.\n */\n overrideAuth?: (\n req: PayloadRequest,\n getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,\n ) => MCPAccessSettings | Promise<MCPAccessSettings>\n\n /**\n * Set the users collection that API keys should be associated with.\n */\n userCollection?: CollectionSlug\n}\n\n/**\n * MCP Handler options.\n */\nexport type MCPHandlerOptions = {\n /**\n * Set the base path of the MCP handler. This is the path that will be used to access the MCP handler.\n * @default /api\n */\n basePath?: string\n /**\n * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.\n * @default 60\n */\n maxDuration?: number\n /**\n * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.\n * @default process.env.REDIS_URL\n * INFO: Disabled until developer clarity is reached for server side streaming and we have an auth pattern for all SSE patterns\n */\n // redisUrl?: string\n /**\n * Set verbose logging.\n * @default false\n */\n verboseLogs?: boolean\n}\n\n/**\n * MCP Server options.\n */\nexport type MCPServerOptions = {\n /**\n * Set the server info of the MCP server.\n */\n serverInfo?: {\n /**\n * Set the name of the MCP server.\n * @default 'Payload MCP Server'\n */\n name: string\n /**\n * Set the version of the MCP server.\n * @default '1.0.0'\n */\n version: string\n }\n}\n\nexport type MCPAccessSettings = {\n auth?: {\n auth?: boolean\n forgotPassword?: boolean\n login?: boolean\n resetPassword?: boolean\n unlock?: boolean\n verify?: boolean\n }\n collections?: {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n config?: {\n find?: boolean\n update?: boolean\n }\n custom?: Record<string, boolean>\n globals?: {\n find?: boolean\n update?: boolean\n }\n jobs?: {\n create?: boolean\n run?: boolean\n update?: boolean\n }\n 'payload-mcp-prompt'?: Record<string, boolean>\n 'payload-mcp-resource'?: Record<string, boolean>\n 'payload-mcp-tool'?: Record<string, boolean>\n user: TypedUser\n} & Record<string, unknown>\n\nexport type EntityConfig = PluginMCPServerConfig['collections'] | PluginMCPServerConfig['globals']\n\nexport type FieldDefinition = {\n description?: string\n name: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type: string\n}\n\nexport type FieldModification = {\n changes: {\n description?: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type?: string\n }\n fieldName: string\n}\n\nexport type CollectionConfigUpdates = {\n access?: {\n create?: string\n delete?: string\n read?: string\n update?: string\n }\n description?: string\n slug?: string\n timestamps?: boolean\n versioning?: boolean\n}\n\nexport type AdminConfig = {\n avatar?: string\n css?: string\n dateFormat?: string\n inactivityRoute?: string\n livePreview?: {\n breakpoints?: Array<{\n height: number\n label: string\n name: string\n width: number\n }>\n }\n logoutRoute?: string\n meta?: {\n favicon?: string\n ogImage?: string\n titleSuffix?: string\n }\n user?: string\n}\n\nexport type DatabaseConfig = {\n connectOptions?: string\n type?: 'mongodb' | 'postgres'\n url?: string\n}\n\nexport type PluginUpdates = {\n add?: string[]\n remove?: string[]\n}\n\nexport type GeneralConfig = {\n cookiePrefix?: string\n cors?: string\n csrf?: string\n graphQL?: {\n disable?: boolean\n schemaOutputFile?: string\n }\n rateLimit?: {\n max?: number\n skip?: string\n window?: number\n }\n secret?: string\n serverURL?: string\n typescript?: {\n declare?: boolean\n outputFile?: string\n }\n}\n\nexport interface SchemaField {\n description?: string\n name: string\n options?: string[]\n required?: boolean\n type: string\n}\n\nexport interface TaskSequenceItem {\n description?: string\n retries?: number\n taskId: string\n taskSlug: string\n timeout?: number\n}\n\nexport interface JobConfigUpdate {\n description?: string\n queue?: string\n retries?: number\n timeout?: number\n}\n"],"names":[],"mappings":"AA2gBA,WAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-mcp",
|
|
3
|
-
"version": "3.71.
|
|
3
|
+
"version": "3.71.1",
|
|
4
4
|
"description": "MCP (Model Context Protocol) capabilities with Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@payloadcms/eslint-config": "3.28.0",
|
|
48
|
-
"payload": "3.71.
|
|
48
|
+
"payload": "3.71.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"payload": "3.71.
|
|
51
|
+
"payload": "3.71.1"
|
|
52
52
|
},
|
|
53
53
|
"homepage:": "https://payloadcms.com",
|
|
54
54
|
"scripts": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload'
|
|
1
|
+
import type { CollectionConfig, CollectionSlug } from 'payload'
|
|
2
2
|
|
|
3
3
|
import type { PluginMCPServerConfig } from '../types.js'
|
|
4
4
|
|
|
@@ -54,10 +54,6 @@ export const createAPIKeysCollection = (
|
|
|
54
54
|
}) || []
|
|
55
55
|
|
|
56
56
|
const userCollection = pluginOptions.userCollection
|
|
57
|
-
? typeof pluginOptions.userCollection === 'string'
|
|
58
|
-
? pluginOptions.userCollection
|
|
59
|
-
: pluginOptions.userCollection.slug
|
|
60
|
-
: 'users'
|
|
61
57
|
|
|
62
58
|
return {
|
|
63
59
|
slug: 'payload-mcp-api-keys',
|
|
@@ -78,7 +74,7 @@ export const createAPIKeysCollection = (
|
|
|
78
74
|
admin: {
|
|
79
75
|
description: 'The user that the API key is associated with.',
|
|
80
76
|
},
|
|
81
|
-
relationTo: userCollection,
|
|
77
|
+
relationTo: userCollection as CollectionSlug,
|
|
82
78
|
required: true,
|
|
83
79
|
},
|
|
84
80
|
{
|
package/src/defaults.ts
ADDED
package/src/endpoints/mcp.ts
CHANGED
|
@@ -30,16 +30,10 @@ export const initializeMCPHandler = (pluginOptions: PluginMCPServerConfig) => {
|
|
|
30
30
|
.update(apiKey || '')
|
|
31
31
|
.digest('hex')
|
|
32
32
|
|
|
33
|
-
const apiKeyConstraints = [
|
|
34
|
-
{
|
|
35
|
-
apiKeyIndex: {
|
|
36
|
-
equals: sha256APIKeyIndex,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
]
|
|
40
|
-
|
|
41
33
|
const where: Where = {
|
|
42
|
-
|
|
34
|
+
apiKeyIndex: {
|
|
35
|
+
equals: sha256APIKeyIndex,
|
|
36
|
+
},
|
|
43
37
|
}
|
|
44
38
|
|
|
45
39
|
const { docs } = await payload.find({
|
|
@@ -59,11 +53,7 @@ export const initializeMCPHandler = (pluginOptions: PluginMCPServerConfig) => {
|
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
const user = docs[0]?.user as TypedUser
|
|
62
|
-
|
|
63
|
-
typeof pluginOptions.userCollection === 'string'
|
|
64
|
-
? pluginOptions.userCollection
|
|
65
|
-
: pluginOptions.userCollection?.slug
|
|
66
|
-
user.collection = customUserCollection ?? 'users'
|
|
56
|
+
user.collection = pluginOptions.userCollection as string
|
|
67
57
|
user._strategy = 'mcp-api-key' as const
|
|
68
58
|
|
|
69
59
|
return docs[0] as unknown as MCPAccessSettings
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ declare module 'payload' {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
import { defaults } from './defaults.js'
|
|
15
|
+
|
|
14
16
|
export type { MCPAccessSettings }
|
|
15
17
|
/**
|
|
16
18
|
* The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.
|
|
@@ -36,6 +38,10 @@ export const mcpPlugin =
|
|
|
36
38
|
description: tool.description,
|
|
37
39
|
})) || []
|
|
38
40
|
|
|
41
|
+
// User Collection
|
|
42
|
+
pluginOptions.userCollection =
|
|
43
|
+
pluginOptions.userCollection ?? config?.admin?.user ?? defaults.userCollection
|
|
44
|
+
|
|
39
45
|
const experimentalTools = pluginOptions?.experimental?.tools || {}
|
|
40
46
|
|
|
41
47
|
/**
|
package/src/types.ts
CHANGED