@frogbotai/plugin-mcp 0.14.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FrogBot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @frogbotai/plugin-mcp
2
+
3
+ Expose selected FrogBot collections and globals to external MCP clients through Payload's MCP server.
4
+
5
+ ```ts
6
+ import { apiKeysPlugin } from '@frogbotai/plugin-api-keys';
7
+ import { mcpPlugin } from '@frogbotai/plugin-mcp';
8
+ import { rolesPlugin } from '@frogbotai/plugin-roles';
9
+ import { buildConfig } from 'frogbot';
10
+
11
+ export default buildConfig({
12
+ collections: [
13
+ { slug: 'users', auth: true, fields: [] },
14
+ { slug: 'posts', fields: [{ name: 'title', type: 'text' }] },
15
+ ],
16
+ plugins: [
17
+ rolesPlugin(),
18
+ apiKeysPlugin(),
19
+ mcpPlugin({
20
+ collections: { posts: { enabled: { find: true } } },
21
+ }),
22
+ ],
23
+ });
24
+ ```
25
+
26
+ Connect MCP clients to `/api/mcp` with a Bearer token minted by `@frogbotai/plugin-api-keys`. Revoked, malformed, and unknown keys are rejected. The plugin requires `apiKeysPlugin()` earlier in the plugin array.
27
+
28
+ This package is a thin adapter around `@payloadcms/plugin-mcp`. Payload adds a dormant `payload-mcp-api-keys` collection for schema stability, but its keys cannot authenticate this endpoint. Experimental config, collection-definition, job, and auth-mutation tools are unavailable. SSE is not supported.
@@ -0,0 +1,13 @@
1
+ import type { ApiKeyStrategy } from '@frogbotai/plugin-api-keys';
2
+ import type { MCPAccessSettings } from '@payloadcms/plugin-mcp';
3
+ import type { MCPPluginConfig } from '@payloadcms/plugin-mcp';
4
+ import type { PayloadRequest } from 'payload';
5
+ type ResolveMcpAccessOptions = {
6
+ authenticate: ApiKeyStrategy['authenticate'];
7
+ pluginOptions: MCPPluginConfig;
8
+ req: PayloadRequest;
9
+ };
10
+ export declare function validateMcpCapabilities(pluginOptions: MCPPluginConfig): void;
11
+ export declare function resolveMcpAccess({ authenticate, pluginOptions, req }: ResolveMcpAccessOptions): Promise<MCPAccessSettings>;
12
+ export {};
13
+ //# sourceMappingURL=access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,KAAK,uBAAuB,GAAG;IAC7B,YAAY,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC7C,aAAa,EAAE,eAAe,CAAC;IAC/B,GAAG,EAAE,cAAc,CAAC;CACrB,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAa5E;AAoBD,wBAAsB,gBAAgB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsBhI"}
package/dist/access.js ADDED
@@ -0,0 +1,57 @@
1
+ import { UnauthorizedError } from 'payload';
2
+ const toCamelCase = (value) => value
3
+ .replace(/[-_\s]+(.)?/g, (_, character) => character?.toUpperCase() ?? '')
4
+ .replace(/^(.)/, (_, character) => character.toLowerCase());
5
+ export function validateMcpCapabilities(pluginOptions) {
6
+ const reserved = new Set(['auth', 'config', 'jobs']);
7
+ for (const [type, entities] of [
8
+ ['Collection', pluginOptions.collections],
9
+ ['Global', pluginOptions.globals],
10
+ ]) {
11
+ for (const slug of Object.keys(entities ?? {})) {
12
+ const capability = toCamelCase(slug);
13
+ if (reserved.has(capability)) {
14
+ throw new Error(`[plugin-mcp] ${type} slug '${slug}' maps to reserved MCP capability '${capability}'.`);
15
+ }
16
+ }
17
+ }
18
+ }
19
+ function collectionGrants(options) {
20
+ return Object.fromEntries(Object.entries(options ?? {}).map(([slug, config]) => [
21
+ toCamelCase(slug),
22
+ config?.enabled === true ? { create: true, delete: true, find: true, update: true } : config?.enabled,
23
+ ]));
24
+ }
25
+ function globalGrants(options) {
26
+ return Object.fromEntries(Object.entries(options ?? {}).map(([slug, config]) => [
27
+ toCamelCase(slug),
28
+ config?.enabled === true ? { find: true, update: true } : config?.enabled,
29
+ ]));
30
+ }
31
+ function namedGrants(items) {
32
+ return Object.fromEntries((items ?? []).map(({ name }) => [toCamelCase(name), true]));
33
+ }
34
+ export async function resolveMcpAccess({ authenticate, pluginOptions, req }) {
35
+ const result = await authenticate({ headers: req.headers, payload: req.payload });
36
+ if (!result.user)
37
+ throw new UnauthorizedError();
38
+ return {
39
+ user: result.user,
40
+ ...collectionGrants(pluginOptions.collections),
41
+ ...globalGrants(pluginOptions.globals),
42
+ 'payload-mcp-tool': namedGrants(pluginOptions.mcp?.tools),
43
+ 'payload-mcp-prompt': namedGrants(pluginOptions.mcp?.prompts),
44
+ 'payload-mcp-resource': namedGrants(pluginOptions.mcp?.resources),
45
+ auth: {
46
+ auth: false,
47
+ forgotPassword: false,
48
+ login: false,
49
+ resetPassword: false,
50
+ unlock: false,
51
+ verify: false,
52
+ },
53
+ config: { find: false, update: false },
54
+ jobs: { create: false, run: false, update: false },
55
+ };
56
+ }
57
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAQ5C,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK;KACzC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,SAA6B,EAAE,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;KAC7F,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;AAEtE,MAAM,UAAU,uBAAuB,CAAC,aAA8B;IACpE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI;QAC7B,CAAC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC;QACzC,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC;KACzB,EAAE,CAAC;QACX,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;YAC/C,MAAM,UAAU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E,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,EAA2B;IAClG,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAClF,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAEhD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,gBAAgB,CAAC,aAAa,CAAC,WAAW,CAAC;QAC9C,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC;QACtC,kBAAkB,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC;QACzD,oBAAoB,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;QAC7D,sBAAsB,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC;QACjE,IAAI,EAAE;YACJ,IAAI,EAAE,KAAK;YACX,cAAc,EAAE,KAAK;YACrB,KAAK,EAAE,KAAK;YACZ,aAAa,EAAE,KAAK;YACpB,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,KAAK;SACd;QACD,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;QACtC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { MCPPluginConfig } from '@payloadcms/plugin-mcp';
2
+ import type { Plugin } from 'frogbot';
3
+ export type McpPluginOptions = Omit<MCPPluginConfig, 'experimental' | 'overrideAuth'>;
4
+ export declare function mcpPlugin(pluginOptions?: McpPluginOptions): Plugin;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;AAEtF,wBAAgB,SAAS,CAAC,aAAa,GAAE,gBAAqB,GAAG,MAAM,CAiBtE"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { isApiKeyStrategy } from '@frogbotai/plugin-api-keys';
2
+ import { mcpPlugin as payloadMcpPlugin } from '@payloadcms/plugin-mcp';
3
+ import { resolveMcpAccess, validateMcpCapabilities } from './access.js';
4
+ export function mcpPlugin(pluginOptions = {}) {
5
+ validateMcpCapabilities(pluginOptions);
6
+ return async (config) => {
7
+ const apiKeyStrategy = config.collections.flatMap((collection) => {
8
+ const auth = typeof collection.auth === 'object' ? collection.auth : undefined;
9
+ return auth?.strategies ?? [];
10
+ }).find(isApiKeyStrategy);
11
+ if (!apiKeyStrategy) {
12
+ throw new Error('[plugin-mcp] apiKeysPlugin must be configured before mcpPlugin.');
13
+ }
14
+ const { experimental: _experimental, overrideAuth: _overrideAuth, ...options } = pluginOptions;
15
+ return await payloadMcpPlugin({
16
+ ...options,
17
+ overrideAuth: (req) => resolveMcpAccess({ authenticate: apiKeyStrategy.authenticate, pluginOptions: options, req }),
18
+ })(config);
19
+ };
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,UAAU,SAAS,CAAC,gBAAkC,EAAE;IAC5D,uBAAuB,CAAC,aAAa,CAAC,CAAC;IACvC,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YAC/D,MAAM,IAAI,GAAG,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/E,OAAO,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,GAAG,aAAgC,CAAC;QAClH,OAAO,MAAM,gBAAgB,CAAC;YAC5B,GAAG,OAAO;YACV,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;SACpH,CAAC,CAAC,MAAe,CAA6B,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@frogbotai/plugin-mcp",
3
+ "version": "0.14.0",
4
+ "description": "Payload MCP integration for FrogBot.",
5
+ "license": "MIT",
6
+ "author": "Colby Gilbert",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/frogbotai/frogbot.git",
10
+ "directory": "packages/plugins/plugin-mcp"
11
+ },
12
+ "homepage": "https://github.com/frogbotai/frogbot#readme",
13
+ "type": "module",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "engines": {
27
+ "node": ">=22"
28
+ },
29
+ "dependencies": {
30
+ "@payloadcms/plugin-mcp": "3.85.1"
31
+ },
32
+ "peerDependencies": {
33
+ "payload": "3.85.1",
34
+ "@frogbotai/plugin-api-keys": "0.14.0",
35
+ "frogbot": "0.14.0"
36
+ },
37
+ "devDependencies": {
38
+ "payload": "3.85.1",
39
+ "typescript": "5.6.2",
40
+ "frogbot": "0.14.0",
41
+ "@frogbotai/plugin-api-keys": "0.14.0",
42
+ "@frogbotai/plugin-roles": "0.14.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.json",
49
+ "clean": "rm -rf dist",
50
+ "typecheck": "tsc --noEmit"
51
+ }
52
+ }