@payloadcms/plugin-mcp 3.83.0-canary.2 → 3.83.0-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collections/createApiKeysCollection.d.ts +3 -3
- package/dist/collections/createApiKeysCollection.d.ts.map +1 -1
- package/dist/collections/createApiKeysCollection.js.map +1 -1
- package/dist/endpoints/mcp.d.ts +2 -2
- package/dist/endpoints/mcp.d.ts.map +1 -1
- package/dist/endpoints/mcp.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/getMcpHandler.d.ts +2 -2
- package/dist/mcp/getMcpHandler.d.ts.map +1 -1
- package/dist/mcp/getMcpHandler.js.map +1 -1
- package/dist/mcp/tools/global/find.d.ts +2 -2
- package/dist/mcp/tools/global/find.d.ts.map +1 -1
- package/dist/mcp/tools/global/find.js.map +1 -1
- package/dist/mcp/tools/global/update.d.ts +2 -2
- package/dist/mcp/tools/global/update.d.ts.map +1 -1
- package/dist/mcp/tools/global/update.js.map +1 -1
- package/dist/mcp/tools/resource/create.d.ts +2 -2
- package/dist/mcp/tools/resource/create.d.ts.map +1 -1
- package/dist/mcp/tools/resource/create.js.map +1 -1
- package/dist/mcp/tools/resource/delete.d.ts +2 -2
- package/dist/mcp/tools/resource/delete.d.ts.map +1 -1
- package/dist/mcp/tools/resource/delete.js.map +1 -1
- package/dist/mcp/tools/resource/find.d.ts +2 -2
- package/dist/mcp/tools/resource/find.d.ts.map +1 -1
- package/dist/mcp/tools/resource/find.js.map +1 -1
- package/dist/mcp/tools/resource/update.d.ts +2 -2
- package/dist/mcp/tools/resource/update.d.ts.map +1 -1
- package/dist/mcp/tools/resource/update.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/collections/createApiKeysCollection.ts +5 -5
- package/src/endpoints/mcp.ts +2 -2
- package/src/index.ts +13 -7
- package/src/mcp/getMcpHandler.ts +6 -6
- package/src/mcp/tools/global/find.ts +2 -2
- package/src/mcp/tools/global/update.ts +2 -2
- package/src/mcp/tools/resource/create.ts +2 -2
- package/src/mcp/tools/resource/delete.ts +2 -2
- package/src/mcp/tools/resource/find.ts +2 -2
- package/src/mcp/tools/resource/update.ts +2 -2
- package/src/types.ts +2 -2
package/src/mcp/getMcpHandler.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { createMcpHandler } from 'mcp-handler'
|
|
|
4
4
|
import { join } from 'path'
|
|
5
5
|
import { APIError, configToJSONSchema, type PayloadRequest, type TypedUser } from 'payload'
|
|
6
6
|
|
|
7
|
-
import type { MCPAccessSettings,
|
|
7
|
+
import type { MCPAccessSettings, MCPPluginConfig } from '../types.js'
|
|
8
8
|
|
|
9
9
|
import { toCamelCase } from '../utils/camelCase.js'
|
|
10
10
|
import { getEnabledSlugs } from '../utils/getEnabledSlugs.js'
|
|
@@ -44,7 +44,7 @@ import { runJobTool } from './tools/job/run.js'
|
|
|
44
44
|
import { updateJobTool } from './tools/job/update.js'
|
|
45
45
|
|
|
46
46
|
export const getMCPHandler = (
|
|
47
|
-
pluginOptions:
|
|
47
|
+
pluginOptions: MCPPluginConfig,
|
|
48
48
|
mcpAccessSettings: MCPAccessSettings,
|
|
49
49
|
req: PayloadRequest,
|
|
50
50
|
) => {
|
|
@@ -63,15 +63,15 @@ export const getMCPHandler = (
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
const payloadToolHandler = (
|
|
66
|
-
handler: NonNullable<NonNullable<
|
|
66
|
+
handler: NonNullable<NonNullable<MCPPluginConfig['mcp']>['tools']>[number]['handler'],
|
|
67
67
|
) => wrapHandler(handler)
|
|
68
68
|
|
|
69
69
|
const payloadPromptHandler = (
|
|
70
|
-
handler: NonNullable<NonNullable<
|
|
70
|
+
handler: NonNullable<NonNullable<MCPPluginConfig['mcp']>['prompts']>[number]['handler'],
|
|
71
71
|
) => wrapHandler(handler)
|
|
72
72
|
|
|
73
73
|
const payloadResourceHandler = (
|
|
74
|
-
handler: NonNullable<NonNullable<
|
|
74
|
+
handler: NonNullable<NonNullable<MCPPluginConfig['mcp']>['resources']>[number]['handler'],
|
|
75
75
|
) => wrapHandler(handler)
|
|
76
76
|
|
|
77
77
|
// User
|
|
@@ -88,7 +88,7 @@ export const getMCPHandler = (
|
|
|
88
88
|
|
|
89
89
|
// Experimental MCP Tool Requirements
|
|
90
90
|
const isDevelopment = process.env.NODE_ENV === 'development'
|
|
91
|
-
const experimentalTools: NonNullable<
|
|
91
|
+
const experimentalTools: NonNullable<MCPPluginConfig['experimental']>['tools'] =
|
|
92
92
|
pluginOptions?.experimental?.tools || {}
|
|
93
93
|
const collectionsPluginConfig = pluginOptions.collections || {}
|
|
94
94
|
const globalsPluginConfig = pluginOptions.globals || {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
2
|
import type { PayloadRequest, SelectType, TypedUser } from 'payload'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { MCPPluginConfig } from '../../../types.js'
|
|
5
5
|
|
|
6
6
|
import { toCamelCase } from '../../../utils/camelCase.js'
|
|
7
7
|
import { toolSchemas } from '../schemas.js'
|
|
@@ -12,7 +12,7 @@ export const findGlobalTool = (
|
|
|
12
12
|
user: TypedUser,
|
|
13
13
|
verboseLogs: boolean,
|
|
14
14
|
globalSlug: string,
|
|
15
|
-
globals:
|
|
15
|
+
globals: MCPPluginConfig['globals'],
|
|
16
16
|
) => {
|
|
17
17
|
const tool = async (
|
|
18
18
|
depth: number = 0,
|
|
@@ -4,7 +4,7 @@ import type { PayloadRequest, SelectType, TypedUser } from 'payload'
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { MCPPluginConfig } from '../../../types.js'
|
|
8
8
|
|
|
9
9
|
import { toCamelCase } from '../../../utils/camelCase.js'
|
|
10
10
|
import {
|
|
@@ -20,7 +20,7 @@ export const updateGlobalTool = (
|
|
|
20
20
|
user: TypedUser,
|
|
21
21
|
verboseLogs: boolean,
|
|
22
22
|
globalSlug: string,
|
|
23
|
-
globals:
|
|
23
|
+
globals: MCPPluginConfig['globals'],
|
|
24
24
|
schema: JSONSchema4,
|
|
25
25
|
) => {
|
|
26
26
|
const tool = async (
|
|
@@ -4,7 +4,7 @@ import type { PayloadRequest, SelectType, TypedUser } from 'payload'
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { MCPPluginConfig } from '../../../types.js'
|
|
8
8
|
|
|
9
9
|
import { toCamelCase } from '../../../utils/camelCase.js'
|
|
10
10
|
import {
|
|
@@ -20,7 +20,7 @@ export const createResourceTool = (
|
|
|
20
20
|
user: TypedUser,
|
|
21
21
|
verboseLogs: boolean,
|
|
22
22
|
collectionSlug: string,
|
|
23
|
-
collections:
|
|
23
|
+
collections: MCPPluginConfig['collections'],
|
|
24
24
|
schema: JSONSchema4,
|
|
25
25
|
) => {
|
|
26
26
|
const tool = async (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
2
|
import type { PayloadRequest, TypedUser } from 'payload'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { MCPPluginConfig } from '../../../types.js'
|
|
5
5
|
|
|
6
6
|
import { toCamelCase } from '../../../utils/camelCase.js'
|
|
7
7
|
import { toolSchemas } from '../schemas.js'
|
|
@@ -12,7 +12,7 @@ export const deleteResourceTool = (
|
|
|
12
12
|
user: TypedUser,
|
|
13
13
|
verboseLogs: boolean,
|
|
14
14
|
collectionSlug: string,
|
|
15
|
-
collections:
|
|
15
|
+
collections: MCPPluginConfig['collections'],
|
|
16
16
|
) => {
|
|
17
17
|
const tool = async (
|
|
18
18
|
id?: number | string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
2
|
import type { PayloadRequest, SelectType, TypedUser } from 'payload'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { MCPPluginConfig } from '../../../types.js'
|
|
5
5
|
|
|
6
6
|
import { toCamelCase } from '../../../utils/camelCase.js'
|
|
7
7
|
import { toolSchemas } from '../schemas.js'
|
|
@@ -12,7 +12,7 @@ export const findResourceTool = (
|
|
|
12
12
|
user: TypedUser,
|
|
13
13
|
verboseLogs: boolean,
|
|
14
14
|
collectionSlug: string,
|
|
15
|
-
collections:
|
|
15
|
+
collections: MCPPluginConfig['collections'],
|
|
16
16
|
) => {
|
|
17
17
|
const tool = async (
|
|
18
18
|
id?: number | string,
|
|
@@ -4,7 +4,7 @@ import type { PayloadRequest, SelectType, TypedUser } from 'payload'
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { MCPPluginConfig } from '../../../types.js'
|
|
8
8
|
|
|
9
9
|
import { toCamelCase } from '../../../utils/camelCase.js'
|
|
10
10
|
import {
|
|
@@ -20,7 +20,7 @@ export const updateResourceTool = (
|
|
|
20
20
|
user: TypedUser,
|
|
21
21
|
verboseLogs: boolean,
|
|
22
22
|
collectionSlug: string,
|
|
23
|
-
collections:
|
|
23
|
+
collections: MCPPluginConfig['collections'],
|
|
24
24
|
schema: JSONSchema4,
|
|
25
25
|
) => {
|
|
26
26
|
const tool = async (
|
package/src/types.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { z } from 'zod'
|
|
|
9
9
|
|
|
10
10
|
import { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type MCPPluginConfig = {
|
|
13
13
|
/**
|
|
14
14
|
* Set the collections that should be available as resources via MCP.
|
|
15
15
|
*/
|
|
@@ -425,7 +425,7 @@ export type MCPAccessSettings = {
|
|
|
425
425
|
user: TypedUser
|
|
426
426
|
} & Record<string, unknown>
|
|
427
427
|
|
|
428
|
-
export type EntityConfig =
|
|
428
|
+
export type EntityConfig = MCPPluginConfig['collections'] | MCPPluginConfig['globals']
|
|
429
429
|
|
|
430
430
|
export type FieldDefinition = {
|
|
431
431
|
description?: string
|