payload-mcp-toolkit 0.3.3 → 0.7.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/README.md +232 -150
- package/dist/__tests__/api-keys.test.js +292 -0
- package/dist/__tests__/api-keys.test.js.map +1 -0
- package/dist/__tests__/auth-strategy.test.js +681 -0
- package/dist/__tests__/auth-strategy.test.js.map +1 -0
- package/dist/__tests__/conflict-detection.test.js +69 -0
- package/dist/__tests__/conflict-detection.test.js.map +1 -0
- package/dist/__tests__/delete-document.test.js +70 -0
- package/dist/__tests__/delete-document.test.js.map +1 -0
- package/dist/__tests__/endpoint.test.js +143 -0
- package/dist/__tests__/endpoint.test.js.map +1 -0
- package/dist/__tests__/find-document.test.js +178 -0
- package/dist/__tests__/find-document.test.js.map +1 -0
- package/dist/__tests__/find-global.test.js +173 -0
- package/dist/__tests__/find-global.test.js.map +1 -0
- package/dist/__tests__/global-versions.test.js +183 -0
- package/dist/__tests__/global-versions.test.js.map +1 -0
- package/dist/__tests__/hash.test.js +58 -0
- package/dist/__tests__/hash.test.js.map +1 -0
- package/dist/__tests__/index-integration.test.js +191 -0
- package/dist/__tests__/index-integration.test.js.map +1 -0
- package/dist/__tests__/introspection.test.js +201 -1
- package/dist/__tests__/introspection.test.js.map +1 -1
- package/dist/__tests__/patch-global-layout.test.js +474 -0
- package/dist/__tests__/patch-global-layout.test.js.map +1 -0
- package/dist/__tests__/patch-layout.test.js +171 -0
- package/dist/__tests__/patch-layout.test.js.map +1 -0
- package/dist/__tests__/registry.test.js +795 -0
- package/dist/__tests__/registry.test.js.map +1 -0
- package/dist/__tests__/resources.test.js +139 -0
- package/dist/__tests__/resources.test.js.map +1 -0
- package/dist/__tests__/update-global.test.js +157 -0
- package/dist/__tests__/update-global.test.js.map +1 -0
- package/dist/api-keys.d.ts +46 -0
- package/dist/api-keys.js +272 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/auth-strategy.d.ts +85 -0
- package/dist/auth-strategy.js +219 -0
- package/dist/auth-strategy.js.map +1 -0
- package/dist/components/CollectionScopesMatrix.d.ts +8 -0
- package/dist/components/CollectionScopesMatrix.js +32 -0
- package/dist/components/CollectionScopesMatrix.js.map +1 -0
- package/dist/components/GlobalScopesMatrix.d.ts +8 -0
- package/dist/components/GlobalScopesMatrix.js +28 -0
- package/dist/components/GlobalScopesMatrix.js.map +1 -0
- package/dist/components/ScopesTable.d.ts +19 -0
- package/dist/components/ScopesTable.js +285 -0
- package/dist/components/ScopesTable.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/conflict-detection.d.ts +13 -0
- package/dist/conflict-detection.js +41 -0
- package/dist/conflict-detection.js.map +1 -0
- package/dist/draft-workflow.d.ts +46 -47
- package/dist/draft-workflow.js +53 -130
- package/dist/draft-workflow.js.map +1 -1
- package/dist/endpoint.d.ts +35 -0
- package/dist/endpoint.js +105 -0
- package/dist/endpoint.js.map +1 -0
- package/dist/hash.d.ts +21 -0
- package/dist/hash.js +36 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +168 -68
- package/dist/index.js.map +1 -1
- package/dist/introspection.d.ts +17 -3
- package/dist/introspection.js +95 -36
- package/dist/introspection.js.map +1 -1
- package/dist/prompts.js +5 -5
- package/dist/prompts.js.map +1 -1
- package/dist/registry.d.ts +50 -0
- package/dist/registry.js +169 -0
- package/dist/registry.js.map +1 -0
- package/dist/resources.d.ts +5 -3
- package/dist/resources.js +23 -11
- package/dist/resources.js.map +1 -1
- package/dist/scope/audit-log.d.ts +18 -0
- package/dist/scope/audit-log.js +50 -0
- package/dist/scope/audit-log.js.map +1 -0
- package/dist/scope/policy.d.ts +73 -0
- package/dist/scope/policy.js +218 -0
- package/dist/scope/policy.js.map +1 -0
- package/dist/tools/_helpers.d.ts +28 -1
- package/dist/tools/_helpers.js +83 -0
- package/dist/tools/_helpers.js.map +1 -1
- package/dist/tools/_layout-helpers.d.ts +43 -0
- package/dist/tools/_layout-helpers.js +159 -0
- package/dist/tools/_layout-helpers.js.map +1 -0
- package/dist/tools/create-document.d.ts +36 -0
- package/dist/tools/create-document.js +83 -0
- package/dist/tools/create-document.js.map +1 -0
- package/dist/tools/delete-document.d.ts +25 -0
- package/dist/tools/delete-document.js +49 -0
- package/dist/tools/delete-document.js.map +1 -0
- package/dist/tools/find-document.d.ts +33 -0
- package/dist/tools/find-document.js +97 -0
- package/dist/tools/find-document.js.map +1 -0
- package/dist/tools/find-global.d.ts +26 -0
- package/dist/tools/find-global.js +122 -0
- package/dist/tools/find-global.js.map +1 -0
- package/dist/tools/global-versions.d.ts +39 -0
- package/dist/tools/global-versions.js +132 -0
- package/dist/tools/global-versions.js.map +1 -0
- package/dist/tools/patch-global-layout.d.ts +31 -0
- package/dist/tools/patch-global-layout.js +127 -0
- package/dist/tools/patch-global-layout.js.map +1 -0
- package/dist/tools/patch-layout.d.ts +5 -8
- package/dist/tools/patch-layout.js +18 -100
- package/dist/tools/patch-layout.js.map +1 -1
- package/dist/tools/publish-draft.d.ts +5 -4
- package/dist/tools/publish-draft.js +6 -1
- package/dist/tools/publish-draft.js.map +1 -1
- package/dist/tools/publish-global-draft.d.ts +20 -0
- package/dist/tools/publish-global-draft.js +50 -0
- package/dist/tools/publish-global-draft.js.map +1 -0
- package/dist/tools/resolve-reference.d.ts +5 -4
- package/dist/tools/resolve-reference.js +4 -0
- package/dist/tools/resolve-reference.js.map +1 -1
- package/dist/tools/safe-delete.d.ts +5 -5
- package/dist/tools/safe-delete.js +20 -15
- package/dist/tools/safe-delete.js.map +1 -1
- package/dist/tools/schedule-publish.d.ts +5 -5
- package/dist/tools/schedule-publish.js +23 -19
- package/dist/tools/schedule-publish.js.map +1 -1
- package/dist/tools/search-content.d.ts +5 -9
- package/dist/tools/search-content.js +16 -12
- package/dist/tools/search-content.js.map +1 -1
- package/dist/tools/update-document.d.ts +5 -5
- package/dist/tools/update-document.js +10 -5
- package/dist/tools/update-document.js.map +1 -1
- package/dist/tools/update-global.d.ts +27 -0
- package/dist/tools/update-global.js +72 -0
- package/dist/tools/update-global.js.map +1 -0
- package/dist/tools/upload-media.d.ts +5 -4
- package/dist/tools/upload-media.js +6 -1
- package/dist/tools/upload-media.js.map +1 -1
- package/dist/tools/versions.d.ts +10 -9
- package/dist/tools/versions.js +15 -7
- package/dist/tools/versions.js.map +1 -1
- package/dist/types.d.ts +56 -3
- package/dist/types.js +13 -6
- package/dist/types.js.map +1 -1
- package/package.json +11 -4
package/dist/tools/versions.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { errorMessage, getDocDisplayName, jsonResponse, requireDraftCollection, stampMcpContext, textResponse } from './_helpers';
|
|
3
3
|
const DEFAULT_LIST_LIMIT = 10;
|
|
4
|
-
/**
|
|
5
|
-
* Lists recent saved versions of a draft document. Returns id, _status,
|
|
6
|
-
* updatedAt, and a compact display name per version so an LLM can pick one
|
|
7
|
-
* to restore.
|
|
4
|
+
/**
|
|
5
|
+
* Lists recent saved versions of a draft document. Returns id, _status,
|
|
6
|
+
* updatedAt, and a compact display name per version so an LLM can pick one
|
|
7
|
+
* to restore.
|
|
8
8
|
*/ export function createListVersionsTool(draftCollections) {
|
|
9
9
|
return {
|
|
10
10
|
name: 'listVersions',
|
|
11
|
+
routing: {
|
|
12
|
+
kind: 'collection',
|
|
13
|
+
action: 'read'
|
|
14
|
+
},
|
|
11
15
|
description: 'List recent saved versions of a document on a draft-enabled collection. ' + 'Use before restoreVersion to pick the right point in time. ' + `Draft-enabled collections: ${[
|
|
12
16
|
...draftCollections
|
|
13
17
|
].join(', ') || 'none'}`,
|
|
@@ -61,12 +65,16 @@ const DEFAULT_LIST_LIMIT = 10;
|
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Restoring a version creates a new version on top — the previous current
|
|
66
|
-
* state is preserved so the operation is itself reversible.
|
|
68
|
+
/**
|
|
69
|
+
* Restoring a version creates a new version on top — the previous current
|
|
70
|
+
* state is preserved so the operation is itself reversible.
|
|
67
71
|
*/ export function createRestoreVersionTool(draftCollections) {
|
|
68
72
|
return {
|
|
69
73
|
name: 'restoreVersion',
|
|
74
|
+
routing: {
|
|
75
|
+
kind: 'collection',
|
|
76
|
+
action: 'update'
|
|
77
|
+
},
|
|
70
78
|
description: 'Restore a document to a previously saved version. ' + 'Use listVersions first to find the version ID. ' + 'Restoring creates a new version on top, so the previous current state is also recoverable. ' + `Draft-enabled collections: ${[
|
|
71
79
|
...draftCollections
|
|
72
80
|
].join(', ') || 'none'}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tools/versions.ts"],"sourcesContent":["import { z } from 'zod'\nimport type { PayloadRequest } from 'payload'\nimport {\n errorMessage,\n getDocDisplayName,\n jsonResponse,\n requireDraftCollection,\n stampMcpContext,\n textResponse,\n} from './_helpers'\n\nconst DEFAULT_LIST_LIMIT = 10\n\n/**\n * Lists recent saved versions of a draft document. Returns id, _status,\n * updatedAt, and a compact display name per version so an LLM can pick one\n * to restore.\n */\nexport function createListVersionsTool(draftCollections: Set<string>) {\n return {\n name: 'listVersions',\n description:\n 'List recent saved versions of a document on a draft-enabled collection. ' +\n 'Use before restoreVersion to pick the right point in time. ' +\n `Draft-enabled collections: ${[...draftCollections].join(', ') || 'none'}`,\n parameters: {\n collection: z\n .string()\n .describe(\n `The collection slug. Must be one of: ${[...draftCollections].join(', ') || 'none'}`,\n ),\n documentId: z.string().describe('The ID of the document whose versions you want to list'),\n limit: z\n .number()\n .optional()\n .default(DEFAULT_LIST_LIMIT)\n .describe(`Maximum number of versions to return (default ${DEFAULT_LIST_LIMIT})`),\n },\n handler: async (\n args:
|
|
1
|
+
{"version":3,"sources":["../../src/tools/versions.ts"],"sourcesContent":["import { z } from 'zod'\r\nimport type { PayloadRequest } from 'payload'\r\nimport {\r\n errorMessage,\r\n getDocDisplayName,\r\n jsonResponse,\r\n requireDraftCollection,\r\n stampMcpContext,\r\n textResponse,\r\n} from './_helpers'\r\n\r\nconst DEFAULT_LIST_LIMIT = 10\r\n\r\n/**\r\n * Lists recent saved versions of a draft document. Returns id, _status,\r\n * updatedAt, and a compact display name per version so an LLM can pick one\r\n * to restore.\r\n */\r\nexport function createListVersionsTool(draftCollections: Set<string>) {\r\n return {\r\n name: 'listVersions',\r\n routing: { kind: 'collection', action: 'read' } as const,\r\n description:\r\n 'List recent saved versions of a document on a draft-enabled collection. ' +\r\n 'Use before restoreVersion to pick the right point in time. ' +\r\n `Draft-enabled collections: ${[...draftCollections].join(', ') || 'none'}`,\r\n parameters: {\r\n collection: z\r\n .string()\r\n .describe(\r\n `The collection slug. Must be one of: ${[...draftCollections].join(', ') || 'none'}`,\r\n ),\r\n documentId: z.string().describe('The ID of the document whose versions you want to list'),\r\n limit: z\r\n .number()\r\n .optional()\r\n .default(DEFAULT_LIST_LIMIT)\r\n .describe(`Maximum number of versions to return (default ${DEFAULT_LIST_LIMIT})`),\r\n },\r\n handler: async (\r\n args: Record<string, unknown>,\r\n req: PayloadRequest,\r\n _extra: unknown,\r\n ) => {\r\n const { collection, documentId, limit = DEFAULT_LIST_LIMIT } = args as {\r\n collection: string\r\n documentId: string\r\n limit?: number\r\n }\r\n\r\n const guard = requireDraftCollection(collection, draftCollections, 'versions')\r\n if (guard) return guard\r\n\r\n stampMcpContext(req)\r\n\r\n try {\r\n const result = await req.payload.findVersions({\r\n collection: collection as any,\r\n where: { parent: { equals: documentId } },\r\n sort: '-updatedAt',\r\n limit,\r\n req,\r\n overrideAccess: false,\r\n user: req.user,\r\n })\r\n\r\n const versions = result.docs.map((v: any) => {\r\n const snapshot = v.version || {}\r\n return {\r\n id: v.id,\r\n updatedAt: v.updatedAt,\r\n createdAt: v.createdAt,\r\n status: snapshot._status ?? 'unknown',\r\n displayName: getDocDisplayName(snapshot, `${collection}#${documentId}`),\r\n autosave: v.autosave === true,\r\n }\r\n })\r\n\r\n return jsonResponse({\r\n collection,\r\n documentId,\r\n totalDocs: result.totalDocs,\r\n returned: versions.length,\r\n versions,\r\n })\r\n } catch (error) {\r\n return textResponse(\r\n `Error listing versions for ${collection}#${documentId}: ${errorMessage(error)}`,\r\n )\r\n }\r\n },\r\n }\r\n}\r\n\r\n/**\r\n * Restoring a version creates a new version on top — the previous current\r\n * state is preserved so the operation is itself reversible.\r\n */\r\nexport function createRestoreVersionTool(draftCollections: Set<string>) {\r\n return {\r\n name: 'restoreVersion',\r\n routing: { kind: 'collection', action: 'update' } as const,\r\n description:\r\n 'Restore a document to a previously saved version. ' +\r\n 'Use listVersions first to find the version ID. ' +\r\n 'Restoring creates a new version on top, so the previous current state is also recoverable. ' +\r\n `Draft-enabled collections: ${[...draftCollections].join(', ') || 'none'}`,\r\n parameters: {\r\n collection: z\r\n .string()\r\n .describe(\r\n `The collection slug. Must be one of: ${[...draftCollections].join(', ') || 'none'}`,\r\n ),\r\n versionId: z\r\n .string()\r\n .describe('The version ID returned by listVersions (NOT the document ID)'),\r\n },\r\n handler: async (\r\n args: Record<string, unknown>,\r\n req: PayloadRequest,\r\n _extra: unknown,\r\n ) => {\r\n const { collection, versionId } = args as { collection: string; versionId: string }\r\n\r\n const guard = requireDraftCollection(collection, draftCollections, 'versions')\r\n if (guard) return guard\r\n\r\n stampMcpContext(req)\r\n\r\n try {\r\n const restored = await req.payload.restoreVersion({\r\n collection: collection as any,\r\n id: versionId,\r\n req,\r\n overrideAccess: false,\r\n user: req.user,\r\n })\r\n\r\n const restoredId = String((restored as any).id)\r\n const displayName = getDocDisplayName(restored, restoredId)\r\n\r\n return textResponse(\r\n `Restored ${collection} document \"${displayName}\" (ID: ${restoredId}) ` +\r\n `from version ${versionId}. The document is now in draft status — ` +\r\n `use publishDraft to make the restored content live.`,\r\n )\r\n } catch (error) {\r\n return textResponse(\r\n `Error restoring ${collection} from version ${versionId}: ${errorMessage(error)}`,\r\n )\r\n }\r\n },\r\n }\r\n}\r\n"],"names":["z","errorMessage","getDocDisplayName","jsonResponse","requireDraftCollection","stampMcpContext","textResponse","DEFAULT_LIST_LIMIT","createListVersionsTool","draftCollections","name","routing","kind","action","description","join","parameters","collection","string","describe","documentId","limit","number","optional","default","handler","args","req","_extra","guard","result","payload","findVersions","where","parent","equals","sort","overrideAccess","user","versions","docs","map","v","snapshot","version","id","updatedAt","createdAt","status","_status","displayName","autosave","totalDocs","returned","length","error","createRestoreVersionTool","versionId","restored","restoreVersion","restoredId","String"],"mappings":"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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -62,6 +62,32 @@ export interface ContentToolkitOptions {
|
|
|
62
62
|
/** Media collection slug (default: 'media') */
|
|
63
63
|
collectionSlug?: string;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* MCP transport / auth configuration. Mostly safe to leave unset;
|
|
67
|
+
* defaults to no-CORS server-to-server use only.
|
|
68
|
+
*/
|
|
69
|
+
auth?: {
|
|
70
|
+
/**
|
|
71
|
+
* Origins permitted on the `Origin` header. Empty / unset means
|
|
72
|
+
* server-to-server callers only (no browser-based MCP clients).
|
|
73
|
+
* `*` is intentionally not honoured.
|
|
74
|
+
*/
|
|
75
|
+
allowedOrigins?: string[];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Override API-key collection settings. Slug defaults to
|
|
79
|
+
* `payload-mcp-api-keys` for zero-touch upgrade compatibility with
|
|
80
|
+
* `@payloadcms/plugin-mcp` v0.3.x rows.
|
|
81
|
+
*/
|
|
82
|
+
apiKeyCollection?: {
|
|
83
|
+
slug?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Override the user collection that API keys link to. By default
|
|
86
|
+
* the toolkit reuses the same `userCollection` resolution as elsewhere
|
|
87
|
+
* (`options.userCollection`, then `incomingConfig.admin.user`).
|
|
88
|
+
*/
|
|
89
|
+
userCollection?: string;
|
|
90
|
+
};
|
|
65
91
|
}
|
|
66
92
|
/** A domain prompt that teaches the AI site-specific vocabulary */
|
|
67
93
|
export interface DomainPrompt {
|
|
@@ -101,6 +127,13 @@ export interface CollectionSchema {
|
|
|
101
127
|
}>;
|
|
102
128
|
searchableFields: string[];
|
|
103
129
|
}
|
|
130
|
+
/** Introspected global metadata. Globals are singletons — no relationships or searchable-fields graph. */
|
|
131
|
+
export interface GlobalSchema {
|
|
132
|
+
slug: string;
|
|
133
|
+
fields: FieldSchema[];
|
|
134
|
+
hasDrafts: boolean;
|
|
135
|
+
hasLivePreview: boolean;
|
|
136
|
+
}
|
|
104
137
|
/**
|
|
105
138
|
* One block in the catalog. Flat — no section/leaf distinction. Whether a
|
|
106
139
|
* block can nest other blocks is encoded in the `BlockNestingMap` keyed by
|
|
@@ -125,10 +158,10 @@ export interface BlockCatalog {
|
|
|
125
158
|
* us pre-classifying anything as a "section" or "leaf".
|
|
126
159
|
*/
|
|
127
160
|
export interface BlockNestingEdge {
|
|
128
|
-
/** Owner of the blocks field —
|
|
161
|
+
/** Owner of the blocks field — a collection slug, a block slug, or a global slug. */
|
|
129
162
|
owner: string;
|
|
130
|
-
/** Whether the owner is a collection or a
|
|
131
|
-
ownerType: 'collection' | 'block';
|
|
163
|
+
/** Whether the owner is a collection, a block, or a global */
|
|
164
|
+
ownerType: 'collection' | 'block' | 'global';
|
|
132
165
|
/** Dotted path to the blocks field within the owner (e.g. `layout`, `hero.content`) */
|
|
133
166
|
fieldPath: string;
|
|
134
167
|
/** Block slugs that this field accepts */
|
|
@@ -145,3 +178,23 @@ export interface RelationshipEdge {
|
|
|
145
178
|
toCollection: string | string[];
|
|
146
179
|
hasMany: boolean;
|
|
147
180
|
}
|
|
181
|
+
export type CollectionAction = 'read' | 'create' | 'update' | 'delete';
|
|
182
|
+
export type GlobalAction = 'read' | 'update';
|
|
183
|
+
export type ScopePreset = 'read-only' | 'editor' | 'admin';
|
|
184
|
+
/**
|
|
185
|
+
* Runtime scope shape consumed by `registry.assertScopeAllows`.
|
|
186
|
+
*
|
|
187
|
+
* - `collections` / `globals` are whitelists when present: a resource not
|
|
188
|
+
* listed there is denied for this key.
|
|
189
|
+
* - `tools.allow` / `tools.deny` are per-tool overrides that take precedence
|
|
190
|
+
* over the preset / resource maps.
|
|
191
|
+
*/
|
|
192
|
+
export interface KeyScopes {
|
|
193
|
+
preset?: ScopePreset;
|
|
194
|
+
collections?: Record<string, CollectionAction[]>;
|
|
195
|
+
globals?: Record<string, GlobalAction[]>;
|
|
196
|
+
tools?: {
|
|
197
|
+
allow?: string[];
|
|
198
|
+
deny?: string[];
|
|
199
|
+
};
|
|
200
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* payload-mcp-toolkit configuration.
|
|
3
|
-
*
|
|
4
|
-
* The plugin works with zero options — every field below is an escape hatch
|
|
5
|
-
* for the cases where Payload's own config doesn't carry enough signal.
|
|
6
|
-
*/ /**
|
|
1
|
+
/**
|
|
2
|
+
* payload-mcp-toolkit configuration.
|
|
3
|
+
*
|
|
4
|
+
* The plugin works with zero options — every field below is an escape hatch
|
|
5
|
+
* for the cases where Payload's own config doesn't carry enough signal.
|
|
6
|
+
*/ /**
|
|
7
|
+
* Runtime scope shape consumed by `registry.assertScopeAllows`.
|
|
8
|
+
*
|
|
9
|
+
* - `collections` / `globals` are whitelists when present: a resource not
|
|
10
|
+
* listed there is denied for this key.
|
|
11
|
+
* - `tools.allow` / `tools.deny` are per-tool overrides that take precedence
|
|
12
|
+
* over the preset / resource maps.
|
|
13
|
+
*/ export { };
|
|
7
14
|
|
|
8
15
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * payload-mcp-toolkit configuration.\n *\n * The plugin works with zero options — every field below is an escape hatch\n * for the cases where Payload's own config doesn't carry enough signal.\n */\nexport interface ContentToolkitOptions {\n /**\n * Preview URL behavior. The toolkit reads `collection.admin.livePreview.url`\n * (or `collection.admin.preview` as a fallback) when generating preview links\n * for draft documents. Provide this object only to override what Payload\n * already knows.\n */\n preview?: {\n /**\n * Absolute base URL prepended to relative preview paths. Defaults to\n * `incomingConfig.serverURL`, then `process.env.NEXT_PUBLIC_SERVER_URL`,\n * then `process.env.SITE_URL`. If none of those resolve and your preview\n * URL function returns a relative path, no preview URL is appended.\n */\n siteUrl?: string\n\n /**\n * Disable preview URL injection entirely.\n */\n disabled?: boolean\n }\n\n /**\n * Per-collection draft behavior overrides. The default behavior is inferred\n * from each collection's `versions.drafts` setting:\n * - drafts enabled → `'always-draft'` (raw `update` is locked; clients go\n * through `publishDraft` / `patchLayout` / `updateDocument` which preserve\n * draft semantics)\n * - drafts disabled → `'always-publish'`\n *\n * Override per slug only if you need to allow raw publish on a draftable\n * collection.\n */\n draftBehavior?: Record<string, 'always-draft' | 'always-publish'>\n\n /**\n * Override the auth collection used for API key linkage. By default the\n * toolkit scans `incomingConfig.collections` for the first collection with\n * `auth: true`, preferring one named `'users'`.\n */\n userCollection?: string\n\n /**\n * Hide collections or globals from the MCP surface. Useful for internal\n * bookkeeping collections that should not be exposed to AI clients.\n */\n exclude?: {\n collections?: string[]\n globals?: string[]\n }\n\n /**\n * Site-specific domain prompts that teach the AI business vocabulary.\n * Merged with the auto-generated prompts.\n */\n domainPrompts?: DomainPrompt[]\n\n /** Media upload configuration */\n mediaUpload?: {\n /** Maximum file size in bytes (default: 10MB) */\n maxFileSize?: number\n /** Media collection slug (default: 'media') */\n collectionSlug?: string\n }\n}\n\n/** A domain prompt that teaches the AI site-specific vocabulary */\nexport interface DomainPrompt {\n /** Unique name for the prompt */\n name: string\n /** Display title */\n title: string\n /** Description of what this prompt teaches */\n description: string\n /** The prompt content */\n content: string\n}\n\n/** Introspected field metadata */\nexport interface FieldSchema {\n name: string\n type: string\n required?: boolean\n hasMany?: boolean\n relationTo?: string | string[]\n options?: Array<{ label: string; value: string }>\n fields?: FieldSchema[]\n maxRows?: number\n}\n\n/** Introspected collection metadata */\nexport interface CollectionSchema {\n slug: string\n fields: FieldSchema[]\n hasDrafts: boolean\n hasLivePreview: boolean\n relationships: Array<{ fieldName: string; relationTo: string | string[]; hasMany: boolean }>\n searchableFields: string[]\n}\n\n/**\n * One block in the catalog. Flat — no section/leaf distinction. Whether a\n * block can nest other blocks is encoded in the `BlockNestingMap` keyed by\n * the path to its `blocks` field.\n */\nexport interface BlockSchema {\n slug: string\n fields: FieldSchema[]\n}\n\n/**\n * Flat catalog of every block referenced by the schema.\n */\nexport interface BlockCatalog {\n blocks: BlockSchema[]\n}\n\n/**\n * One entry per `blocks`-typed field anywhere in the schema.\n *\n * `path` is `<owner>.<dottedFieldPath>` where owner is the collection or\n * block slug that contains the field. Values list the slugs that field\n * accepts. The AI uses this to compose blocks at any nesting depth without\n * us pre-classifying anything as a \"section\" or \"leaf\".\n */\nexport interface BlockNestingEdge {\n /** Owner of the blocks field —
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\r\n * payload-mcp-toolkit configuration.\r\n *\r\n * The plugin works with zero options — every field below is an escape hatch\r\n * for the cases where Payload's own config doesn't carry enough signal.\r\n */\r\nexport interface ContentToolkitOptions {\r\n /**\r\n * Preview URL behavior. The toolkit reads `collection.admin.livePreview.url`\r\n * (or `collection.admin.preview` as a fallback) when generating preview links\r\n * for draft documents. Provide this object only to override what Payload\r\n * already knows.\r\n */\r\n preview?: {\r\n /**\r\n * Absolute base URL prepended to relative preview paths. Defaults to\r\n * `incomingConfig.serverURL`, then `process.env.NEXT_PUBLIC_SERVER_URL`,\r\n * then `process.env.SITE_URL`. If none of those resolve and your preview\r\n * URL function returns a relative path, no preview URL is appended.\r\n */\r\n siteUrl?: string\r\n\r\n /**\r\n * Disable preview URL injection entirely.\r\n */\r\n disabled?: boolean\r\n }\r\n\r\n /**\r\n * Per-collection draft behavior overrides. The default behavior is inferred\r\n * from each collection's `versions.drafts` setting:\r\n * - drafts enabled → `'always-draft'` (raw `update` is locked; clients go\r\n * through `publishDraft` / `patchLayout` / `updateDocument` which preserve\r\n * draft semantics)\r\n * - drafts disabled → `'always-publish'`\r\n *\r\n * Override per slug only if you need to allow raw publish on a draftable\r\n * collection.\r\n */\r\n draftBehavior?: Record<string, 'always-draft' | 'always-publish'>\r\n\r\n /**\r\n * Override the auth collection used for API key linkage. By default the\r\n * toolkit scans `incomingConfig.collections` for the first collection with\r\n * `auth: true`, preferring one named `'users'`.\r\n */\r\n userCollection?: string\r\n\r\n /**\r\n * Hide collections or globals from the MCP surface. Useful for internal\r\n * bookkeeping collections that should not be exposed to AI clients.\r\n */\r\n exclude?: {\r\n collections?: string[]\r\n globals?: string[]\r\n }\r\n\r\n /**\r\n * Site-specific domain prompts that teach the AI business vocabulary.\r\n * Merged with the auto-generated prompts.\r\n */\r\n domainPrompts?: DomainPrompt[]\r\n\r\n /** Media upload configuration */\r\n mediaUpload?: {\r\n /** Maximum file size in bytes (default: 10MB) */\r\n maxFileSize?: number\r\n /** Media collection slug (default: 'media') */\r\n collectionSlug?: string\r\n }\r\n\r\n /**\r\n * MCP transport / auth configuration. Mostly safe to leave unset;\r\n * defaults to no-CORS server-to-server use only.\r\n */\r\n auth?: {\r\n /**\r\n * Origins permitted on the `Origin` header. Empty / unset means\r\n * server-to-server callers only (no browser-based MCP clients).\r\n * `*` is intentionally not honoured.\r\n */\r\n allowedOrigins?: string[]\r\n }\r\n\r\n /**\r\n * Override API-key collection settings. Slug defaults to\r\n * `payload-mcp-api-keys` for zero-touch upgrade compatibility with\r\n * `@payloadcms/plugin-mcp` v0.3.x rows.\r\n */\r\n apiKeyCollection?: {\r\n slug?: string\r\n /**\r\n * Override the user collection that API keys link to. By default\r\n * the toolkit reuses the same `userCollection` resolution as elsewhere\r\n * (`options.userCollection`, then `incomingConfig.admin.user`).\r\n */\r\n userCollection?: string\r\n }\r\n}\r\n\r\n/** A domain prompt that teaches the AI site-specific vocabulary */\r\nexport interface DomainPrompt {\r\n /** Unique name for the prompt */\r\n name: string\r\n /** Display title */\r\n title: string\r\n /** Description of what this prompt teaches */\r\n description: string\r\n /** The prompt content */\r\n content: string\r\n}\r\n\r\n/** Introspected field metadata */\r\nexport interface FieldSchema {\r\n name: string\r\n type: string\r\n required?: boolean\r\n hasMany?: boolean\r\n relationTo?: string | string[]\r\n options?: Array<{ label: string; value: string }>\r\n fields?: FieldSchema[]\r\n maxRows?: number\r\n}\r\n\r\n/** Introspected collection metadata */\r\nexport interface CollectionSchema {\r\n slug: string\r\n fields: FieldSchema[]\r\n hasDrafts: boolean\r\n hasLivePreview: boolean\r\n relationships: Array<{ fieldName: string; relationTo: string | string[]; hasMany: boolean }>\r\n searchableFields: string[]\r\n}\r\n\r\n/** Introspected global metadata. Globals are singletons — no relationships or searchable-fields graph. */\r\nexport interface GlobalSchema {\r\n slug: string\r\n fields: FieldSchema[]\r\n hasDrafts: boolean\r\n hasLivePreview: boolean\r\n}\r\n\r\n/**\r\n * One block in the catalog. Flat — no section/leaf distinction. Whether a\r\n * block can nest other blocks is encoded in the `BlockNestingMap` keyed by\r\n * the path to its `blocks` field.\r\n */\r\nexport interface BlockSchema {\r\n slug: string\r\n fields: FieldSchema[]\r\n}\r\n\r\n/**\r\n * Flat catalog of every block referenced by the schema.\r\n */\r\nexport interface BlockCatalog {\r\n blocks: BlockSchema[]\r\n}\r\n\r\n/**\r\n * One entry per `blocks`-typed field anywhere in the schema.\r\n *\r\n * `path` is `<owner>.<dottedFieldPath>` where owner is the collection or\r\n * block slug that contains the field. Values list the slugs that field\r\n * accepts. The AI uses this to compose blocks at any nesting depth without\r\n * us pre-classifying anything as a \"section\" or \"leaf\".\r\n */\r\nexport interface BlockNestingEdge {\r\n /** Owner of the blocks field — a collection slug, a block slug, or a global slug. */\r\n owner: string\r\n /** Whether the owner is a collection, a block, or a global */\r\n ownerType: 'collection' | 'block' | 'global'\r\n /** Dotted path to the blocks field within the owner (e.g. `layout`, `hero.content`) */\r\n fieldPath: string\r\n /** Block slugs that this field accepts */\r\n acceptedBlockSlugs: string[]\r\n /** Optional row cap from the field config */\r\n maxRows?: number\r\n}\r\n\r\n/** Map of every blocks-field in the schema to the slugs it accepts */\r\nexport type BlockNestingMap = BlockNestingEdge[]\r\n\r\n/** Relationship edge in the collection graph */\r\nexport interface RelationshipEdge {\r\n fromCollection: string\r\n fieldName: string\r\n toCollection: string | string[]\r\n hasMany: boolean\r\n}\r\n\r\n// ─── Scope shapes ─────────────────────────────────────────────────────\r\n//\r\n// Canonical scope types live here so the auth strategy, registry, and admin\r\n// API-keys collection all import from the same surface. Globals support\r\n// only `read` / `update` — they don't have `create` / `delete` semantics.\r\n\r\nexport type CollectionAction = 'read' | 'create' | 'update' | 'delete'\r\nexport type GlobalAction = 'read' | 'update'\r\nexport type ScopePreset = 'read-only' | 'editor' | 'admin'\r\n\r\n/**\r\n * Runtime scope shape consumed by `registry.assertScopeAllows`.\r\n *\r\n * - `collections` / `globals` are whitelists when present: a resource not\r\n * listed there is denied for this key.\r\n * - `tools.allow` / `tools.deny` are per-tool overrides that take precedence\r\n * over the preset / resource maps.\r\n */\r\nexport interface KeyScopes {\r\n preset?: ScopePreset\r\n collections?: Record<string, CollectionAction[]>\r\n globals?: Record<string, GlobalAction[]>\r\n tools?: { allow?: string[]; deny?: string[] }\r\n}\r\n"],"names":[],"mappings":"AAAA;;;;;CAKC,GAoMD;;;;;;;CAOC,GACD,WAKC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-mcp-toolkit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Standalone schema-aware MCP plugin for Payload CMS v3 — owns the /api/mcp endpoint, scoped API keys, draft workflow, and AI-friendly tools so non-technical editors can manage content via AI chat.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "jon8800",
|
|
7
7
|
"homepage": "https://github.com/jon8800/payload-mcp-toolkit#readme",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"import": "./dist/index.js",
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./client": {
|
|
33
|
+
"import": "./dist/components/index.js",
|
|
34
|
+
"types": "./dist/components/index.d.ts",
|
|
35
|
+
"default": "./dist/components/index.js"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"main": "./dist/index.js",
|
|
@@ -36,15 +41,17 @@
|
|
|
36
41
|
"dist"
|
|
37
42
|
],
|
|
38
43
|
"sideEffects": false,
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
46
|
+
"mcp-handler": "^1.1.0"
|
|
47
|
+
},
|
|
39
48
|
"peerDependencies": {
|
|
40
|
-
"@payloadcms/plugin-mcp": "^3.0.0",
|
|
41
49
|
"payload": "^3.0.0",
|
|
42
50
|
"zod": "^3.0.0"
|
|
43
51
|
},
|
|
44
52
|
"devDependencies": {
|
|
45
53
|
"@payloadcms/db-sqlite": "3.82.1",
|
|
46
54
|
"@payloadcms/next": "3.82.1",
|
|
47
|
-
"@payloadcms/plugin-mcp": "3.82.1",
|
|
48
55
|
"@payloadcms/richtext-lexical": "3.82.1",
|
|
49
56
|
"@payloadcms/ui": "3.82.1",
|
|
50
57
|
"@swc/cli": "0.6.0",
|