@payloadcms/plugin-mcp 0.0.1-alpha.0
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 +22 -0
- package/README.md +7 -0
- package/dist/collections/createApiKeysCollection.d.ts +7 -0
- package/dist/collections/createApiKeysCollection.d.ts.map +1 -0
- package/dist/collections/createApiKeysCollection.js +315 -0
- package/dist/collections/createApiKeysCollection.js.map +1 -0
- package/dist/endpoints/mcp.d.ts +4 -0
- package/dist/endpoints/mcp.d.ts.map +1 -0
- package/dist/endpoints/mcp.js +44 -0
- package/dist/endpoints/mcp.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/createRequest.d.ts +3 -0
- package/dist/mcp/createRequest.d.ts.map +1 -0
- package/dist/mcp/createRequest.js +14 -0
- package/dist/mcp/createRequest.js.map +1 -0
- package/dist/mcp/getMcpHandler.d.ts +4 -0
- package/dist/mcp/getMcpHandler.d.ts.map +1 -0
- package/dist/mcp/getMcpHandler.js +179 -0
- package/dist/mcp/getMcpHandler.js.map +1 -0
- package/dist/mcp/helpers/config.d.ts +30 -0
- package/dist/mcp/helpers/config.d.ts.map +1 -0
- package/dist/mcp/helpers/config.js +217 -0
- package/dist/mcp/helpers/config.js.map +1 -0
- package/dist/mcp/helpers/conversion.d.ts +2 -0
- package/dist/mcp/helpers/conversion.d.ts.map +1 -0
- package/dist/mcp/helpers/conversion.js +5 -0
- package/dist/mcp/helpers/conversion.js.map +1 -0
- package/dist/mcp/helpers/fields.d.ts +38 -0
- package/dist/mcp/helpers/fields.d.ts.map +1 -0
- package/dist/mcp/helpers/fields.js +96 -0
- package/dist/mcp/helpers/fields.js.map +1 -0
- package/dist/mcp/helpers/fileValidation.d.ts +69 -0
- package/dist/mcp/helpers/fileValidation.d.ts.map +1 -0
- package/dist/mcp/helpers/fileValidation.js +305 -0
- package/dist/mcp/helpers/fileValidation.js.map +1 -0
- package/dist/mcp/helpers/validation.d.ts +9 -0
- package/dist/mcp/helpers/validation.d.ts.map +1 -0
- package/dist/mcp/helpers/validation.js +22 -0
- package/dist/mcp/helpers/validation.js.map +1 -0
- package/dist/mcp/registerTool.d.ts +6 -0
- package/dist/mcp/registerTool.d.ts.map +1 -0
- package/dist/mcp/registerTool.js +18 -0
- package/dist/mcp/registerTool.js.map +1 -0
- package/dist/mcp/tools/auth/auth.d.ts +4 -0
- package/dist/mcp/tools/auth/auth.d.ts.map +1 -0
- package/dist/mcp/tools/auth/auth.js +54 -0
- package/dist/mcp/tools/auth/auth.js.map +1 -0
- package/dist/mcp/tools/auth/forgotPassword.d.ts +4 -0
- package/dist/mcp/tools/auth/forgotPassword.d.ts.map +1 -0
- package/dist/mcp/tools/auth/forgotPassword.js +45 -0
- package/dist/mcp/tools/auth/forgotPassword.js.map +1 -0
- package/dist/mcp/tools/auth/login.d.ts +4 -0
- package/dist/mcp/tools/auth/login.d.ts.map +1 -0
- package/dist/mcp/tools/auth/login.js +48 -0
- package/dist/mcp/tools/auth/login.js.map +1 -0
- package/dist/mcp/tools/auth/resetPassword.d.ts +4 -0
- package/dist/mcp/tools/auth/resetPassword.d.ts.map +1 -0
- package/dist/mcp/tools/auth/resetPassword.js +46 -0
- package/dist/mcp/tools/auth/resetPassword.js.map +1 -0
- package/dist/mcp/tools/auth/unlock.d.ts +4 -0
- package/dist/mcp/tools/auth/unlock.d.ts.map +1 -0
- package/dist/mcp/tools/auth/unlock.js +45 -0
- package/dist/mcp/tools/auth/unlock.js.map +1 -0
- package/dist/mcp/tools/auth/verify.d.ts +4 -0
- package/dist/mcp/tools/auth/verify.d.ts.map +1 -0
- package/dist/mcp/tools/auth/verify.js +42 -0
- package/dist/mcp/tools/auth/verify.js.map +1 -0
- package/dist/mcp/tools/collection/create.d.ts +10 -0
- package/dist/mcp/tools/collection/create.d.ts.map +1 -0
- package/dist/mcp/tools/collection/create.js +159 -0
- package/dist/mcp/tools/collection/create.js.map +1 -0
- package/dist/mcp/tools/collection/delete.d.ts +10 -0
- package/dist/mcp/tools/collection/delete.d.ts.map +1 -0
- package/dist/mcp/tools/collection/delete.js +162 -0
- package/dist/mcp/tools/collection/delete.js.map +1 -0
- package/dist/mcp/tools/collection/find.d.ts +10 -0
- package/dist/mcp/tools/collection/find.d.ts.map +1 -0
- package/dist/mcp/tools/collection/find.js +162 -0
- package/dist/mcp/tools/collection/find.js.map +1 -0
- package/dist/mcp/tools/collection/update.d.ts +10 -0
- package/dist/mcp/tools/collection/update.d.ts.map +1 -0
- package/dist/mcp/tools/collection/update.js +206 -0
- package/dist/mcp/tools/collection/update.js.map +1 -0
- package/dist/mcp/tools/config/find.d.ts +10 -0
- package/dist/mcp/tools/config/find.d.ts.map +1 -0
- package/dist/mcp/tools/config/find.js +94 -0
- package/dist/mcp/tools/config/find.js.map +1 -0
- package/dist/mcp/tools/config/update.d.ts +10 -0
- package/dist/mcp/tools/config/update.d.ts.map +1 -0
- package/dist/mcp/tools/config/update.js +212 -0
- package/dist/mcp/tools/config/update.js.map +1 -0
- package/dist/mcp/tools/job/create.d.ts +10 -0
- package/dist/mcp/tools/job/create.d.ts.map +1 -0
- package/dist/mcp/tools/job/create.js +293 -0
- package/dist/mcp/tools/job/create.js.map +1 -0
- package/dist/mcp/tools/job/run.d.ts +10 -0
- package/dist/mcp/tools/job/run.d.ts.map +1 -0
- package/dist/mcp/tools/job/run.js +147 -0
- package/dist/mcp/tools/job/run.js.map +1 -0
- package/dist/mcp/tools/job/update.d.ts +11 -0
- package/dist/mcp/tools/job/update.d.ts.map +1 -0
- package/dist/mcp/tools/job/update.js +211 -0
- package/dist/mcp/tools/job/update.js.map +1 -0
- package/dist/mcp/tools/resource/create.d.ts +6 -0
- package/dist/mcp/tools/resource/create.d.ts.map +1 -0
- package/dist/mcp/tools/resource/create.js +75 -0
- package/dist/mcp/tools/resource/create.js.map +1 -0
- package/dist/mcp/tools/resource/delete.d.ts +5 -0
- package/dist/mcp/tools/resource/delete.d.ts.map +1 -0
- package/dist/mcp/tools/resource/delete.js +140 -0
- package/dist/mcp/tools/resource/delete.js.map +1 -0
- package/dist/mcp/tools/resource/find.d.ts +5 -0
- package/dist/mcp/tools/resource/find.d.ts.map +1 -0
- package/dist/mcp/tools/resource/find.js +119 -0
- package/dist/mcp/tools/resource/find.js.map +1 -0
- package/dist/mcp/tools/resource/update.d.ts +6 -0
- package/dist/mcp/tools/resource/update.d.ts.map +1 -0
- package/dist/mcp/tools/resource/update.js +201 -0
- package/dist/mcp/tools/resource/update.js.map +1 -0
- package/dist/mcp/tools/schemas.d.ts +374 -0
- package/dist/mcp/tools/schemas.d.ts.map +1 -0
- package/dist/mcp/tools/schemas.js +201 -0
- package/dist/mcp/tools/schemas.js.map +1 -0
- package/dist/types.d.ts +379 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/camelCase.d.ts +9 -0
- package/dist/utils/camelCase.d.ts.map +1 -0
- package/dist/utils/camelCase.js +11 -0
- package/dist/utils/camelCase.js.map +1 -0
- package/dist/utils/convertCollectionSchemaToZod.d.ts +3 -0
- package/dist/utils/convertCollectionSchemaToZod.d.ts.map +1 -0
- package/dist/utils/convertCollectionSchemaToZod.js +30 -0
- package/dist/utils/convertCollectionSchemaToZod.js.map +1 -0
- package/package.json +64 -0
- package/src/collections/createApiKeysCollection.ts +393 -0
- package/src/endpoints/mcp.ts +60 -0
- package/src/index.ts +86 -0
- package/src/mcp/createRequest.ts +13 -0
- package/src/mcp/getMcpHandler.ts +433 -0
- package/src/mcp/helpers/config.ts +326 -0
- package/src/mcp/helpers/conversion.ts +3 -0
- package/src/mcp/helpers/fields.ts +158 -0
- package/src/mcp/helpers/fileValidation.ts +417 -0
- package/src/mcp/helpers/validation.ts +32 -0
- package/src/mcp/registerTool.ts +22 -0
- package/src/mcp/tools/auth/auth.ts +69 -0
- package/src/mcp/tools/auth/forgotPassword.ts +68 -0
- package/src/mcp/tools/auth/login.ts +70 -0
- package/src/mcp/tools/auth/resetPassword.ts +59 -0
- package/src/mcp/tools/auth/unlock.ts +62 -0
- package/src/mcp/tools/auth/verify.ts +55 -0
- package/src/mcp/tools/collection/create.ts +236 -0
- package/src/mcp/tools/collection/delete.ts +227 -0
- package/src/mcp/tools/collection/find.ts +222 -0
- package/src/mcp/tools/collection/update.ts +288 -0
- package/src/mcp/tools/config/find.ts +126 -0
- package/src/mcp/tools/config/update.ts +282 -0
- package/src/mcp/tools/job/create.ts +420 -0
- package/src/mcp/tools/job/run.ts +189 -0
- package/src/mcp/tools/job/update.ts +319 -0
- package/src/mcp/tools/resource/create.ts +121 -0
- package/src/mcp/tools/resource/delete.ts +210 -0
- package/src/mcp/tools/resource/find.ts +194 -0
- package/src/mcp/tools/resource/update.ts +314 -0
- package/src/mcp/tools/schemas.ts +373 -0
- package/src/types.ts +405 -0
- package/src/utils/camelCase.ts +12 -0
- package/src/utils/convertCollectionSchemaToZod.ts +35 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Payload MCP Plugin
|
|
2
|
+
|
|
3
|
+
A plugin for [Payload](https://github.com/payloadcms/payload). This plugin adds [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro) capabilities.
|
|
4
|
+
|
|
5
|
+
- [Source code](https://github.com/payloadcms/payload/tree/main/packages/plugin-mcp)
|
|
6
|
+
- [Documentation](https://payloadcms.com/docs/plugins/mcp)
|
|
7
|
+
- [Documentation source](https://github.com/payloadcms/payload/tree/main/docs/plugins/mcp.mdx)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CollectionConfig } from 'payload';
|
|
2
|
+
import type { PluginMCPServerConfig } from '../types.js';
|
|
3
|
+
export declare const createAPIKeysCollection: (collections: PluginMCPServerConfig["collections"], customTools?: Array<{
|
|
4
|
+
description: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}>, experimentalTools?: NonNullable<PluginMCPServerConfig["experimental"]>["tools"]) => CollectionConfig;
|
|
7
|
+
//# sourceMappingURL=createApiKeysCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createApiKeysCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createApiKeysCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAgHxD,eAAO,MAAM,uBAAuB,gBACrB,qBAAqB,CAAC,aAAa,CAAC,gBACpC,KAAK,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,sBACtC,WAAW,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,KAC7E,gBAkRF,CAAA"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { toCamelCase } from '../utils/camelCase.js';
|
|
2
|
+
const addEnabledCollectionTools = (collections)=>{
|
|
3
|
+
const enabledCollectionSlugs = Object.keys(collections || {}).filter((collection)=>{
|
|
4
|
+
const fullyEnabled = typeof collections?.[collection]?.enabled === 'boolean' && collections?.[collection]?.enabled;
|
|
5
|
+
if (fullyEnabled) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const partiallyEnabled = typeof collections?.[collection]?.enabled !== 'boolean' && (typeof collections?.[collection]?.enabled?.find === 'boolean' && collections?.[collection]?.enabled?.find === true || typeof collections?.[collection]?.enabled?.create === 'boolean' && collections?.[collection]?.enabled?.create === true || typeof collections?.[collection]?.enabled?.update === 'boolean' && collections?.[collection]?.enabled?.update === true || typeof collections?.[collection]?.enabled?.delete === 'boolean' && collections?.[collection]?.enabled?.delete === true);
|
|
9
|
+
if (partiallyEnabled) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return enabledCollectionSlugs.map((enabledCollectionSlug)=>({
|
|
14
|
+
type: 'collapsible',
|
|
15
|
+
admin: {
|
|
16
|
+
position: 'sidebar'
|
|
17
|
+
},
|
|
18
|
+
fields: [
|
|
19
|
+
{
|
|
20
|
+
name: `${toCamelCase(enabledCollectionSlug)}`,
|
|
21
|
+
type: 'group',
|
|
22
|
+
fields: [
|
|
23
|
+
...collections?.[enabledCollectionSlug]?.enabled === true || typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' && typeof collections?.[enabledCollectionSlug]?.enabled?.find === 'boolean' && collections?.[enabledCollectionSlug]?.enabled?.find === true ? [
|
|
24
|
+
{
|
|
25
|
+
name: `find`,
|
|
26
|
+
type: 'checkbox',
|
|
27
|
+
admin: {
|
|
28
|
+
description: `Allow clients to find ${enabledCollectionSlug}.`
|
|
29
|
+
},
|
|
30
|
+
defaultValue: false,
|
|
31
|
+
label: 'Find'
|
|
32
|
+
}
|
|
33
|
+
] : [],
|
|
34
|
+
...collections?.[enabledCollectionSlug]?.enabled === true || typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' && typeof collections?.[enabledCollectionSlug]?.enabled?.create === 'boolean' && collections?.[enabledCollectionSlug]?.enabled?.create === true ? [
|
|
35
|
+
{
|
|
36
|
+
name: `create`,
|
|
37
|
+
type: 'checkbox',
|
|
38
|
+
admin: {
|
|
39
|
+
description: `Allow clients to create ${enabledCollectionSlug}.`
|
|
40
|
+
},
|
|
41
|
+
defaultValue: false,
|
|
42
|
+
label: 'Create'
|
|
43
|
+
}
|
|
44
|
+
] : [],
|
|
45
|
+
...collections?.[enabledCollectionSlug]?.enabled === true || typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' && typeof collections?.[enabledCollectionSlug]?.enabled?.update === 'boolean' && collections?.[enabledCollectionSlug]?.enabled?.update === true ? [
|
|
46
|
+
{
|
|
47
|
+
name: `update`,
|
|
48
|
+
type: 'checkbox',
|
|
49
|
+
admin: {
|
|
50
|
+
description: `Allow clients to update ${enabledCollectionSlug}.`
|
|
51
|
+
},
|
|
52
|
+
defaultValue: false,
|
|
53
|
+
label: 'Update'
|
|
54
|
+
}
|
|
55
|
+
] : [],
|
|
56
|
+
...collections?.[enabledCollectionSlug]?.enabled === true || typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' && typeof collections?.[enabledCollectionSlug]?.enabled?.delete === 'boolean' && collections?.[enabledCollectionSlug]?.enabled?.delete === true ? [
|
|
57
|
+
{
|
|
58
|
+
name: `delete`,
|
|
59
|
+
type: 'checkbox',
|
|
60
|
+
admin: {
|
|
61
|
+
description: `Allow clients to delete ${enabledCollectionSlug}.`
|
|
62
|
+
},
|
|
63
|
+
defaultValue: false,
|
|
64
|
+
label: 'Delete'
|
|
65
|
+
}
|
|
66
|
+
] : []
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
label: `${enabledCollectionSlug.charAt(0).toUpperCase() + toCamelCase(enabledCollectionSlug).slice(1)}`
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
export const createAPIKeysCollection = (collections, customTools = [], experimentalTools = {})=>{
|
|
74
|
+
const customToolsFields = customTools.map((tool)=>{
|
|
75
|
+
const camelCasedName = toCamelCase(tool.name);
|
|
76
|
+
return {
|
|
77
|
+
name: camelCasedName,
|
|
78
|
+
type: 'checkbox',
|
|
79
|
+
admin: {
|
|
80
|
+
description: tool.description
|
|
81
|
+
},
|
|
82
|
+
defaultValue: true,
|
|
83
|
+
label: camelCasedName
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
slug: 'payload-mcp-api-keys',
|
|
88
|
+
admin: {
|
|
89
|
+
group: 'MCP',
|
|
90
|
+
useAsTitle: 'label'
|
|
91
|
+
},
|
|
92
|
+
auth: {
|
|
93
|
+
disableLocalStrategy: true,
|
|
94
|
+
useAPIKey: true
|
|
95
|
+
},
|
|
96
|
+
fields: [
|
|
97
|
+
{
|
|
98
|
+
name: 'user',
|
|
99
|
+
type: 'relationship',
|
|
100
|
+
admin: {
|
|
101
|
+
description: 'The user that the API key is associated with.'
|
|
102
|
+
},
|
|
103
|
+
relationTo: 'users',
|
|
104
|
+
required: true
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'label',
|
|
108
|
+
type: 'text',
|
|
109
|
+
admin: {
|
|
110
|
+
description: 'A useful label for the API key.'
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'description',
|
|
115
|
+
type: 'text',
|
|
116
|
+
admin: {
|
|
117
|
+
description: 'The purpose of the API key.'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
...addEnabledCollectionTools(collections),
|
|
121
|
+
...customTools.length > 0 ? [
|
|
122
|
+
{
|
|
123
|
+
type: 'collapsible',
|
|
124
|
+
admin: {
|
|
125
|
+
position: 'sidebar'
|
|
126
|
+
},
|
|
127
|
+
fields: [
|
|
128
|
+
{
|
|
129
|
+
name: 'custom',
|
|
130
|
+
type: 'group',
|
|
131
|
+
fields: customToolsFields
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
label: 'Custom Tools'
|
|
135
|
+
}
|
|
136
|
+
] : [],
|
|
137
|
+
// Experimental Tools
|
|
138
|
+
...process.env.NODE_ENV === 'development' && (experimentalTools?.collections?.enabled || experimentalTools?.jobs?.enabled || experimentalTools?.config?.enabled || experimentalTools?.auth?.enabled) ? [
|
|
139
|
+
{
|
|
140
|
+
type: 'collapsible',
|
|
141
|
+
admin: {
|
|
142
|
+
position: 'sidebar'
|
|
143
|
+
},
|
|
144
|
+
fields: [
|
|
145
|
+
...experimentalTools?.collections?.enabled ? [
|
|
146
|
+
{
|
|
147
|
+
name: 'collections',
|
|
148
|
+
type: 'group',
|
|
149
|
+
fields: [
|
|
150
|
+
{
|
|
151
|
+
name: 'find',
|
|
152
|
+
type: 'checkbox',
|
|
153
|
+
admin: {
|
|
154
|
+
description: 'Allow LLMs to find and list Payload collections with optional content and document counts.'
|
|
155
|
+
},
|
|
156
|
+
defaultValue: false
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'create',
|
|
160
|
+
type: 'checkbox',
|
|
161
|
+
admin: {
|
|
162
|
+
description: 'Allow LLMs to create new Payload collections with specified fields and configuration.'
|
|
163
|
+
},
|
|
164
|
+
defaultValue: false
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'update',
|
|
168
|
+
type: 'checkbox',
|
|
169
|
+
admin: {
|
|
170
|
+
description: 'Allow LLMs to update existing Payload collections with new fields, modifications, or configuration changes.'
|
|
171
|
+
},
|
|
172
|
+
defaultValue: false
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'delete',
|
|
176
|
+
type: 'checkbox',
|
|
177
|
+
admin: {
|
|
178
|
+
description: 'Allow LLMs to delete Payload collections and optionally update the configuration.'
|
|
179
|
+
},
|
|
180
|
+
defaultValue: false
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
] : [],
|
|
185
|
+
...experimentalTools?.jobs?.enabled ? [
|
|
186
|
+
{
|
|
187
|
+
name: 'jobs',
|
|
188
|
+
type: 'group',
|
|
189
|
+
fields: [
|
|
190
|
+
{
|
|
191
|
+
name: 'create',
|
|
192
|
+
type: 'checkbox',
|
|
193
|
+
admin: {
|
|
194
|
+
description: 'Allow LLMs to create new Payload jobs (tasks and workflows) with custom schemas and configuration.'
|
|
195
|
+
},
|
|
196
|
+
defaultValue: false
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'run',
|
|
200
|
+
type: 'checkbox',
|
|
201
|
+
admin: {
|
|
202
|
+
description: 'Allow LLMs to execute Payload jobs with custom input data and queue options.'
|
|
203
|
+
},
|
|
204
|
+
defaultValue: false
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'update',
|
|
208
|
+
type: 'checkbox',
|
|
209
|
+
admin: {
|
|
210
|
+
description: 'Allow LLMs to update existing Payload jobs with new schemas, configuration, or handler code.'
|
|
211
|
+
},
|
|
212
|
+
defaultValue: false
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
] : [],
|
|
217
|
+
...experimentalTools?.config?.enabled ? [
|
|
218
|
+
{
|
|
219
|
+
name: 'config',
|
|
220
|
+
type: 'group',
|
|
221
|
+
fields: [
|
|
222
|
+
{
|
|
223
|
+
name: 'find',
|
|
224
|
+
type: 'checkbox',
|
|
225
|
+
admin: {
|
|
226
|
+
description: 'Allow LLMs to read and display a Payload configuration file.'
|
|
227
|
+
},
|
|
228
|
+
defaultValue: false
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'update',
|
|
232
|
+
type: 'checkbox',
|
|
233
|
+
admin: {
|
|
234
|
+
description: 'Allow LLMs to update a Payload configuration file with various modifications.'
|
|
235
|
+
},
|
|
236
|
+
defaultValue: false
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
] : [],
|
|
241
|
+
...experimentalTools?.auth?.enabled ? [
|
|
242
|
+
{
|
|
243
|
+
name: 'auth',
|
|
244
|
+
type: 'group',
|
|
245
|
+
fields: [
|
|
246
|
+
{
|
|
247
|
+
name: 'auth',
|
|
248
|
+
type: 'checkbox',
|
|
249
|
+
admin: {
|
|
250
|
+
description: 'Allow LLMs to check authentication status for a user by setting custom headers. (e.g. {"Authorization": "Bearer <token>"})'
|
|
251
|
+
},
|
|
252
|
+
defaultValue: false,
|
|
253
|
+
label: 'Check Auth Status'
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: 'login',
|
|
257
|
+
type: 'checkbox',
|
|
258
|
+
admin: {
|
|
259
|
+
description: 'Allow LLMs to authenticate a user with email and password.'
|
|
260
|
+
},
|
|
261
|
+
defaultValue: false,
|
|
262
|
+
label: 'User Login'
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'verify',
|
|
266
|
+
type: 'checkbox',
|
|
267
|
+
admin: {
|
|
268
|
+
description: 'Allow LLMs to verify a user email with a verification token.'
|
|
269
|
+
},
|
|
270
|
+
defaultValue: false,
|
|
271
|
+
label: 'Email Verification'
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: 'resetPassword',
|
|
275
|
+
type: 'checkbox',
|
|
276
|
+
admin: {
|
|
277
|
+
description: 'Allow LLMs to reset a user password with a reset token.'
|
|
278
|
+
},
|
|
279
|
+
defaultValue: false,
|
|
280
|
+
label: 'Reset Password'
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: 'forgotPassword',
|
|
284
|
+
type: 'checkbox',
|
|
285
|
+
admin: {
|
|
286
|
+
description: 'Allow LLMs to send a password reset email to a user.'
|
|
287
|
+
},
|
|
288
|
+
defaultValue: false,
|
|
289
|
+
label: 'Forgot Password'
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: 'unlock',
|
|
293
|
+
type: 'checkbox',
|
|
294
|
+
admin: {
|
|
295
|
+
description: 'Allow LLMs to unlock a user account that has been locked due to failed login attempts.'
|
|
296
|
+
},
|
|
297
|
+
defaultValue: false,
|
|
298
|
+
label: 'Unlock Account'
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
] : []
|
|
303
|
+
],
|
|
304
|
+
label: 'Experimental Tools'
|
|
305
|
+
}
|
|
306
|
+
] : []
|
|
307
|
+
],
|
|
308
|
+
labels: {
|
|
309
|
+
plural: 'API Keys',
|
|
310
|
+
singular: 'API Key'
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
//# sourceMappingURL=createApiKeysCollection.js.map
|
|
@@ -0,0 +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'\n\nconst addEnabledCollectionTools = (collections: PluginMCPServerConfig['collections']) => {\n const enabledCollectionSlugs = Object.keys(collections || {}).filter((collection) => {\n const fullyEnabled =\n typeof collections?.[collection]?.enabled === 'boolean' && collections?.[collection]?.enabled\n\n if (fullyEnabled) {\n return true\n }\n\n const partiallyEnabled =\n typeof collections?.[collection]?.enabled !== 'boolean' &&\n ((typeof collections?.[collection]?.enabled?.find === 'boolean' &&\n collections?.[collection]?.enabled?.find === true) ||\n (typeof collections?.[collection]?.enabled?.create === 'boolean' &&\n collections?.[collection]?.enabled?.create === true) ||\n (typeof collections?.[collection]?.enabled?.update === 'boolean' &&\n collections?.[collection]?.enabled?.update === true) ||\n (typeof collections?.[collection]?.enabled?.delete === 'boolean' &&\n collections?.[collection]?.enabled?.delete === true))\n\n if (partiallyEnabled) {\n return true\n }\n })\n return enabledCollectionSlugs.map((enabledCollectionSlug) => ({\n type: 'collapsible' as const,\n admin: {\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: `${toCamelCase(enabledCollectionSlug)}`,\n type: 'group' as const,\n fields: [\n ...(collections?.[enabledCollectionSlug]?.enabled === true ||\n (typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' &&\n typeof collections?.[enabledCollectionSlug]?.enabled?.find === 'boolean' &&\n collections?.[enabledCollectionSlug]?.enabled?.find === true)\n ? [\n {\n name: `find`,\n type: 'checkbox' as const,\n admin: {\n description: `Allow clients to find ${enabledCollectionSlug}.`,\n },\n defaultValue: false,\n label: 'Find',\n },\n ]\n : []),\n\n ...(collections?.[enabledCollectionSlug]?.enabled === true ||\n (typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' &&\n typeof collections?.[enabledCollectionSlug]?.enabled?.create === 'boolean' &&\n collections?.[enabledCollectionSlug]?.enabled?.create === true)\n ? [\n {\n name: `create`,\n type: 'checkbox' as const,\n admin: {\n description: `Allow clients to create ${enabledCollectionSlug}.`,\n },\n defaultValue: false,\n label: 'Create',\n },\n ]\n : []),\n\n ...(collections?.[enabledCollectionSlug]?.enabled === true ||\n (typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' &&\n typeof collections?.[enabledCollectionSlug]?.enabled?.update === 'boolean' &&\n collections?.[enabledCollectionSlug]?.enabled?.update === true)\n ? [\n {\n name: `update`,\n type: 'checkbox' as const,\n admin: {\n description: `Allow clients to update ${enabledCollectionSlug}.`,\n },\n defaultValue: false,\n label: 'Update',\n },\n ]\n : []),\n\n ...(collections?.[enabledCollectionSlug]?.enabled === true ||\n (typeof collections?.[enabledCollectionSlug]?.enabled !== 'boolean' &&\n typeof collections?.[enabledCollectionSlug]?.enabled?.delete === 'boolean' &&\n collections?.[enabledCollectionSlug]?.enabled?.delete === true)\n ? [\n {\n name: `delete`,\n type: 'checkbox' as const,\n admin: {\n description: `Allow clients to delete ${enabledCollectionSlug}.`,\n },\n defaultValue: false,\n label: 'Delete',\n },\n ]\n : []),\n ],\n },\n ],\n label: `${enabledCollectionSlug.charAt(0).toUpperCase() + toCamelCase(enabledCollectionSlug).slice(1)}`,\n }))\n}\n\nexport const createAPIKeysCollection = (\n collections: PluginMCPServerConfig['collections'],\n customTools: Array<{ description: string; name: string }> = [],\n experimentalTools: NonNullable<PluginMCPServerConfig['experimental']>['tools'] = {},\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 return {\n slug: 'payload-mcp-api-keys',\n admin: {\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: 'users',\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 ...addEnabledCollectionTools(collections),\n\n ...(customTools.length > 0\n ? [\n {\n type: 'collapsible' as const,\n admin: {\n position: 'sidebar' as const,\n },\n fields: [\n {\n name: 'custom',\n type: 'group' as const,\n fields: customToolsFields,\n },\n ],\n label: 'Custom Tools',\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 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","addEnabledCollectionTools","collections","enabledCollectionSlugs","Object","keys","filter","collection","fullyEnabled","enabled","partiallyEnabled","find","create","update","delete","map","enabledCollectionSlug","type","admin","position","fields","name","description","defaultValue","label","charAt","toUpperCase","slice","createAPIKeysCollection","customTools","experimentalTools","customToolsFields","tool","camelCasedName","slug","group","useAsTitle","auth","disableLocalStrategy","useAPIKey","relationTo","required","length","process","env","NODE_ENV","jobs","config","labels","plural","singular"],"mappings":"AAIA,SAASA,WAAW,QAAQ,wBAAuB;AAEnD,MAAMC,4BAA4B,CAACC;IACjC,MAAMC,yBAAyB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;oCACA;wCACEH,MAAM;wCACNJ,MAAM;wCACNC,OAAO;4CACLI,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEH,MAAM;wCACNJ,MAAM;wCACNC,OAAO;4CACLI,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEH,MAAM;wCACNJ,MAAM;wCACNC,OAAO;4CACLI,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEH,MAAM;wCACNJ,MAAM;wCACNC,OAAO;4CACLI,aAAa;wCACf;wCACAC,cAAc;wCACdC,OAAO;oCACT;oCACA;wCACEH,MAAM;wCACNJ,MAAM;wCACNC,OAAO;4CACLI,aACE;wCACJ;wCACAC,cAAc;wCACdC,OAAO;oCACT;iCACD;4BACH;yBACD,GACD,EAAE;qBACP;oBACDA,OAAO;gBACT;aACD,GACD,EAAE;SACP;QACDwB,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/endpoints/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAc,MAAM,SAAS,CAAA;AAEnE,OAAO,KAAK,EAAE,qBAAqB,EAAgB,MAAM,aAAa,CAAA;AAKtE,eAAO,MAAM,oBAAoB,kBAAmB,qBAAqB,mBAmDxE,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import { APIError } from 'payload';
|
|
3
|
+
import { createRequestFromPayloadRequest } from '../mcp/createRequest.js';
|
|
4
|
+
import { getMCPHandler } from '../mcp/getMcpHandler.js';
|
|
5
|
+
export const initializeMCPHandler = (pluginOptions)=>{
|
|
6
|
+
const mcpHandler = async (req)=>{
|
|
7
|
+
const { payload } = req;
|
|
8
|
+
const MCPOptions = pluginOptions.mcp || {};
|
|
9
|
+
const MCPHandlerOptions = MCPOptions.handlerOptions || {};
|
|
10
|
+
const useVerboseLogs = MCPHandlerOptions.verboseLogs ?? false;
|
|
11
|
+
const apiKey = req.headers.get('Authorization')?.startsWith('Bearer ') ? req.headers.get('Authorization')?.replace('Bearer ', '').trim() : null;
|
|
12
|
+
if (apiKey === null) {
|
|
13
|
+
throw new APIError('API Key is required', 401);
|
|
14
|
+
}
|
|
15
|
+
const sha256APIKeyIndex = crypto.createHmac('sha256', payload.secret).update(apiKey || '').digest('hex');
|
|
16
|
+
const apiKeyConstraints = [
|
|
17
|
+
{
|
|
18
|
+
apiKeyIndex: {
|
|
19
|
+
equals: sha256APIKeyIndex
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
const where = {
|
|
24
|
+
or: apiKeyConstraints
|
|
25
|
+
};
|
|
26
|
+
const { docs } = await payload.find({
|
|
27
|
+
collection: 'payload-mcp-api-keys',
|
|
28
|
+
where
|
|
29
|
+
});
|
|
30
|
+
if (docs.length === 0) {
|
|
31
|
+
throw new APIError('API Key is invalid', 401);
|
|
32
|
+
}
|
|
33
|
+
const toolSettings = docs[0];
|
|
34
|
+
if (useVerboseLogs) {
|
|
35
|
+
payload.logger.info('[payload-mcp] API Key is valid');
|
|
36
|
+
}
|
|
37
|
+
const handler = getMCPHandler(pluginOptions, toolSettings, req);
|
|
38
|
+
const request = createRequestFromPayloadRequest(req);
|
|
39
|
+
return await handler(request);
|
|
40
|
+
};
|
|
41
|
+
return mcpHandler;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/mcp.ts"],"sourcesContent":["import crypto from 'crypto'\nimport { APIError, type PayloadHandler, type Where } from 'payload'\n\nimport type { PluginMCPServerConfig, ToolSettings } 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 const apiKey = req.headers.get('Authorization')?.startsWith('Bearer ')\n ? req.headers.get('Authorization')?.replace('Bearer ', '').trim()\n : null\n\n if (apiKey === null) {\n throw new APIError('API Key is required', 401)\n }\n\n const sha256APIKeyIndex = crypto\n .createHmac('sha256', payload.secret)\n .update(apiKey || '')\n .digest('hex')\n\n const apiKeyConstraints = [\n {\n apiKeyIndex: {\n equals: sha256APIKeyIndex,\n },\n },\n ]\n const where: Where = {\n or: apiKeyConstraints,\n }\n\n const { docs } = await payload.find({\n collection: 'payload-mcp-api-keys',\n where,\n })\n\n if (docs.length === 0) {\n throw new APIError('API Key is invalid', 401)\n }\n\n const toolSettings = docs[0] as ToolSettings\n\n if (useVerboseLogs) {\n payload.logger.info('[payload-mcp] API Key is valid')\n }\n\n const handler = getMCPHandler(pluginOptions, toolSettings, req)\n const request = createRequestFromPayloadRequest(req)\n return await handler(request)\n }\n return mcpHandler\n}\n"],"names":["crypto","APIError","createRequestFromPayloadRequest","getMCPHandler","initializeMCPHandler","pluginOptions","mcpHandler","req","payload","MCPOptions","mcp","MCPHandlerOptions","handlerOptions","useVerboseLogs","verboseLogs","apiKey","headers","get","startsWith","replace","trim","sha256APIKeyIndex","createHmac","secret","update","digest","apiKeyConstraints","apiKeyIndex","equals","where","or","docs","find","collection","length","toolSettings","logger","info","handler","request"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,SAASC,QAAQ,QAAyC,UAAS;AAInE,SAASC,+BAA+B,QAAQ,0BAAyB;AACzE,SAASC,aAAa,QAAQ,0BAAyB;AAEvD,OAAO,MAAMC,uBAAuB,CAACC;IACnC,MAAMC,aAA6B,OAAOC;QACxC,MAAM,EAAEC,OAAO,EAAE,GAAGD;QACpB,MAAME,aAAaJ,cAAcK,GAAG,IAAI,CAAC;QACzC,MAAMC,oBAAoBF,WAAWG,cAAc,IAAI,CAAC;QACxD,MAAMC,iBAAiBF,kBAAkBG,WAAW,IAAI;QAExD,MAAMC,SAASR,IAAIS,OAAO,CAACC,GAAG,CAAC,kBAAkBC,WAAW,aACxDX,IAAIS,OAAO,CAACC,GAAG,CAAC,kBAAkBE,QAAQ,WAAW,IAAIC,SACzD;QAEJ,IAAIL,WAAW,MAAM;YACnB,MAAM,IAAId,SAAS,uBAAuB;QAC5C;QAEA,MAAMoB,oBAAoBrB,OACvBsB,UAAU,CAAC,UAAUd,QAAQe,MAAM,EACnCC,MAAM,CAACT,UAAU,IACjBU,MAAM,CAAC;QAEV,MAAMC,oBAAoB;YACxB;gBACEC,aAAa;oBACXC,QAAQP;gBACV;YACF;SACD;QACD,MAAMQ,QAAe;YACnBC,IAAIJ;QACN;QAEA,MAAM,EAAEK,IAAI,EAAE,GAAG,MAAMvB,QAAQwB,IAAI,CAAC;YAClCC,YAAY;YACZJ;QACF;QAEA,IAAIE,KAAKG,MAAM,KAAK,GAAG;YACrB,MAAM,IAAIjC,SAAS,sBAAsB;QAC3C;QAEA,MAAMkC,eAAeJ,IAAI,CAAC,EAAE;QAE5B,IAAIlB,gBAAgB;YAClBL,QAAQ4B,MAAM,CAACC,IAAI,CAAC;QACtB;QAEA,MAAMC,UAAUnC,cAAcE,eAAe8B,cAAc5B;QAC3D,MAAMgC,UAAUrC,gCAAgCK;QAChD,OAAO,MAAM+B,QAAQC;IACvB;IACA,OAAOjC;AACT,EAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
import type { PluginMCPServerConfig } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.
|
|
5
|
+
*
|
|
6
|
+
* @param pluginOptions - The options for the MCP plugin.
|
|
7
|
+
* @experimental This plugin is experimental and may change in the future.
|
|
8
|
+
*/
|
|
9
|
+
export declare const mcpPlugin: (pluginOptions: PluginMCPServerConfig) => (config: Config) => Config;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAKvD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,kBACJ,qBAAqB,cAC5B,MAAM,KAAG,MAsEjB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createAPIKeysCollection } from './collections/createApiKeysCollection.js';
|
|
2
|
+
import { initializeMCPHandler } from './endpoints/mcp.js';
|
|
3
|
+
/**
|
|
4
|
+
* The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.
|
|
5
|
+
*
|
|
6
|
+
* @param pluginOptions - The options for the MCP plugin.
|
|
7
|
+
* @experimental This plugin is experimental and may change in the future.
|
|
8
|
+
*/ export const mcpPlugin = (pluginOptions)=>(config)=>{
|
|
9
|
+
if (!config.collections) {
|
|
10
|
+
config.collections = [];
|
|
11
|
+
}
|
|
12
|
+
// Collections
|
|
13
|
+
const collections = pluginOptions.collections || {};
|
|
14
|
+
// Extract custom tools for the global config
|
|
15
|
+
const customTools = pluginOptions.mcp?.tools?.map((tool)=>({
|
|
16
|
+
name: tool.name,
|
|
17
|
+
description: tool.description
|
|
18
|
+
})) || [];
|
|
19
|
+
const experimentalTools = pluginOptions?.experimental?.tools || {};
|
|
20
|
+
/**
|
|
21
|
+
* API Keys
|
|
22
|
+
* --------
|
|
23
|
+
* High resolution control over MCP capabilities is crucial when using Payload with LLMs.
|
|
24
|
+
*
|
|
25
|
+
* This API Keys collection has ways for admins to create API keys and allow or disallow the MCP capabilities.
|
|
26
|
+
* This is useful when Admins want to allow or disallow the use of the MCP capabilities in real time.
|
|
27
|
+
* For example:
|
|
28
|
+
* - If a collection has all of its capabilities enabled, admins can allow or disallow the create, update, delete, and find capabilities on that collection.
|
|
29
|
+
* - If a collection only has the find capability enabled, admins can only allow or disallow the find capability on that collection.
|
|
30
|
+
* - If a custom tool has gone haywire, admins can disallow that tool.
|
|
31
|
+
*
|
|
32
|
+
*/ const apiKeyCollection = createAPIKeysCollection(collections, customTools, experimentalTools);
|
|
33
|
+
if (pluginOptions.overrideApiKeyCollection) {
|
|
34
|
+
config.collections.push(pluginOptions.overrideApiKeyCollection(apiKeyCollection));
|
|
35
|
+
} else {
|
|
36
|
+
config.collections.push(apiKeyCollection);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.
|
|
40
|
+
* If your plugin heavily modifies the database schema, you may want to remove this property.
|
|
41
|
+
*/ if (pluginOptions.disabled) {
|
|
42
|
+
return config;
|
|
43
|
+
}
|
|
44
|
+
if (!config.endpoints) {
|
|
45
|
+
config.endpoints = [];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* This is the primary MCP Server Endpoint.
|
|
49
|
+
* Payload will automatically add the /api prefix to the path, so the full path is `/api/mcp`
|
|
50
|
+
* NOTE: This is only transport method until we add full support for SSE which will be another endpoint at `/api/sse`
|
|
51
|
+
*/ config.endpoints.push({
|
|
52
|
+
handler: initializeMCPHandler(pluginOptions),
|
|
53
|
+
method: 'post',
|
|
54
|
+
path: '/mcp'
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* The GET response is always: {"jsonrpc":"2.0","error":{"code":-32000,"message":"Method not allowed."},"id":null} -- even with an API key
|
|
58
|
+
* This is expected behavior and MCP clients should always use the POST endpoint.
|
|
59
|
+
*/ config.endpoints.push({
|
|
60
|
+
handler: initializeMCPHandler(pluginOptions),
|
|
61
|
+
method: 'get',
|
|
62
|
+
path: '/mcp'
|
|
63
|
+
});
|
|
64
|
+
return config;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport type { PluginMCPServerConfig } from './types.js'\n\nimport { createAPIKeysCollection } from './collections/createApiKeysCollection.js'\nimport { initializeMCPHandler } from './endpoints/mcp.js'\n\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 // 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 custom tool has gone haywire, admins can disallow that tool.\n *\n */\n const apiKeyCollection = createAPIKeysCollection(collections, customTools, experimentalTools)\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","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;AAEzD;;;;;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,6CAA6C;QAC7C,MAAMC,cACJH,cAAcI,GAAG,EAAEC,OAAOC,IAAI,CAACC,OAAU,CAAA;gBACvCC,MAAMD,KAAKC,IAAI;gBACfC,aAAaF,KAAKE,WAAW;YAC/B,CAAA,MAAO,EAAE;QAEX,MAAMC,oBAAoBV,eAAeW,cAAcN,SAAS,CAAC;QAEjE;;;;;;;;;;;;KAYC,GACD,MAAMO,mBAAmBf,wBAAwBK,aAAaC,aAAaO;QAC3E,IAAIV,cAAca,wBAAwB,EAAE;YAC1CZ,OAAOC,WAAW,CAACY,IAAI,CAACd,cAAca,wBAAwB,CAACD;QACjE,OAAO;YACLX,OAAOC,WAAW,CAACY,IAAI,CAACF;QAC1B;QAEA;;;KAGC,GACD,IAAIZ,cAAce,QAAQ,EAAE;YAC1B,OAAOd;QACT;QAEA,IAAI,CAACA,OAAOe,SAAS,EAAE;YACrBf,OAAOe,SAAS,GAAG,EAAE;QACvB;QAEA;;;;KAIC,GACDf,OAAOe,SAAS,CAACF,IAAI,CAAC;YACpBG,SAASnB,qBAAqBE;YAC9BkB,QAAQ;YACRC,MAAM;QACR;QAEA;;;KAGC,GACDlB,OAAOe,SAAS,CAACF,IAAI,CAAC;YACpBG,SAASnB,qBAAqBE;YAC9BkB,QAAQ;YACRC,MAAM;QACR;QAEA,OAAOlB;IACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRequest.d.ts","sourceRoot":"","sources":["../../src/mcp/createRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAEvD,eAAO,MAAM,+BAA+B,QAAS,cAAc,YAUlE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { APIError } from 'payload';
|
|
2
|
+
export const createRequestFromPayloadRequest = (req)=>{
|
|
3
|
+
if (!req.url) {
|
|
4
|
+
throw new APIError('Request URL is required', 500);
|
|
5
|
+
}
|
|
6
|
+
return new Request(req.url, {
|
|
7
|
+
body: req.body,
|
|
8
|
+
duplex: 'half',
|
|
9
|
+
headers: req.headers,
|
|
10
|
+
method: req.method
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=createRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/createRequest.ts"],"sourcesContent":["import { APIError, type PayloadRequest } from 'payload'\n\nexport const createRequestFromPayloadRequest = (req: PayloadRequest) => {\n if (!req.url) {\n throw new APIError('Request URL is required', 500)\n }\n return new Request(req.url, {\n body: req.body,\n duplex: 'half',\n headers: req.headers,\n method: req.method,\n } as { duplex: 'half' } & RequestInit)\n}\n"],"names":["APIError","createRequestFromPayloadRequest","req","url","Request","body","duplex","headers","method"],"mappings":"AAAA,SAASA,QAAQ,QAA6B,UAAS;AAEvD,OAAO,MAAMC,kCAAkC,CAACC;IAC9C,IAAI,CAACA,IAAIC,GAAG,EAAE;QACZ,MAAM,IAAIH,SAAS,2BAA2B;IAChD;IACA,OAAO,IAAII,QAAQF,IAAIC,GAAG,EAAE;QAC1BE,MAAMH,IAAIG,IAAI;QACdC,QAAQ;QACRC,SAASL,IAAIK,OAAO;QACpBC,QAAQN,IAAIM,MAAM;IACpB;AACF,EAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
import type { PluginMCPServerConfig, ToolSettings } from '../types.js';
|
|
3
|
+
export declare const getMCPHandler: (pluginOptions: PluginMCPServerConfig, toolSettings: ToolSettings, req: PayloadRequest) => (request: Request) => Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=getMcpHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMcpHandler.d.ts","sourceRoot":"","sources":["../../src/mcp/getMcpHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,KAAK,cAAc,EAAkB,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA4BtE,eAAO,MAAM,aAAa,kBACT,qBAAqB,gBACtB,YAAY,OACrB,cAAc,4CA2YpB,CAAA"}
|