Skip to content

Commit 9555fa2

Browse files
committed
fix: resolve API endpoint 404 errors by correcting double path issue
- Fixed duplicate /api/v1/ paths in all endpoint calls - Updated all endpoints to use relative paths when base URL already includes /api/v1 - Changed endpoints from /api/v1/workflows to /workflows throughout codebase - Fixed src/server.ts, src/index.ts, and src/services/n8nApi.ts - Bumped version to 0.10.3 - Resolves 404 errors in list_workflows and all other MCP tools
1 parent 5bd020c commit 9555fa2

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@makafeli/n8n-workflow-builder",
3-
"version": "0.10.2",
3+
"version": "0.10.3",
44
"description": "Model Context Protocol server for n8n workflow management",
55
"main": "build/server.cjs",
66
"module": "./src/index.ts",

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
2121
// Create MCP server with modern SDK 1.17.0 API
2222
const server = new McpServer({
2323
name: "n8n-workflow-builder",
24-
version: "0.10.2"
24+
version: "0.10.3"
2525
});
2626

2727
// Register workflow management tools using modern MCP SDK 1.17.0 API
@@ -31,7 +31,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
3131
{},
3232
async () => {
3333
try {
34-
const response = await n8nApi.get('/api/v1/workflows');
34+
const response = await n8nApi.get('/workflows');
3535
return {
3636
content: [{
3737
type: "text",
@@ -64,7 +64,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
6464
},
6565
async ({ workflow }) => {
6666
try {
67-
const response = await n8nApi.post('/api/v1/workflows', workflow);
67+
const response = await n8nApi.post('/workflows', workflow);
6868
return {
6969
content: [{
7070
type: "text",
@@ -91,7 +91,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
9191
},
9292
async ({ id }) => {
9393
try {
94-
const response = await n8nApi.get(`/api/v1/workflows/${id}`);
94+
const response = await n8nApi.get(`/workflows/${id}`);
9595
return {
9696
content: [{
9797
type: "text",
@@ -118,7 +118,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
118118
},
119119
async ({ id }) => {
120120
try {
121-
const response = await n8nApi.post(`/api/v1/workflows/${id}/execute`);
121+
const response = await n8nApi.post(`/workflows/${id}/execute`);
122122
return {
123123
content: [{
124124
type: "text",
@@ -152,7 +152,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
152152
},
153153
async ({ id, workflow }) => {
154154
try {
155-
const response = await n8nApi.put(`/api/v1/workflows/${id}`, workflow);
155+
const response = await n8nApi.put(`/workflows/${id}`, workflow);
156156
return {
157157
content: [{
158158
type: "text",
@@ -179,7 +179,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
179179
},
180180
async ({ id }) => {
181181
try {
182-
const response = await n8nApi.patch(`/api/v1/workflows/${id}/activate`);
182+
const response = await n8nApi.patch(`/workflows/${id}/activate`);
183183
return {
184184
content: [{
185185
type: "text",
@@ -206,7 +206,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
206206
},
207207
async ({ id }) => {
208208
try {
209-
const response = await n8nApi.patch(`/api/v1/workflows/${id}/deactivate`);
209+
const response = await n8nApi.patch(`/workflows/${id}/deactivate`);
210210
return {
211211
content: [{
212212
type: "text",
@@ -233,7 +233,7 @@ export default function ({ config }: { config: z.infer<typeof configSchema> }) {
233233
},
234234
async ({ id }) => {
235235
try {
236-
const response = await n8nApi.delete(`/api/v1/workflows/${id}`);
236+
const response = await n8nApi.delete(`/workflows/${id}`);
237237
return {
238238
content: [{
239239
type: "text",

src/server.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const n8nApi = axios.create({
2525
// Create MCP server with modern SDK 1.17.0 API
2626
const server = new McpServer({
2727
name: "n8n-workflow-builder",
28-
version: "0.10.2"
28+
version: "0.10.3"
2929
});
3030

3131
// Register workflow management tools using modern MCP SDK 1.17.0 API
@@ -35,7 +35,7 @@ server.tool(
3535
{},
3636
async () => {
3737
try {
38-
const response = await n8nApi.get('/api/v1/workflows');
38+
const response = await n8nApi.get('/workflows');
3939
return {
4040
content: [{
4141
type: "text",
@@ -68,7 +68,7 @@ server.tool(
6868
},
6969
async ({ workflow }) => {
7070
try {
71-
const response = await n8nApi.post('/api/v1/workflows', workflow);
71+
const response = await n8nApi.post('/workflows', workflow);
7272
return {
7373
content: [{
7474
type: "text",
@@ -95,7 +95,7 @@ server.tool(
9595
},
9696
async ({ id }) => {
9797
try {
98-
const response = await n8nApi.get(`/api/v1/workflows/${id}`);
98+
const response = await n8nApi.get(`/workflows/${id}`);
9999
return {
100100
content: [{
101101
type: "text",
@@ -129,7 +129,7 @@ server.tool(
129129
},
130130
async ({ id, workflow }) => {
131131
try {
132-
const response = await n8nApi.put(`/api/v1/workflows/${id}`, workflow);
132+
const response = await n8nApi.put(`/workflows/${id}`, workflow);
133133
return {
134134
content: [{
135135
type: "text",
@@ -156,7 +156,7 @@ server.tool(
156156
},
157157
async ({ id }) => {
158158
try {
159-
const response = await n8nApi.delete(`/api/v1/workflows/${id}`);
159+
const response = await n8nApi.delete(`/workflows/${id}`);
160160
return {
161161
content: [{
162162
type: "text",
@@ -187,7 +187,7 @@ server.tool(
187187
},
188188
async ({ id }) => {
189189
try {
190-
const response = await n8nApi.post(`/api/v1/workflows/${id}/activate`);
190+
const response = await n8nApi.post(`/workflows/${id}/activate`);
191191
return {
192192
content: [{
193193
type: "text",
@@ -218,7 +218,7 @@ server.tool(
218218
},
219219
async ({ id }) => {
220220
try {
221-
const response = await n8nApi.post(`/api/v1/workflows/${id}/deactivate`);
221+
const response = await n8nApi.post(`/workflows/${id}/deactivate`);
222222
return {
223223
content: [{
224224
type: "text",
@@ -249,7 +249,7 @@ server.tool(
249249
},
250250
async ({ id }) => {
251251
try {
252-
const response = await n8nApi.post(`/api/v1/workflows/${id}/execute`);
252+
const response = await n8nApi.post(`/workflows/${id}/execute`);
253253
return {
254254
content: [{
255255
type: "text",
@@ -287,11 +287,11 @@ server.tool(
287287
async ({ workflow }) => {
288288
try {
289289
// First create the workflow
290-
const createResponse = await n8nApi.post('/api/v1/workflows', workflow);
290+
const createResponse = await n8nApi.post('/workflows', workflow);
291291
const workflowId = createResponse.data.id;
292292

293293
// Then activate it
294-
const activateResponse = await n8nApi.post(`/api/v1/workflows/${workflowId}/activate`);
294+
const activateResponse = await n8nApi.post(`/workflows/${workflowId}/activate`);
295295

296296
return {
297297
content: [{
@@ -338,7 +338,7 @@ server.tool(
338338
if (limit) params.append('limit', limit.toString());
339339
if (cursor) params.append('cursor', cursor);
340340

341-
const response = await n8nApi.get(`/api/v1/executions?${params.toString()}`);
341+
const response = await n8nApi.get(`/executions?${params.toString()}`);
342342
return {
343343
content: [{
344344
type: "text",
@@ -369,7 +369,7 @@ server.tool(
369369
const params = new URLSearchParams();
370370
if (includeData !== undefined) params.append('includeData', includeData.toString());
371371

372-
const url = `/api/v1/executions/${id}${params.toString() ? `?${params.toString()}` : ''}`;
372+
const url = `/executions/${id}${params.toString() ? `?${params.toString()}` : ''}`;
373373
const response = await n8nApi.get(url);
374374
return {
375375
content: [{
@@ -397,7 +397,7 @@ server.tool(
397397
},
398398
async ({ id }) => {
399399
try {
400-
const response = await n8nApi.delete(`/api/v1/executions/${id}`);
400+
const response = await n8nApi.delete(`/executions/${id}`);
401401
return {
402402
content: [{
403403
type: "text",
@@ -435,7 +435,7 @@ server.tool(
435435
if (limit) params.append('limit', limit.toString());
436436
if (cursor) params.append('cursor', cursor);
437437

438-
const response = await n8nApi.get(`/api/v1/tags?${params.toString()}`);
438+
const response = await n8nApi.get(`/tags?${params.toString()}`);
439439
return {
440440
content: [{
441441
type: "text",
@@ -462,7 +462,7 @@ server.tool(
462462
},
463463
async ({ name }) => {
464464
try {
465-
const response = await n8nApi.post('/api/v1/tags', { name });
465+
const response = await n8nApi.post('/tags', { name });
466466
return {
467467
content: [{
468468
type: "text",
@@ -493,7 +493,7 @@ server.tool(
493493
},
494494
async ({ id }) => {
495495
try {
496-
const response = await n8nApi.get(`/api/v1/tags/${id}`);
496+
const response = await n8nApi.get(`/tags/${id}`);
497497
return {
498498
content: [{
499499
type: "text",
@@ -525,7 +525,7 @@ server.tool(
525525
},
526526
async ({ id, name }) => {
527527
try {
528-
const response = await n8nApi.put(`/api/v1/tags/${id}`, { name });
528+
const response = await n8nApi.put(`/tags/${id}`, { name });
529529
return {
530530
content: [{
531531
type: "text",
@@ -556,7 +556,7 @@ server.tool(
556556
},
557557
async ({ id }) => {
558558
try {
559-
const response = await n8nApi.delete(`/api/v1/tags/${id}`);
559+
const response = await n8nApi.delete(`/tags/${id}`);
560560
return {
561561
content: [{
562562
type: "text",
@@ -587,7 +587,7 @@ server.tool(
587587
},
588588
async ({ workflowId }) => {
589589
try {
590-
const response = await n8nApi.get(`/api/v1/workflows/${workflowId}/tags`);
590+
const response = await n8nApi.get(`/workflows/${workflowId}/tags`);
591591
return {
592592
content: [{
593593
type: "text",
@@ -620,7 +620,7 @@ server.tool(
620620
},
621621
async ({ workflowId, tagIds }) => {
622622
try {
623-
const response = await n8nApi.put(`/api/v1/workflows/${workflowId}/tags`, { tagIds });
623+
const response = await n8nApi.put(`/workflows/${workflowId}/tags`, { tagIds });
624624
return {
625625
content: [{
626626
type: "text",
@@ -655,7 +655,7 @@ server.tool(
655655
},
656656
async ({ name, type, data }) => {
657657
try {
658-
const response = await n8nApi.post('/api/v1/credentials', {
658+
const response = await n8nApi.post('/credentials', {
659659
name,
660660
type,
661661
data
@@ -695,7 +695,7 @@ server.tool(
695695
},
696696
async ({ credentialType }) => {
697697
try {
698-
const response = await n8nApi.get(`/api/v1/credentials/schema/${credentialType}`);
698+
const response = await n8nApi.get(`/credentials/schema/${credentialType}`);
699699
return {
700700
content: [{
701701
type: "text",
@@ -727,7 +727,7 @@ server.tool(
727727
},
728728
async ({ id }) => {
729729
try {
730-
const response = await n8nApi.delete(`/api/v1/credentials/${id}`);
730+
const response = await n8nApi.delete(`/credentials/${id}`);
731731
return {
732732
content: [{
733733
type: "text",
@@ -773,7 +773,7 @@ server.tool(
773773
}
774774
}
775775

776-
const response = await n8nApi.post('/api/v1/audit', auditPayload);
776+
const response = await n8nApi.post('/audit', auditPayload);
777777
return {
778778
content: [{
779779
type: "text",
@@ -800,7 +800,7 @@ server.tool(
800800
async function main() {
801801
const transport = new StdioServerTransport();
802802
await server.connect(transport);
803-
console.error("N8N Workflow Builder MCP server v0.10.2 running on stdio");
803+
console.error("N8N Workflow Builder MCP server v0.10.3 running on stdio");
804804
console.error("Modern SDK 1.17.0 with 23 tools: 9 workflow + 3 execution + 7 tag + 3 credential + 1 audit");
805805
}
806806

src/services/n8nApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WorkflowSpec } from '../types/workflow';
44
import { N8NWorkflowResponse } from '../types/api';
55

66
const api = axios.create({
7-
baseURL: `${N8N_HOST}/rest/workflows`,
7+
baseURL: `${N8N_HOST}/workflows`,
88
headers: {
99
'Content-Type': 'application/json',
1010
'x-api-key': N8N_API_KEY

0 commit comments

Comments
 (0)