@govcraft/payload-cms-mcp 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -0
- package/dist/config/index.d.ts +27 -0
- package/dist/config/index.js +31 -0
- package/dist/config/index.js.map +1 -0
- package/dist/controllers/mcp.controller.d.ts +7 -0
- package/dist/controllers/mcp.controller.js +328 -0
- package/dist/controllers/mcp.controller.js.map +1 -0
- package/dist/controllers/payload-mcp.controller.d.ts +4 -0
- package/dist/controllers/payload-mcp.controller.js +185 -0
- package/dist/controllers/payload-mcp.controller.js.map +1 -0
- package/dist/generate-tools.d.ts +1 -0
- package/dist/generate-tools.js +1417 -0
- package/dist/generate-tools.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/anthropic-mcp.d.ts +3 -0
- package/dist/mcp/anthropic-mcp.js +332 -0
- package/dist/mcp/anthropic-mcp.js.map +1 -0
- package/dist/mcp/generated/index.d.ts +44 -0
- package/dist/mcp/generated/index.js +45 -0
- package/dist/mcp/generated/index.js.map +1 -0
- package/dist/mcp/generated/payload-tools.d.ts +7 -0
- package/dist/mcp/generated/payload-tools.js +69 -0
- package/dist/mcp/generated/payload-tools.js.map +1 -0
- package/dist/mcp/generated/payload-tools.json +13024 -0
- package/dist/mcp/generated/tools/create.json +9138 -0
- package/dist/mcp/generated/tools/createAccess.json +10 -0
- package/dist/mcp/generated/tools/createAfterChangeHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterDeleteHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterErrorHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterForgotPasswordHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterLoginHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterLogoutHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterMeHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterOperationHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterReadHook.json +9 -0
- package/dist/mcp/generated/tools/createAfterRefreshHook.json +9 -0
- package/dist/mcp/generated/tools/createArrayField.json +90 -0
- package/dist/mcp/generated/tools/createBeforeChangeHook.json +9 -0
- package/dist/mcp/generated/tools/createBeforeDeleteHook.json +9 -0
- package/dist/mcp/generated/tools/createBeforeLoginHook.json +9 -0
- package/dist/mcp/generated/tools/createBeforeOperationHook.json +9 -0
- package/dist/mcp/generated/tools/createBeforeReadHook.json +9 -0
- package/dist/mcp/generated/tools/createBeforeValidateHook.json +9 -0
- package/dist/mcp/generated/tools/createBlocksField.json +79 -0
- package/dist/mcp/generated/tools/createCodeField.json +79 -0
- package/dist/mcp/generated/tools/createCollection.json +422 -0
- package/dist/mcp/generated/tools/createCollectionAdminOptions.json +2789 -0
- package/dist/mcp/generated/tools/createDateField.json +84 -0
- package/dist/mcp/generated/tools/createEmailField.json +87 -0
- package/dist/mcp/generated/tools/createField.json +31 -0
- package/dist/mcp/generated/tools/createGlobal.json +220 -0
- package/dist/mcp/generated/tools/createGroupField.json +79 -0
- package/dist/mcp/generated/tools/createJSONField.json +79 -0
- package/dist/mcp/generated/tools/createJoinField.json +79 -0
- package/dist/mcp/generated/tools/createMeHook.json +9 -0
- package/dist/mcp/generated/tools/createNumberField.json +31 -0
- package/dist/mcp/generated/tools/createPointField.json +79 -0
- package/dist/mcp/generated/tools/createPolymorphicRelationshipField.json +31 -0
- package/dist/mcp/generated/tools/createRadioField.json +94 -0
- package/dist/mcp/generated/tools/createRefreshHook.json +9 -0
- package/dist/mcp/generated/tools/createRelationshipField.json +31 -0
- package/dist/mcp/generated/tools/createRichTextField.json +79 -0
- package/dist/mcp/generated/tools/createSelectField.json +31 -0
- package/dist/mcp/generated/tools/createSingleRelationshipField.json +31 -0
- package/dist/mcp/generated/tools/createTextField.json +31 -0
- package/dist/mcp/generated/tools/createTextareaField.json +87 -0
- package/dist/mcp/generated/tools/createUploadField.json +31 -0
- package/dist/mcp/handler.d.ts +6 -0
- package/dist/mcp/handler.js +147 -0
- package/dist/mcp/handler.js.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.js +28 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/io/index.d.ts +2 -0
- package/dist/mcp/io/index.js +31 -0
- package/dist/mcp/io/index.js.map +1 -0
- package/dist/mcp/io/stdin.d.ts +2 -0
- package/dist/mcp/io/stdin.js +118 -0
- package/dist/mcp/io/stdin.js.map +1 -0
- package/dist/mcp/session.d.ts +16 -0
- package/dist/mcp/session.js +85 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/sse.d.ts +10 -0
- package/dist/mcp/sse.js +86 -0
- package/dist/mcp/sse.js.map +1 -0
- package/dist/mcp/tools/calculator.d.ts +2 -0
- package/dist/mcp/tools/calculator.js +68 -0
- package/dist/mcp/tools/calculator.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.js +6 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/list-tools.d.ts +2 -0
- package/dist/mcp/tools/list-tools.js +47 -0
- package/dist/mcp/tools/list-tools.js.map +1 -0
- package/dist/mcp/tools/payload-tools-loader.d.ts +2 -0
- package/dist/mcp/tools/payload-tools-loader.js +21 -0
- package/dist/mcp/tools/payload-tools-loader.js.map +1 -0
- package/dist/mcp/types.d.ts +69 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/middleware/errorHandler.d.ts +14 -0
- package/dist/middleware/errorHandler.js +25 -0
- package/dist/middleware/errorHandler.js.map +1 -0
- package/dist/middleware/notFoundHandler.d.ts +2 -0
- package/dist/middleware/notFoundHandler.js +8 -0
- package/dist/middleware/notFoundHandler.js.map +1 -0
- package/dist/routes/health.d.ts +2 -0
- package/dist/routes/health.js +18 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/mcp.d.ts +2 -0
- package/dist/routes/mcp.js +11 -0
- package/dist/routes/mcp.js.map +1 -0
- package/dist/routes/payload-mcp.routes.d.ts +3 -0
- package/dist/routes/payload-mcp.routes.js +8 -0
- package/dist/routes/payload-mcp.routes.js.map +1 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Payload CMS MCP
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server for Payload CMS 3.0 that auto-generates tools from Payload's TypeScript type definitions. This server runs in stdio-only mode, making it compatible with MCP clients like Cursor.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Auto-generates MCP tools from Payload CMS 3.0 TypeScript definitions
|
|
8
|
+
- Provides AI assistants with up-to-date code generation capabilities for Payload CMS
|
|
9
|
+
- Runs in stdio-only mode for integration with MCP clients (no HTTP endpoint)
|
|
10
|
+
- Supports all major Payload CMS features:
|
|
11
|
+
- Collections
|
|
12
|
+
- Globals
|
|
13
|
+
- Fields (all field types)
|
|
14
|
+
- Hooks
|
|
15
|
+
- Authentication
|
|
16
|
+
- Configuration
|
|
17
|
+
|
|
18
|
+
## How It Works
|
|
19
|
+
|
|
20
|
+
1. **Parse Type Definitions**: Uses ts-morph to analyze Payload's .d.ts files
|
|
21
|
+
2. **Generate Tools**: Converts types into MCP tools with parameters
|
|
22
|
+
3. **Register Tools**: Makes tools available via the MCP protocol
|
|
23
|
+
4. **Generate Code**: Returns properly formatted Payload CMS 3.0 code when tools are invoked
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
27
|
+
### Prerequisites
|
|
28
|
+
|
|
29
|
+
- Node.js (v18 or higher)
|
|
30
|
+
- pnpm (v8 or higher) or npm
|
|
31
|
+
|
|
32
|
+
### Installation
|
|
33
|
+
|
|
34
|
+
#### Option 1: From npm (recommended)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install globally
|
|
38
|
+
npm install -g @govcraft/payload-cms-mcp
|
|
39
|
+
|
|
40
|
+
# Or install locally in your project
|
|
41
|
+
npm install @govcraft/payload-cms-mcp
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
After installation, you can run the server using:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# If installed globally
|
|
48
|
+
payload-cms-mcp
|
|
49
|
+
|
|
50
|
+
# If installed locally
|
|
51
|
+
npx @govcraft/payload-cms-mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Option 2: From source
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Clone the repository
|
|
58
|
+
git clone https://github.com/Govcraft/payload-cms-mcp.git
|
|
59
|
+
cd payload-cms-mcp
|
|
60
|
+
|
|
61
|
+
# Install dependencies
|
|
62
|
+
pnpm install
|
|
63
|
+
|
|
64
|
+
# Start the server
|
|
65
|
+
pnpm start
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The installation process automatically:
|
|
69
|
+
1. Gets the latest version of Payload CMS
|
|
70
|
+
2. Generates MCP tools from Payload types
|
|
71
|
+
3. Builds the server ready for use
|
|
72
|
+
|
|
73
|
+
### Using with Cursor
|
|
74
|
+
|
|
75
|
+
To use the MCP server with Cursor or other MCP-compatible clients:
|
|
76
|
+
|
|
77
|
+
1. Run the server in stdio-only mode (default):
|
|
78
|
+
```bash
|
|
79
|
+
payload-cms-mcp
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. In Cursor, add the MCP server:
|
|
83
|
+
- Click on the MCP Servers button in the sidebar
|
|
84
|
+
- Click "Add new MCP server"
|
|
85
|
+
- Enter a name (e.g., "payload-cms-mcp")
|
|
86
|
+
- Select "sse" as the type
|
|
87
|
+
- Enter the path to your server executable (e.g., `/usr/local/bin/payload-cms-mcp`)
|
|
88
|
+
- Click "Save"
|
|
89
|
+
|
|
90
|
+
3. The MCP server should now be available in Cursor. You can use the tools to generate Payload CMS code.
|
|
91
|
+
|
|
92
|
+
## Available Tools
|
|
93
|
+
|
|
94
|
+
The following tools are auto-generated from Payload CMS 3.0 type definitions:
|
|
95
|
+
|
|
96
|
+
- **createCollection**: Creates a collection configuration
|
|
97
|
+
- **createGlobal**: Creates a global configuration
|
|
98
|
+
- **createTextField**: Creates a text field configuration
|
|
99
|
+
- **createEmailField**: Creates an email field configuration
|
|
100
|
+
- **createNumberField**: Creates a number field configuration
|
|
101
|
+
- **createDateField**: Creates a date field configuration
|
|
102
|
+
- **createRelationshipField**: Creates a relationship field
|
|
103
|
+
- **createArrayField**: Creates an array field configuration
|
|
104
|
+
- **createBlocksField**: Creates a blocks field configuration
|
|
105
|
+
- And many more field types...
|
|
106
|
+
|
|
107
|
+
Each tool accepts parameters based on the Payload CMS type definitions and returns properly formatted code.
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
### Regenerating Tools
|
|
112
|
+
|
|
113
|
+
If you update Payload CMS or want to regenerate the tools:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Update Payload
|
|
117
|
+
pnpm add payload@latest
|
|
118
|
+
|
|
119
|
+
# Regenerate tools
|
|
120
|
+
pnpm generate-tools
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Logging
|
|
124
|
+
|
|
125
|
+
The server uses Winston for logging. Logs are written to files in the `logs` directory with the following files:
|
|
126
|
+
|
|
127
|
+
- `combined.log`: All logs (info level and above)
|
|
128
|
+
- `error.log`: Error logs only
|
|
129
|
+
- `exceptions.log`: Uncaught exceptions
|
|
130
|
+
- `rejections.log`: Unhandled promise rejections
|
|
131
|
+
|
|
132
|
+
The server uses npm logging levels (from highest to lowest priority):
|
|
133
|
+
```
|
|
134
|
+
error: 0,
|
|
135
|
+
warn: 1,
|
|
136
|
+
info: 2,
|
|
137
|
+
http: 3,
|
|
138
|
+
verbose: 4,
|
|
139
|
+
debug: 5,
|
|
140
|
+
silly: 6
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
By default, the log level is set to `info`, which means only logs with level `info`, `warn`, and `error` will be recorded. To see more detailed logs:
|
|
144
|
+
|
|
145
|
+
- Set to `verbose` to see tool registration details
|
|
146
|
+
- Set to `debug` for more detailed debugging information
|
|
147
|
+
|
|
148
|
+
You can change the log level by setting the `LOG_LEVEL` environment variable:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Run with verbose logging
|
|
152
|
+
LOG_LEVEL=verbose payload-cms-mcp
|
|
153
|
+
|
|
154
|
+
# Or set in .env file
|
|
155
|
+
# LOG_LEVEL=verbose
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
161
|
+
|
|
162
|
+
## Author
|
|
163
|
+
|
|
164
|
+
[Govcraft](https://github.com/Govcraft)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ServerConfig {
|
|
2
|
+
port: number;
|
|
3
|
+
env: string;
|
|
4
|
+
}
|
|
5
|
+
interface ApiConfig {
|
|
6
|
+
prefix: string;
|
|
7
|
+
}
|
|
8
|
+
interface CorsConfig {
|
|
9
|
+
origin: string | string[];
|
|
10
|
+
}
|
|
11
|
+
interface LogConfig {
|
|
12
|
+
level: string;
|
|
13
|
+
dir: string;
|
|
14
|
+
}
|
|
15
|
+
interface MCPConfig {
|
|
16
|
+
enableStdio: boolean;
|
|
17
|
+
stdioOnly: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface Config {
|
|
20
|
+
server: ServerConfig;
|
|
21
|
+
api: ApiConfig;
|
|
22
|
+
cors: CorsConfig;
|
|
23
|
+
log: LogConfig;
|
|
24
|
+
mcp: MCPConfig;
|
|
25
|
+
}
|
|
26
|
+
export declare const config: Config;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
dotenv.config();
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
const rootDir = path.resolve(__dirname, '../../');
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const enableStdio = args.includes('--stdio') || args.includes('-s');
|
|
10
|
+
const stdioOnly = args.includes('--stdio-only') || args.includes('-S');
|
|
11
|
+
export const config = {
|
|
12
|
+
server: {
|
|
13
|
+
port: parseInt(process.env.PORT || '3000', 10),
|
|
14
|
+
env: process.env.NODE_ENV || 'development',
|
|
15
|
+
},
|
|
16
|
+
api: {
|
|
17
|
+
prefix: process.env.API_PREFIX || '/api/v1',
|
|
18
|
+
},
|
|
19
|
+
cors: {
|
|
20
|
+
origin: process.env.CORS_ORIGIN || '*',
|
|
21
|
+
},
|
|
22
|
+
log: {
|
|
23
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
24
|
+
dir: path.join(rootDir, 'logs'),
|
|
25
|
+
},
|
|
26
|
+
mcp: {
|
|
27
|
+
enableStdio: enableStdio || process.env.ENABLE_STDIO === 'true',
|
|
28
|
+
stdioOnly: stdioOnly || process.env.STDIO_ONLY === 'true'
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAkClD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACpE,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,CAAC;QAC9C,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;KAC3C;IACD,GAAG,EAAE;QACH,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,SAAS;KAC5C;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG;KACvC;IACD,GAAG,EAAE;QACH,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;QACtC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;KAChC;IACD,GAAG,EAAE;QACH,WAAW,EAAE,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,MAAM;QAC/D,SAAS,EAAE,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM;KAC1D;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
export declare function handleSSEConnection(req: Request, res: Response): Promise<void>;
|
|
3
|
+
export declare function handleSSERequest(req: Request, res: Response): Promise<void>;
|
|
4
|
+
export declare function handleMCPRequest(req: Request, res: Response): Promise<void>;
|
|
5
|
+
export declare function handleToolCall(req: Request, res: Response): Promise<void>;
|
|
6
|
+
export declare function getTools(_req: Request, res: Response): void;
|
|
7
|
+
export declare function handleSSEToolCall(req: Request, res: Response): Promise<void>;
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { processRequest, executeTool, getAvailableTools, validateMessage } from '../mcp/handler.js';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
import { initializeSSE, sendMessageToClient, hasActiveConnection } from '../mcp/sse.js';
|
|
5
|
+
import { sessionManager } from '../mcp/session.js';
|
|
6
|
+
export async function handleSSEConnection(req, res) {
|
|
7
|
+
try {
|
|
8
|
+
let sessionId = req.query.sessionId;
|
|
9
|
+
if (!sessionId) {
|
|
10
|
+
const session = sessionManager.createSession({});
|
|
11
|
+
sessionId = session.id;
|
|
12
|
+
}
|
|
13
|
+
else if (!sessionManager.getSession(sessionId)) {
|
|
14
|
+
const session = sessionManager.createSession({});
|
|
15
|
+
sessionId = session.id;
|
|
16
|
+
}
|
|
17
|
+
initializeSSE(res, sessionId);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
logger.error('Error establishing SSE connection', { error });
|
|
21
|
+
res.status(500).json({
|
|
22
|
+
id: uuidv4(),
|
|
23
|
+
type: 'error',
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
payload: {
|
|
26
|
+
code: 'server_error',
|
|
27
|
+
message: 'Failed to establish SSE connection',
|
|
28
|
+
details: {
|
|
29
|
+
error: error instanceof Error ? error.message : String(error)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function handleSSERequest(req, res) {
|
|
36
|
+
try {
|
|
37
|
+
const { body } = req;
|
|
38
|
+
const sessionId = req.headers['x-mcp-session-id'];
|
|
39
|
+
if (!sessionId) {
|
|
40
|
+
res.status(400).json({
|
|
41
|
+
id: uuidv4(),
|
|
42
|
+
type: 'error',
|
|
43
|
+
timestamp: new Date().toISOString(),
|
|
44
|
+
payload: {
|
|
45
|
+
code: 'missing_session',
|
|
46
|
+
message: 'Session ID is required for SSE requests'
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!hasActiveConnection(sessionId)) {
|
|
52
|
+
res.status(400).json({
|
|
53
|
+
id: uuidv4(),
|
|
54
|
+
type: 'error',
|
|
55
|
+
timestamp: new Date().toISOString(),
|
|
56
|
+
payload: {
|
|
57
|
+
code: 'no_sse_connection',
|
|
58
|
+
message: 'No active SSE connection for this session'
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!validateMessage(body)) {
|
|
64
|
+
res.status(400).json({
|
|
65
|
+
id: uuidv4(),
|
|
66
|
+
type: 'error',
|
|
67
|
+
timestamp: new Date().toISOString(),
|
|
68
|
+
payload: {
|
|
69
|
+
code: 'invalid_request',
|
|
70
|
+
message: 'Invalid MCP request format'
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const mcpRequest = body;
|
|
76
|
+
res.status(202).json({
|
|
77
|
+
id: uuidv4(),
|
|
78
|
+
type: 'status',
|
|
79
|
+
timestamp: new Date().toISOString(),
|
|
80
|
+
payload: {
|
|
81
|
+
status: 'processing',
|
|
82
|
+
message: 'Request accepted and being processed'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
processRequest(mcpRequest, sessionId)
|
|
86
|
+
.then(response => {
|
|
87
|
+
sendMessageToClient(sessionId, response);
|
|
88
|
+
})
|
|
89
|
+
.catch(error => {
|
|
90
|
+
logger.error('Error processing SSE request', { error });
|
|
91
|
+
const errorResponse = {
|
|
92
|
+
id: uuidv4(),
|
|
93
|
+
type: 'error',
|
|
94
|
+
timestamp: new Date().toISOString(),
|
|
95
|
+
payload: {
|
|
96
|
+
code: 'processing_error',
|
|
97
|
+
message: 'Error processing request',
|
|
98
|
+
details: {
|
|
99
|
+
error: error instanceof Error ? error.message : String(error)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
sendMessageToClient(sessionId, errorResponse);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
logger.error('Error handling SSE request', { error });
|
|
108
|
+
res.status(500).json({
|
|
109
|
+
id: uuidv4(),
|
|
110
|
+
type: 'error',
|
|
111
|
+
timestamp: new Date().toISOString(),
|
|
112
|
+
payload: {
|
|
113
|
+
code: 'server_error',
|
|
114
|
+
message: 'Internal server error',
|
|
115
|
+
details: {
|
|
116
|
+
error: error instanceof Error ? error.message : String(error)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export async function handleMCPRequest(req, res) {
|
|
123
|
+
try {
|
|
124
|
+
const { body } = req;
|
|
125
|
+
const sessionId = req.headers['x-mcp-session-id'];
|
|
126
|
+
if (!validateMessage(body)) {
|
|
127
|
+
res.status(400).json({
|
|
128
|
+
id: uuidv4(),
|
|
129
|
+
type: 'error',
|
|
130
|
+
timestamp: new Date().toISOString(),
|
|
131
|
+
payload: {
|
|
132
|
+
code: 'invalid_request',
|
|
133
|
+
message: 'Invalid MCP request format'
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const mcpRequest = body;
|
|
139
|
+
const response = await processRequest(mcpRequest, sessionId);
|
|
140
|
+
if (!sessionId && response.type === 'response' && response.payload.metadata?.sessionId) {
|
|
141
|
+
res.setHeader('X-MCP-Session-ID', response.payload.metadata.sessionId);
|
|
142
|
+
}
|
|
143
|
+
res.status(200).json(response);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
logger.error('Error handling MCP request', { error });
|
|
147
|
+
res.status(500).json({
|
|
148
|
+
id: uuidv4(),
|
|
149
|
+
type: 'error',
|
|
150
|
+
timestamp: new Date().toISOString(),
|
|
151
|
+
payload: {
|
|
152
|
+
code: 'server_error',
|
|
153
|
+
message: 'Internal server error',
|
|
154
|
+
details: {
|
|
155
|
+
error: error instanceof Error ? error.message : String(error)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export async function handleToolCall(req, res) {
|
|
162
|
+
try {
|
|
163
|
+
const { body } = req;
|
|
164
|
+
const sessionId = req.headers['x-mcp-session-id'];
|
|
165
|
+
if (!sessionId) {
|
|
166
|
+
res.status(400).json({
|
|
167
|
+
id: uuidv4(),
|
|
168
|
+
type: 'error',
|
|
169
|
+
timestamp: new Date().toISOString(),
|
|
170
|
+
payload: {
|
|
171
|
+
code: 'missing_session',
|
|
172
|
+
message: 'Session ID is required for tool calls'
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (!validateMessage(body) || body.type !== 'tool_call') {
|
|
178
|
+
res.status(400).json({
|
|
179
|
+
id: uuidv4(),
|
|
180
|
+
type: 'error',
|
|
181
|
+
timestamp: new Date().toISOString(),
|
|
182
|
+
payload: {
|
|
183
|
+
code: 'invalid_tool_call',
|
|
184
|
+
message: 'Invalid tool call format'
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const toolCall = body;
|
|
190
|
+
const toolResult = await executeTool(toolCall, sessionId);
|
|
191
|
+
res.status(200).json(toolResult);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
logger.error('Error handling tool call', { error });
|
|
195
|
+
res.status(500).json({
|
|
196
|
+
id: uuidv4(),
|
|
197
|
+
type: 'error',
|
|
198
|
+
timestamp: new Date().toISOString(),
|
|
199
|
+
payload: {
|
|
200
|
+
code: 'server_error',
|
|
201
|
+
message: 'Internal server error',
|
|
202
|
+
details: {
|
|
203
|
+
error: error instanceof Error ? error.message : String(error)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export function getTools(_req, res) {
|
|
210
|
+
try {
|
|
211
|
+
const tools = getAvailableTools();
|
|
212
|
+
res.status(200).json({
|
|
213
|
+
id: uuidv4(),
|
|
214
|
+
type: 'tools_list',
|
|
215
|
+
timestamp: new Date().toISOString(),
|
|
216
|
+
payload: {
|
|
217
|
+
tools: tools.map(tool => ({
|
|
218
|
+
name: tool.name,
|
|
219
|
+
description: tool.description,
|
|
220
|
+
parameters: tool.parameters
|
|
221
|
+
}))
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
logger.error('Error getting tools list', { error });
|
|
227
|
+
res.status(500).json({
|
|
228
|
+
id: uuidv4(),
|
|
229
|
+
type: 'error',
|
|
230
|
+
timestamp: new Date().toISOString(),
|
|
231
|
+
payload: {
|
|
232
|
+
code: 'server_error',
|
|
233
|
+
message: 'Internal server error',
|
|
234
|
+
details: {
|
|
235
|
+
error: error instanceof Error ? error.message : String(error)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
export async function handleSSEToolCall(req, res) {
|
|
242
|
+
try {
|
|
243
|
+
const { body } = req;
|
|
244
|
+
const sessionId = req.headers['x-mcp-session-id'];
|
|
245
|
+
if (!sessionId) {
|
|
246
|
+
res.status(400).json({
|
|
247
|
+
id: uuidv4(),
|
|
248
|
+
type: 'error',
|
|
249
|
+
timestamp: new Date().toISOString(),
|
|
250
|
+
payload: {
|
|
251
|
+
code: 'missing_session',
|
|
252
|
+
message: 'Session ID is required for tool calls'
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (!hasActiveConnection(sessionId)) {
|
|
258
|
+
res.status(400).json({
|
|
259
|
+
id: uuidv4(),
|
|
260
|
+
type: 'error',
|
|
261
|
+
timestamp: new Date().toISOString(),
|
|
262
|
+
payload: {
|
|
263
|
+
code: 'no_sse_connection',
|
|
264
|
+
message: 'No active SSE connection for this session'
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (!validateMessage(body) || body.type !== 'tool_call') {
|
|
270
|
+
res.status(400).json({
|
|
271
|
+
id: uuidv4(),
|
|
272
|
+
type: 'error',
|
|
273
|
+
timestamp: new Date().toISOString(),
|
|
274
|
+
payload: {
|
|
275
|
+
code: 'invalid_tool_call',
|
|
276
|
+
message: 'Invalid tool call format'
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const toolCall = body;
|
|
282
|
+
res.status(202).json({
|
|
283
|
+
id: uuidv4(),
|
|
284
|
+
type: 'status',
|
|
285
|
+
timestamp: new Date().toISOString(),
|
|
286
|
+
payload: {
|
|
287
|
+
status: 'processing',
|
|
288
|
+
message: 'Tool call accepted and being processed'
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
executeTool(toolCall, sessionId)
|
|
292
|
+
.then(toolResult => {
|
|
293
|
+
sendMessageToClient(sessionId, toolResult);
|
|
294
|
+
})
|
|
295
|
+
.catch(error => {
|
|
296
|
+
logger.error('Error executing tool via SSE', { error });
|
|
297
|
+
const errorResponse = {
|
|
298
|
+
id: uuidv4(),
|
|
299
|
+
type: 'error',
|
|
300
|
+
timestamp: new Date().toISOString(),
|
|
301
|
+
payload: {
|
|
302
|
+
code: 'tool_execution_error',
|
|
303
|
+
message: 'Error executing tool',
|
|
304
|
+
details: {
|
|
305
|
+
error: error instanceof Error ? error.message : String(error)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
sendMessageToClient(sessionId, errorResponse);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
logger.error('Error handling SSE tool call', { error });
|
|
314
|
+
res.status(500).json({
|
|
315
|
+
id: uuidv4(),
|
|
316
|
+
type: 'error',
|
|
317
|
+
timestamp: new Date().toISOString(),
|
|
318
|
+
payload: {
|
|
319
|
+
code: 'server_error',
|
|
320
|
+
message: 'Internal server error',
|
|
321
|
+
details: {
|
|
322
|
+
error: error instanceof Error ? error.message : String(error)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=mcp.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.controller.js","sourceRoot":"","sources":["../../src/controllers/mcp.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAY,EAAE,GAAa;IACnE,IAAI,CAAC;QAEH,IAAI,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,SAAmB,CAAC;QAE9C,IAAI,CAAC,SAAS,EAAE,CAAC;YAEf,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YACjD,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;QACzB,CAAC;aAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAKjD,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,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AC,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAExD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,EAAE,EAAE,MAAM,EAAE;YACZ,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,OAAO,EAAE;gBACP,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,uBAAuB;gBAChC,OAAO,EAAE;oBACP,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D;aACF;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
export declare function handlePayloadMCPSSEConnection(req: Request, res: Response): Promise<void>;
|
|
3
|
+
export declare function handlePayloadMCPSSERequest(req: Request, res: Response): Promise<void>;
|
|
4
|
+
export declare function handlePayloadMCPRequest(req: Request, res: Response): Promise<void>;
|