Skip to content

Commit 6c70495

Browse files
committed
Add user agent for all requests going out to API, fix missing tools from README
1 parent 43bd03d commit 6c70495

File tree

2 files changed

+95
-40
lines changed

2 files changed

+95
-40
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ collection - fields - create - reference; // Create a reference field
138138
collection - fields - update; // Update a custom field
139139
collections - items - create - item - live; // Create items
140140
collections - items - update - items - live; // Update items
141+
collections - items - list - items; // List collection items
142+
collections - items - create - item; // Create collection items (staged)
143+
collections - items - update - items; // Update collection items (staged)
144+
collections - items - publish - items; // Publish collection items
141145
```
142146

143147
# 🗣️ Prompts & Resources

src/mcp.ts

Lines changed: 91 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ export function createMcpServer() {
1414
});
1515
}
1616

17+
// Common request options, including User-Agent header
18+
const requestOptions = {
19+
headers: {
20+
"User-Agent": `Webflow MCP Server/${packageJson.version}`,
21+
},
22+
};
23+
1724
// Register tools
1825
export function registerTools(
1926
server: McpServer,
@@ -23,7 +30,7 @@ export function registerTools(
2330

2431
// GET https://api.webflow.com/v2/sites
2532
server.tool("sites_list", async () => {
26-
const response = await getClient().sites.list();
33+
const response = await getClient().sites.list(requestOptions);
2734
return {
2835
content: [{ type: "text", text: JSON.stringify(response) }],
2936
};
@@ -36,7 +43,7 @@ export function registerTools(
3643
site_id: z.string(),
3744
},
3845
async ({ site_id }) => {
39-
const response = await getClient().sites.get(site_id);
46+
const response = await getClient().sites.get(site_id, requestOptions);
4047
return {
4148
content: [{ type: "text", text: JSON.stringify(response) }],
4249
};
@@ -52,10 +59,14 @@ export function registerTools(
5259
publishToWebflowSubdomain: z.boolean().optional().default(false),
5360
},
5461
async ({ site_id, customDomains, publishToWebflowSubdomain }) => {
55-
const response = await getClient().sites.publish(site_id, {
56-
customDomains,
57-
publishToWebflowSubdomain,
58-
});
62+
const response = await getClient().sites.publish(
63+
site_id,
64+
{
65+
customDomains,
66+
publishToWebflowSubdomain,
67+
},
68+
requestOptions
69+
);
5970
return {
6071
content: [{ type: "text", text: JSON.stringify(response) }],
6172
};
@@ -74,11 +85,15 @@ export function registerTools(
7485
offset: z.number().optional(),
7586
},
7687
async ({ site_id, localeId, limit, offset }) => {
77-
const response = await getClient().pages.list(site_id, {
78-
localeId,
79-
limit,
80-
offset,
81-
});
88+
const response = await getClient().pages.list(
89+
site_id,
90+
{
91+
localeId,
92+
limit,
93+
offset,
94+
},
95+
requestOptions
96+
);
8297
return {
8398
content: [{ type: "text", text: JSON.stringify(response) }],
8499
};
@@ -93,9 +108,13 @@ export function registerTools(
93108
localeId: z.string().optional(),
94109
},
95110
async ({ page_id, localeId }) => {
96-
const response = await getClient().pages.getMetadata(page_id, {
97-
localeId,
98-
});
111+
const response = await getClient().pages.getMetadata(
112+
page_id,
113+
{
114+
localeId,
115+
},
116+
requestOptions
117+
);
99118
return {
100119
content: [{ type: "text", text: JSON.stringify(response) }],
101120
};
@@ -144,10 +163,14 @@ export function registerTools(
144163
body: WebflowPageSchema,
145164
},
146165
async ({ page_id, localeId, body }) => {
147-
const response = await getClient().pages.updatePageSettings(page_id, {
148-
localeId,
149-
body,
150-
});
166+
const response = await getClient().pages.updatePageSettings(
167+
page_id,
168+
{
169+
localeId,
170+
body,
171+
},
172+
requestOptions
173+
);
151174
return {
152175
content: [{ type: "text", text: JSON.stringify(response) }],
153176
};
@@ -164,11 +187,15 @@ export function registerTools(
164187
offset: z.number().optional(),
165188
},
166189
async ({ page_id, localeId, limit, offset }) => {
167-
const response = await getClient().pages.getContent(page_id, {
168-
localeId,
169-
limit,
170-
offset,
171-
});
190+
const response = await getClient().pages.getContent(
191+
page_id,
192+
{
193+
localeId,
194+
limit,
195+
offset,
196+
},
197+
requestOptions
198+
);
172199
return {
173200
content: [{ type: "text", text: JSON.stringify(response) }],
174201
};
@@ -203,10 +230,14 @@ export function registerTools(
203230
nodes: WebflowPageDomWriteNodesItemSchema,
204231
},
205232
async ({ page_id, localeId, nodes }) => {
206-
const response = await getClient().pages.updateStaticContent(page_id, {
207-
localeId,
208-
nodes,
209-
});
233+
const response = await getClient().pages.updateStaticContent(
234+
page_id,
235+
{
236+
localeId,
237+
nodes,
238+
},
239+
requestOptions
240+
);
210241
return {
211242
content: [{ type: "text", text: JSON.stringify(response) }],
212243
};
@@ -222,7 +253,10 @@ export function registerTools(
222253
site_id: z.string(),
223254
},
224255
async ({ site_id }) => {
225-
const response = await getClient().collections.list(site_id);
256+
const response = await getClient().collections.list(
257+
site_id,
258+
requestOptions
259+
);
226260
return {
227261
content: [{ type: "text", text: JSON.stringify(response) }],
228262
};
@@ -236,7 +270,10 @@ export function registerTools(
236270
collection_id: z.string(),
237271
},
238272
async ({ collection_id }) => {
239-
const response = await getClient().collections.get(collection_id);
273+
const response = await getClient().collections.get(
274+
collection_id,
275+
requestOptions
276+
);
240277
return {
241278
content: [{ type: "text", text: JSON.stringify(response) }],
242279
};
@@ -311,7 +348,11 @@ export function registerTools(
311348
request: WebflowCollectionsCreateRequestSchema,
312349
},
313350
async ({ site_id, request }) => {
314-
const response = await getClient().collections.create(site_id, request);
351+
const response = await getClient().collections.create(
352+
site_id,
353+
request,
354+
requestOptions
355+
);
315356
return { content: [{ type: "text", text: JSON.stringify(response) }] };
316357
}
317358
);
@@ -326,7 +367,8 @@ export function registerTools(
326367
async ({ collection_id, request }) => {
327368
const response = await getClient().collections.fields.create(
328369
collection_id,
329-
request
370+
request,
371+
requestOptions
330372
);
331373
return { content: [{ type: "text", text: JSON.stringify(response) }] };
332374
}
@@ -342,7 +384,8 @@ export function registerTools(
342384
async ({ collection_id, request }) => {
343385
const response = await getClient().collections.fields.create(
344386
collection_id,
345-
request
387+
request,
388+
requestOptions
346389
);
347390
return { content: [{ type: "text", text: JSON.stringify(response) }] };
348391
}
@@ -358,7 +401,8 @@ export function registerTools(
358401
async ({ collection_id, request }) => {
359402
const response = await getClient().collections.fields.create(
360403
collection_id,
361-
request
404+
request,
405+
requestOptions
362406
);
363407
return { content: [{ type: "text", text: JSON.stringify(response) }] };
364408
}
@@ -383,7 +427,8 @@ export function registerTools(
383427
const response = await getClient().collections.fields.update(
384428
collection_id,
385429
field_id,
386-
request
430+
request,
431+
requestOptions
387432
);
388433
return { content: [{ type: "text", text: JSON.stringify(response) }] };
389434
}
@@ -423,7 +468,8 @@ export function registerTools(
423468
async ({ collection_id, request }) => {
424469
const response = await getClient().collections.items.createItemLive(
425470
collection_id,
426-
request
471+
request,
472+
requestOptions
427473
);
428474
return {
429475
content: [{ type: "text", text: JSON.stringify(response) }],
@@ -467,7 +513,8 @@ export function registerTools(
467513
async ({ collection_id, request }) => {
468514
const response = await getClient().collections.items.updateItemsLive(
469515
collection_id,
470-
request
516+
request,
517+
requestOptions
471518
);
472519
return {
473520
content: [{ type: "text", text: JSON.stringify(response) }],
@@ -508,7 +555,8 @@ export function registerTools(
508555
slug,
509556
sortBy,
510557
sortOrder,
511-
}
558+
},
559+
requestOptions
512560
);
513561
return {
514562
content: [{ type: "text", text: JSON.stringify(response) }],
@@ -549,7 +597,8 @@ export function registerTools(
549597
async ({ collection_id, request }) => {
550598
const response = await getClient().collections.items.createItem(
551599
collection_id,
552-
request
600+
request,
601+
requestOptions
553602
);
554603
return {
555604
content: [{ type: "text", text: JSON.stringify(response) }],
@@ -589,7 +638,8 @@ export function registerTools(
589638
async ({ collection_id, request }) => {
590639
const response = await getClient().collections.items.updateItems(
591640
collection_id,
592-
request
641+
request,
642+
requestOptions
593643
);
594644
return {
595645
content: [{ type: "text", text: JSON.stringify(response) }],
@@ -609,7 +659,8 @@ export function registerTools(
609659
collection_id,
610660
{
611661
itemIds: itemIds,
612-
}
662+
},
663+
requestOptions
613664
);
614665
return {
615666
content: [{ type: "text", text: JSON.stringify(response) }],

0 commit comments

Comments
 (0)