@node2flow/n8n-management-mcp 1.0.5
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 +21 -0
- package/README.md +187 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/index.js.map +1 -0
- package/dist/n8n-client.d.ts +45 -0
- package/dist/n8n-client.d.ts.map +1 -0
- package/dist/n8n-client.js +172 -0
- package/dist/n8n-client.js.map +1 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +133 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +385 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +316 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/worker.d.ts +11 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +75 -0
- package/dist/worker.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Node2Flow
|
|
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,187 @@
|
|
|
1
|
+
# n8n Management MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@node2flow/n8n-management-mcp)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
[ภาษาไทย](docs/README.th.md)
|
|
7
|
+
|
|
8
|
+
MCP (Model Context Protocol) server for connecting AI assistants to your n8n instance. Manage workflows, executions, credentials, tags, variables, and users through 31 tools.
|
|
9
|
+
|
|
10
|
+
Works with Claude Desktop, Cursor, VS Code, and any MCP client.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Claude Desktop
|
|
17
|
+
|
|
18
|
+
Add to `claude_desktop_config.json`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"n8n": {
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["-y", "@node2flow/n8n-management-mcp"],
|
|
26
|
+
"env": {
|
|
27
|
+
"N8N_URL": "https://your-n8n-instance.com",
|
|
28
|
+
"N8N_API_KEY": "your-n8n-api-key"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Cursor / VS Code
|
|
36
|
+
|
|
37
|
+
Add to MCP settings:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"n8n": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["-y", "@node2flow/n8n-management-mcp"],
|
|
45
|
+
"env": {
|
|
46
|
+
"N8N_URL": "https://your-n8n-instance.com",
|
|
47
|
+
"N8N_API_KEY": "your-n8n-api-key"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### HTTP Mode (Streamable HTTP)
|
|
55
|
+
|
|
56
|
+
For remote deployment or shared access:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npx @node2flow/n8n-management-mcp --http
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Server starts on port 3000 (configurable via `PORT` env var). MCP endpoint: `http://localhost:3000/mcp`
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
| Environment Variable | Required | Description |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `N8N_URL` | Yes | URL of your n8n instance (e.g. `https://n8n.example.com`) |
|
|
71
|
+
| `N8N_API_KEY` | Yes | n8n API key ([how to create](https://docs.n8n.io/api/authentication/)) |
|
|
72
|
+
| `PORT` | No | Port for HTTP server (default: `3000`, only used with `--http`) |
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## All Tools (31 tools)
|
|
77
|
+
|
|
78
|
+
### Workflow Management (10 tools)
|
|
79
|
+
|
|
80
|
+
| Tool | Description |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `n8n_list_workflows` | List all workflows with status and tags |
|
|
83
|
+
| `n8n_get_workflow` | Get workflow details (nodes, connections) |
|
|
84
|
+
| `n8n_create_workflow` | Create a new workflow |
|
|
85
|
+
| `n8n_update_workflow` | Update workflow structure |
|
|
86
|
+
| `n8n_delete_workflow` | Permanently delete a workflow |
|
|
87
|
+
| `n8n_activate_workflow` | Activate workflow triggers |
|
|
88
|
+
| `n8n_deactivate_workflow` | Deactivate workflow triggers |
|
|
89
|
+
| `n8n_execute_workflow` | Execute a workflow with input data |
|
|
90
|
+
| `n8n_get_workflow_tags` | Get tags assigned to a workflow |
|
|
91
|
+
| `n8n_update_workflow_tags` | Update workflow tags |
|
|
92
|
+
|
|
93
|
+
### Execution History (4 tools)
|
|
94
|
+
|
|
95
|
+
| Tool | Description |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `n8n_list_executions` | List execution history (filter by workflow) |
|
|
98
|
+
| `n8n_get_execution` | Get execution details with node outputs |
|
|
99
|
+
| `n8n_delete_execution` | Delete an execution record |
|
|
100
|
+
| `n8n_retry_execution` | Retry a failed execution |
|
|
101
|
+
|
|
102
|
+
### Credentials (4 tools)
|
|
103
|
+
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `n8n_create_credential` | Store API credentials |
|
|
107
|
+
| `n8n_update_credential` | Update credential data |
|
|
108
|
+
| `n8n_delete_credential` | Delete a credential |
|
|
109
|
+
| `n8n_get_credential_schema` | Get required fields for a credential type |
|
|
110
|
+
|
|
111
|
+
### Tags (5 tools)
|
|
112
|
+
|
|
113
|
+
| Tool | Description |
|
|
114
|
+
|---|---|
|
|
115
|
+
| `n8n_list_tags` | List all tags |
|
|
116
|
+
| `n8n_get_tag` | Get tag details |
|
|
117
|
+
| `n8n_create_tag` | Create a new tag |
|
|
118
|
+
| `n8n_update_tag` | Rename a tag |
|
|
119
|
+
| `n8n_delete_tag` | Delete a tag |
|
|
120
|
+
|
|
121
|
+
### Variables (4 tools)
|
|
122
|
+
|
|
123
|
+
| Tool | Description |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `n8n_list_variables` | List all environment variables |
|
|
126
|
+
| `n8n_create_variable` | Create a global variable |
|
|
127
|
+
| `n8n_update_variable` | Update a variable value |
|
|
128
|
+
| `n8n_delete_variable` | Delete a variable |
|
|
129
|
+
|
|
130
|
+
### User Management (4 tools)
|
|
131
|
+
|
|
132
|
+
| Tool | Description |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `n8n_list_users` | List all users (owner only) |
|
|
135
|
+
| `n8n_get_user` | Get user details |
|
|
136
|
+
| `n8n_delete_user` | Delete a user |
|
|
137
|
+
| `n8n_update_user_role` | Change user role |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Requirements
|
|
142
|
+
|
|
143
|
+
- **Node.js** 18+
|
|
144
|
+
- **n8n instance** with API enabled
|
|
145
|
+
- **n8n API key**
|
|
146
|
+
|
|
147
|
+
### How to Create an n8n API Key
|
|
148
|
+
|
|
149
|
+
1. Go to your n8n instance Settings
|
|
150
|
+
2. Select API > API Keys
|
|
151
|
+
3. Click Create API key
|
|
152
|
+
4. Copy the key and use it as `N8N_API_KEY`
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## For Developers
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
git clone https://github.com/node2flow-th/n8n-management-mcp-community.git
|
|
160
|
+
cd n8n-management-mcp-community
|
|
161
|
+
npm install
|
|
162
|
+
npm run build
|
|
163
|
+
|
|
164
|
+
# Run in stdio mode
|
|
165
|
+
N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npm start
|
|
166
|
+
|
|
167
|
+
# Run in dev mode (hot reload)
|
|
168
|
+
N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npm run dev
|
|
169
|
+
|
|
170
|
+
# Run in HTTP mode
|
|
171
|
+
N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npm start -- --http
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT License - see [LICENSE](LICENSE)
|
|
179
|
+
|
|
180
|
+
Copyright (c) 2026 [Node2Flow](https://node2flow.net)
|
|
181
|
+
|
|
182
|
+
## Links
|
|
183
|
+
|
|
184
|
+
- [npm Package](https://www.npmjs.com/package/@node2flow/n8n-management-mcp)
|
|
185
|
+
- [n8n Documentation](https://docs.n8n.io/)
|
|
186
|
+
- [MCP Protocol](https://modelcontextprotocol.io/)
|
|
187
|
+
- [Node2Flow](https://node2flow.net)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* n8n Management MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Community edition — connects directly to your n8n instance.
|
|
6
|
+
*
|
|
7
|
+
* Usage (stdio - for Claude Desktop / Cursor / VS Code):
|
|
8
|
+
* N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npx @node2flow/n8n-management-mcp
|
|
9
|
+
*
|
|
10
|
+
* Usage (HTTP - Streamable HTTP transport):
|
|
11
|
+
* N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npx @node2flow/n8n-management-mcp --http
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Smithery expects a default export that returns a Server instance.
|
|
15
|
+
* Config (N8N_URL, N8N_API_KEY) is provided by users at runtime via Smithery UI.
|
|
16
|
+
*/
|
|
17
|
+
export default function createSmitheryServer(opts?: {
|
|
18
|
+
config?: {
|
|
19
|
+
N8N_URL?: string;
|
|
20
|
+
N8N_API_KEY?: string;
|
|
21
|
+
};
|
|
22
|
+
}): import("@modelcontextprotocol/sdk/server").Server<{
|
|
23
|
+
method: string;
|
|
24
|
+
params?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
_meta?: {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
progressToken?: string | number | undefined;
|
|
29
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
30
|
+
taskId: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
method: string;
|
|
36
|
+
params?: {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
_meta?: {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
progressToken?: string | number | undefined;
|
|
41
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
42
|
+
taskId: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
[x: string]: unknown;
|
|
48
|
+
_meta?: {
|
|
49
|
+
[x: string]: unknown;
|
|
50
|
+
progressToken?: string | number | undefined;
|
|
51
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
52
|
+
taskId: string;
|
|
53
|
+
} | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
}>;
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AA2LH;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK1G"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* n8n Management MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Community edition — connects directly to your n8n instance.
|
|
6
|
+
*
|
|
7
|
+
* Usage (stdio - for Claude Desktop / Cursor / VS Code):
|
|
8
|
+
* N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npx @node2flow/n8n-management-mcp
|
|
9
|
+
*
|
|
10
|
+
* Usage (HTTP - Streamable HTTP transport):
|
|
11
|
+
* N8N_URL=https://your-n8n.com N8N_API_KEY=your_key npx @node2flow/n8n-management-mcp --http
|
|
12
|
+
*/
|
|
13
|
+
import { randomUUID } from 'node:crypto';
|
|
14
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
15
|
+
import { StreamableHTTPServerTransport, } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
16
|
+
import { createMcpExpressApp } from '@modelcontextprotocol/sdk/server/express.js';
|
|
17
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
18
|
+
import { createServer } from './server.js';
|
|
19
|
+
import { TOOLS } from './tools.js';
|
|
20
|
+
/**
|
|
21
|
+
* Read config from environment variables
|
|
22
|
+
*/
|
|
23
|
+
function getConfig() {
|
|
24
|
+
const apiUrl = process.env.N8N_URL;
|
|
25
|
+
const apiKey = process.env.N8N_API_KEY;
|
|
26
|
+
if (!apiUrl || !apiKey) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return { apiUrl, apiKey };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Start in stdio mode (for Claude Desktop, Cursor, VS Code)
|
|
33
|
+
*/
|
|
34
|
+
async function startStdio() {
|
|
35
|
+
const config = getConfig();
|
|
36
|
+
const server = createServer(config ?? undefined);
|
|
37
|
+
const transport = new StdioServerTransport();
|
|
38
|
+
await server.connect(transport);
|
|
39
|
+
console.error('n8n Management MCP Server running on stdio');
|
|
40
|
+
console.error(`Connected to: ${config?.apiUrl ?? '(not configured yet)'}`);
|
|
41
|
+
console.error(`Tools available: ${TOOLS.length}`);
|
|
42
|
+
console.error('Ready for MCP client\n');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Start in HTTP mode (Streamable HTTP transport)
|
|
46
|
+
*/
|
|
47
|
+
async function startHttp() {
|
|
48
|
+
const port = parseInt(process.env.PORT || '3000', 10);
|
|
49
|
+
const app = createMcpExpressApp({ host: '0.0.0.0' });
|
|
50
|
+
// Map of active transports by session ID
|
|
51
|
+
const transports = {};
|
|
52
|
+
// POST /mcp — handle MCP requests
|
|
53
|
+
app.post('/mcp', async (req, res) => {
|
|
54
|
+
// Read config from query params (Smithery gateway) or env vars
|
|
55
|
+
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
56
|
+
const qUrl = url.searchParams.get('N8N_URL');
|
|
57
|
+
const qKey = url.searchParams.get('N8N_API_KEY');
|
|
58
|
+
if (qUrl)
|
|
59
|
+
process.env.N8N_URL = qUrl;
|
|
60
|
+
if (qKey)
|
|
61
|
+
process.env.N8N_API_KEY = qKey;
|
|
62
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
63
|
+
try {
|
|
64
|
+
let transport;
|
|
65
|
+
if (sessionId && transports[sessionId]) {
|
|
66
|
+
// Reuse existing transport
|
|
67
|
+
transport = transports[sessionId];
|
|
68
|
+
}
|
|
69
|
+
else if (!sessionId && isInitializeRequest(req.body)) {
|
|
70
|
+
// New initialization request
|
|
71
|
+
transport = new StreamableHTTPServerTransport({
|
|
72
|
+
sessionIdGenerator: () => randomUUID(),
|
|
73
|
+
onsessioninitialized: (sid) => {
|
|
74
|
+
transports[sid] = transport;
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
transport.onclose = () => {
|
|
78
|
+
const sid = transport.sessionId;
|
|
79
|
+
if (sid && transports[sid]) {
|
|
80
|
+
delete transports[sid];
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const config = getConfig();
|
|
84
|
+
const server = createServer(config ?? undefined);
|
|
85
|
+
await server.connect(transport);
|
|
86
|
+
await transport.handleRequest(req, res, req.body);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
res.status(400).json({
|
|
91
|
+
jsonrpc: '2.0',
|
|
92
|
+
error: {
|
|
93
|
+
code: -32000,
|
|
94
|
+
message: 'Bad Request: No valid session ID provided',
|
|
95
|
+
},
|
|
96
|
+
id: null,
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
await transport.handleRequest(req, res, req.body);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error('Error handling MCP request:', error);
|
|
104
|
+
if (!res.headersSent) {
|
|
105
|
+
res.status(500).json({
|
|
106
|
+
jsonrpc: '2.0',
|
|
107
|
+
error: {
|
|
108
|
+
code: -32603,
|
|
109
|
+
message: 'Internal server error',
|
|
110
|
+
},
|
|
111
|
+
id: null,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
// GET /mcp — SSE stream for existing sessions
|
|
117
|
+
app.get('/mcp', async (req, res) => {
|
|
118
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
119
|
+
if (!sessionId || !transports[sessionId]) {
|
|
120
|
+
res.status(400).send('Invalid or missing session ID');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
await transports[sessionId].handleRequest(req, res);
|
|
124
|
+
});
|
|
125
|
+
// DELETE /mcp — session termination
|
|
126
|
+
app.delete('/mcp', async (req, res) => {
|
|
127
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
128
|
+
if (!sessionId || !transports[sessionId]) {
|
|
129
|
+
res.status(400).send('Invalid or missing session ID');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
await transports[sessionId].handleRequest(req, res);
|
|
133
|
+
});
|
|
134
|
+
// Health check
|
|
135
|
+
app.get('/', (_req, res) => {
|
|
136
|
+
res.json({
|
|
137
|
+
name: 'n8n-management-mcp',
|
|
138
|
+
version: '1.0.4',
|
|
139
|
+
status: 'ok',
|
|
140
|
+
tools: TOOLS.length,
|
|
141
|
+
transport: 'streamable-http',
|
|
142
|
+
endpoints: {
|
|
143
|
+
mcp: '/mcp',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
const config = getConfig();
|
|
148
|
+
app.listen(port, () => {
|
|
149
|
+
console.log(`n8n Management MCP Server (HTTP) listening on port ${port}`);
|
|
150
|
+
console.log(`Connected to: ${config?.apiUrl ?? '(not configured yet)'}`);
|
|
151
|
+
console.log(`Tools available: ${TOOLS.length}`);
|
|
152
|
+
console.log(`MCP endpoint: http://localhost:${port}/mcp`);
|
|
153
|
+
});
|
|
154
|
+
process.on('SIGINT', async () => {
|
|
155
|
+
console.log('\nShutting down...');
|
|
156
|
+
for (const sessionId in transports) {
|
|
157
|
+
try {
|
|
158
|
+
await transports[sessionId].close();
|
|
159
|
+
delete transports[sessionId];
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Ignore cleanup errors
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
process.exit(0);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Main entry point
|
|
170
|
+
*/
|
|
171
|
+
async function main() {
|
|
172
|
+
const useHttp = process.argv.includes('--http');
|
|
173
|
+
if (useHttp) {
|
|
174
|
+
await startHttp();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
await startStdio();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Smithery expects a default export that returns a Server instance.
|
|
182
|
+
* Config (N8N_URL, N8N_API_KEY) is provided by users at runtime via Smithery UI.
|
|
183
|
+
*/
|
|
184
|
+
export default function createSmitheryServer(opts) {
|
|
185
|
+
if (opts?.config?.N8N_URL)
|
|
186
|
+
process.env.N8N_URL = opts.config.N8N_URL;
|
|
187
|
+
if (opts?.config?.N8N_API_KEY)
|
|
188
|
+
process.env.N8N_API_KEY = opts.config.N8N_API_KEY;
|
|
189
|
+
const config = getConfig();
|
|
190
|
+
return createServer(config ?? undefined);
|
|
191
|
+
}
|
|
192
|
+
main().catch((error) => {
|
|
193
|
+
console.error('Fatal error:', error);
|
|
194
|
+
process.exit(1);
|
|
195
|
+
});
|
|
196
|
+
//# sourceMappingURL=index.js.map
|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,CAAC;IAEhD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,MAAM,UAAU,EAAE,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,IAA8D;IACzG,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IACrE,IAAI,IAAI,EAAE,MAAM,EAAE,WAAW;QAAE,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IACjF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,YAAY,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* n8n API Client
|
|
3
|
+
* Wrapper for n8n REST API v1 calls with error handling
|
|
4
|
+
*/
|
|
5
|
+
import { N8nConfig } from './types.js';
|
|
6
|
+
export declare class N8nClient {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: N8nConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Make authenticated request to n8n API
|
|
11
|
+
*/
|
|
12
|
+
private request;
|
|
13
|
+
listWorkflows(): Promise<unknown>;
|
|
14
|
+
getWorkflow(id: string): Promise<unknown>;
|
|
15
|
+
createWorkflow(workflow: any): Promise<unknown>;
|
|
16
|
+
updateWorkflow(id: string, workflow: any): Promise<unknown>;
|
|
17
|
+
deleteWorkflow(id: string): Promise<unknown>;
|
|
18
|
+
activateWorkflow(id: string): Promise<unknown>;
|
|
19
|
+
deactivateWorkflow(id: string): Promise<unknown>;
|
|
20
|
+
executeWorkflow(id: string, data?: any): Promise<unknown>;
|
|
21
|
+
getWorkflowTags(id: string): Promise<unknown>;
|
|
22
|
+
updateWorkflowTags(id: string, tags: string[]): Promise<unknown>;
|
|
23
|
+
listExecutions(workflowId?: string): Promise<unknown>;
|
|
24
|
+
getExecution(id: string): Promise<unknown>;
|
|
25
|
+
deleteExecution(id: string): Promise<unknown>;
|
|
26
|
+
retryExecution(id: string): Promise<unknown>;
|
|
27
|
+
createCredential(credential: any): Promise<unknown>;
|
|
28
|
+
updateCredential(id: string, credential: any): Promise<unknown>;
|
|
29
|
+
deleteCredential(id: string): Promise<unknown>;
|
|
30
|
+
getCredentialSchema(credentialType: string): Promise<unknown>;
|
|
31
|
+
listTags(): Promise<unknown>;
|
|
32
|
+
getTag(id: string): Promise<unknown>;
|
|
33
|
+
createTag(name: string): Promise<unknown>;
|
|
34
|
+
updateTag(id: string, name: string): Promise<unknown>;
|
|
35
|
+
deleteTag(id: string): Promise<unknown>;
|
|
36
|
+
listVariables(): Promise<unknown>;
|
|
37
|
+
createVariable(key: string, value: string): Promise<unknown>;
|
|
38
|
+
updateVariable(id: string, key: string, value: string): Promise<unknown>;
|
|
39
|
+
deleteVariable(id: string): Promise<unknown>;
|
|
40
|
+
listUsers(): Promise<unknown>;
|
|
41
|
+
getUser(identifier: string): Promise<unknown>;
|
|
42
|
+
deleteUser(id: string): Promise<unknown>;
|
|
43
|
+
updateUserRole(id: string, role: 'admin' | 'member'): Promise<unknown>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=n8n-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n8n-client.d.ts","sourceRoot":"","sources":["../src/n8n-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,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