@universal-mcp-toolkit/server-cloudflare-workers 0.1.0
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/.well-known/mcp-server.json +36 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +354 -0
- package/package.json +53 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/json",
|
|
3
|
+
"name": "cloudflare-workers",
|
|
4
|
+
"title": "Cloudflare Workers MCP Server",
|
|
5
|
+
"description": "Worker, route, and account tools for Cloudflare Workers.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"packageName": "@universal-mcp-toolkit/server-cloudflare-workers",
|
|
8
|
+
"homepage": "https://github.com/universal-mcp-toolkit/universal-mcp-toolkit",
|
|
9
|
+
"transports": [
|
|
10
|
+
"stdio",
|
|
11
|
+
"sse"
|
|
12
|
+
],
|
|
13
|
+
"authentication": {
|
|
14
|
+
"mode": "environment-variables",
|
|
15
|
+
"required": [
|
|
16
|
+
"CLOUDFLARE_API_TOKEN",
|
|
17
|
+
"CLOUDFLARE_ACCOUNT_ID"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"capabilities": {
|
|
21
|
+
"tools": true,
|
|
22
|
+
"resources": true,
|
|
23
|
+
"prompts": true
|
|
24
|
+
},
|
|
25
|
+
"tools": [
|
|
26
|
+
"list_workers",
|
|
27
|
+
"get_worker",
|
|
28
|
+
"list_routes"
|
|
29
|
+
],
|
|
30
|
+
"resources": [
|
|
31
|
+
"account"
|
|
32
|
+
],
|
|
33
|
+
"prompts": [
|
|
34
|
+
"edge-rollout"
|
|
35
|
+
]
|
|
36
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 universal-mcp-toolkit
|
|
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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as _universal_mcp_toolkit_core from '@universal-mcp-toolkit/core';
|
|
2
|
+
import { ToolkitServer, ToolkitServerMetadata } from '@universal-mcp-toolkit/core';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare const metadata: ToolkitServerMetadata;
|
|
6
|
+
declare const serverCard: _universal_mcp_toolkit_core.ToolkitServerCard;
|
|
7
|
+
declare const workerSummarySchema: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
10
|
+
modifiedAt: z.ZodNullable<z.ZodString>;
|
|
11
|
+
usageModel: z.ZodNullable<z.ZodString>;
|
|
12
|
+
handlers: z.ZodArray<z.ZodString>;
|
|
13
|
+
compatibilityDate: z.ZodNullable<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const workerDetailSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
18
|
+
modifiedAt: z.ZodNullable<z.ZodString>;
|
|
19
|
+
usageModel: z.ZodNullable<z.ZodString>;
|
|
20
|
+
handlers: z.ZodArray<z.ZodString>;
|
|
21
|
+
compatibilityDate: z.ZodNullable<z.ZodString>;
|
|
22
|
+
bindingsCount: z.ZodNumber;
|
|
23
|
+
placementMode: z.ZodNullable<z.ZodString>;
|
|
24
|
+
logpush: z.ZodBoolean;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
declare const routeSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
pattern: z.ZodString;
|
|
29
|
+
script: z.ZodNullable<z.ZodString>;
|
|
30
|
+
zoneName: z.ZodNullable<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
declare const accountSummarySchema: z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
type: z.ZodNullable<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
type CloudflareWorkerSummary = z.infer<typeof workerSummarySchema>;
|
|
38
|
+
type CloudflareWorkerDetail = z.infer<typeof workerDetailSchema>;
|
|
39
|
+
type CloudflareRoute = z.infer<typeof routeSchema>;
|
|
40
|
+
type CloudflareAccountSummary = z.infer<typeof accountSummarySchema>;
|
|
41
|
+
interface CloudflareWorkersClient {
|
|
42
|
+
listWorkers(limit: number): Promise<ReadonlyArray<CloudflareWorkerSummary>>;
|
|
43
|
+
getWorker(scriptName: string): Promise<CloudflareWorkerDetail>;
|
|
44
|
+
listRoutes(input: {
|
|
45
|
+
limit: number;
|
|
46
|
+
scriptName?: string;
|
|
47
|
+
}): Promise<ReadonlyArray<CloudflareRoute>>;
|
|
48
|
+
getAccountSummary(): Promise<CloudflareAccountSummary>;
|
|
49
|
+
}
|
|
50
|
+
interface CreateCloudflareWorkersServerOptions {
|
|
51
|
+
client?: CloudflareWorkersClient;
|
|
52
|
+
env?: NodeJS.ProcessEnv;
|
|
53
|
+
fetch?: typeof fetch;
|
|
54
|
+
}
|
|
55
|
+
declare class CloudflareWorkersServer extends ToolkitServer {
|
|
56
|
+
private readonly client;
|
|
57
|
+
constructor(client: CloudflareWorkersClient);
|
|
58
|
+
}
|
|
59
|
+
declare function createServer(options?: CreateCloudflareWorkersServerOptions): Promise<CloudflareWorkersServer>;
|
|
60
|
+
declare function main(argv?: readonly string[]): Promise<void>;
|
|
61
|
+
|
|
62
|
+
export { type CloudflareAccountSummary, type CloudflareRoute, type CloudflareWorkerDetail, type CloudflareWorkerSummary, type CloudflareWorkersClient, CloudflareWorkersServer, type CreateCloudflareWorkersServerOptions, createServer, main, metadata, serverCard };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createServerCard,
|
|
4
|
+
defineTool,
|
|
5
|
+
ExternalServiceError,
|
|
6
|
+
loadEnv,
|
|
7
|
+
parseRuntimeOptions,
|
|
8
|
+
runToolkitServer,
|
|
9
|
+
ToolkitServer
|
|
10
|
+
} from "@universal-mcp-toolkit/core";
|
|
11
|
+
import { resolve } from "path";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
var toolNames = ["list_workers", "get_worker", "list_routes"];
|
|
15
|
+
var resourceNames = ["account"];
|
|
16
|
+
var promptNames = ["edge-rollout"];
|
|
17
|
+
var metadata = {
|
|
18
|
+
id: "cloudflare-workers",
|
|
19
|
+
title: "Cloudflare Workers MCP Server",
|
|
20
|
+
description: "Worker, route, and account tools for Cloudflare Workers.",
|
|
21
|
+
version: "0.1.0",
|
|
22
|
+
packageName: "@universal-mcp-toolkit/server-cloudflare-workers",
|
|
23
|
+
homepage: "https://github.com/universal-mcp-toolkit/universal-mcp-toolkit",
|
|
24
|
+
repositoryUrl: "https://github.com/universal-mcp-toolkit/universal-mcp-toolkit",
|
|
25
|
+
documentationUrl: "https://github.com/universal-mcp-toolkit/universal-mcp-toolkit/tree/main/servers/cloudflare-workers",
|
|
26
|
+
envVarNames: ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"],
|
|
27
|
+
transports: ["stdio", "sse"],
|
|
28
|
+
toolNames,
|
|
29
|
+
resourceNames,
|
|
30
|
+
promptNames
|
|
31
|
+
};
|
|
32
|
+
var serverCard = createServerCard(metadata);
|
|
33
|
+
var envShape = {
|
|
34
|
+
CLOUDFLARE_API_TOKEN: z.string().min(1),
|
|
35
|
+
CLOUDFLARE_ACCOUNT_ID: z.string().min(1),
|
|
36
|
+
CLOUDFLARE_API_BASE_URL: z.string().url().optional()
|
|
37
|
+
};
|
|
38
|
+
var workerSummarySchema = z.object({
|
|
39
|
+
name: z.string(),
|
|
40
|
+
createdAt: z.string().nullable(),
|
|
41
|
+
modifiedAt: z.string().nullable(),
|
|
42
|
+
usageModel: z.string().nullable(),
|
|
43
|
+
handlers: z.array(z.string()),
|
|
44
|
+
compatibilityDate: z.string().nullable()
|
|
45
|
+
});
|
|
46
|
+
var workerDetailSchema = workerSummarySchema.extend({
|
|
47
|
+
bindingsCount: z.number().int().nonnegative(),
|
|
48
|
+
placementMode: z.string().nullable(),
|
|
49
|
+
logpush: z.boolean()
|
|
50
|
+
});
|
|
51
|
+
var routeSchema = z.object({
|
|
52
|
+
id: z.string(),
|
|
53
|
+
pattern: z.string(),
|
|
54
|
+
script: z.string().nullable(),
|
|
55
|
+
zoneName: z.string().nullable()
|
|
56
|
+
});
|
|
57
|
+
var accountSummarySchema = z.object({
|
|
58
|
+
id: z.string(),
|
|
59
|
+
name: z.string(),
|
|
60
|
+
type: z.string().nullable()
|
|
61
|
+
});
|
|
62
|
+
var cloudflareResponseSchema = (resultSchema) => z.object({
|
|
63
|
+
success: z.boolean().optional(),
|
|
64
|
+
result: resultSchema
|
|
65
|
+
});
|
|
66
|
+
var workerListResponseSchema = cloudflareResponseSchema(
|
|
67
|
+
z.array(
|
|
68
|
+
z.object({
|
|
69
|
+
id: z.string(),
|
|
70
|
+
created_on: z.string().nullable().optional(),
|
|
71
|
+
modified_on: z.string().nullable().optional(),
|
|
72
|
+
usage_model: z.string().nullable().optional(),
|
|
73
|
+
handlers: z.array(z.string()).optional(),
|
|
74
|
+
compatibility_date: z.string().nullable().optional()
|
|
75
|
+
})
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
var workerSettingsResponseSchema = cloudflareResponseSchema(
|
|
79
|
+
z.object({
|
|
80
|
+
compatibility_date: z.string().nullable().optional(),
|
|
81
|
+
usage_model: z.string().nullable().optional(),
|
|
82
|
+
bindings: z.array(z.unknown()).optional(),
|
|
83
|
+
placement_mode: z.string().nullable().optional(),
|
|
84
|
+
logpush: z.boolean().optional()
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
var routesResponseSchema = cloudflareResponseSchema(
|
|
88
|
+
z.array(
|
|
89
|
+
z.object({
|
|
90
|
+
id: z.string(),
|
|
91
|
+
pattern: z.string(),
|
|
92
|
+
script: z.string().nullable().optional(),
|
|
93
|
+
zone_name: z.string().nullable().optional()
|
|
94
|
+
})
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
var accountResponseSchema = cloudflareResponseSchema(
|
|
98
|
+
z.object({
|
|
99
|
+
id: z.string(),
|
|
100
|
+
name: z.string(),
|
|
101
|
+
type: z.string().nullable().optional()
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
function resolveEnv(source = process.env) {
|
|
105
|
+
return loadEnv(envShape, source);
|
|
106
|
+
}
|
|
107
|
+
function toNullableString(value) {
|
|
108
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
109
|
+
}
|
|
110
|
+
var FetchCloudflareWorkersClient = class {
|
|
111
|
+
accountId;
|
|
112
|
+
baseUrl;
|
|
113
|
+
fetchImpl;
|
|
114
|
+
headers;
|
|
115
|
+
constructor(options) {
|
|
116
|
+
this.accountId = options.accountId;
|
|
117
|
+
this.baseUrl = (options.baseUrl ?? "https://api.cloudflare.com/client/v4").replace(/\/+$/, "");
|
|
118
|
+
this.fetchImpl = options.fetch;
|
|
119
|
+
this.headers = {
|
|
120
|
+
authorization: `Bearer ${options.apiToken}`,
|
|
121
|
+
accept: "application/json"
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async listWorkers(limit) {
|
|
125
|
+
const payload = await this.requestJson(
|
|
126
|
+
`/accounts/${this.accountId}/workers/scripts`,
|
|
127
|
+
workerListResponseSchema
|
|
128
|
+
);
|
|
129
|
+
return payload.result.slice(0, limit).map((worker) => ({
|
|
130
|
+
name: worker.id,
|
|
131
|
+
createdAt: toNullableString(worker.created_on),
|
|
132
|
+
modifiedAt: toNullableString(worker.modified_on),
|
|
133
|
+
usageModel: toNullableString(worker.usage_model),
|
|
134
|
+
handlers: worker.handlers ?? [],
|
|
135
|
+
compatibilityDate: toNullableString(worker.compatibility_date)
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
async getWorker(scriptName) {
|
|
139
|
+
const [summary, settings] = await Promise.all([
|
|
140
|
+
this.listWorkers(Number.MAX_SAFE_INTEGER),
|
|
141
|
+
this.requestJson(
|
|
142
|
+
`/accounts/${this.accountId}/workers/scripts/${encodeURIComponent(scriptName)}/settings`,
|
|
143
|
+
workerSettingsResponseSchema
|
|
144
|
+
)
|
|
145
|
+
]);
|
|
146
|
+
const worker = summary.find((entry) => entry.name === scriptName);
|
|
147
|
+
if (!worker) {
|
|
148
|
+
throw new ExternalServiceError(`Cloudflare worker '${scriptName}' was not found.`, {
|
|
149
|
+
statusCode: 404
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
...worker,
|
|
154
|
+
bindingsCount: settings.result.bindings?.length ?? 0,
|
|
155
|
+
placementMode: toNullableString(settings.result.placement_mode),
|
|
156
|
+
logpush: settings.result.logpush ?? false
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async listRoutes(input) {
|
|
160
|
+
const payload = await this.requestJson(`/accounts/${this.accountId}/workers/routes`, routesResponseSchema);
|
|
161
|
+
const filtered = payload.result.filter((route) => input.scriptName === void 0 || route.script === input.scriptName).slice(0, input.limit);
|
|
162
|
+
return filtered.map((route) => ({
|
|
163
|
+
id: route.id,
|
|
164
|
+
pattern: route.pattern,
|
|
165
|
+
script: toNullableString(route.script),
|
|
166
|
+
zoneName: toNullableString(route.zone_name)
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
async getAccountSummary() {
|
|
170
|
+
const payload = await this.requestJson(`/accounts/${this.accountId}`, accountResponseSchema);
|
|
171
|
+
return {
|
|
172
|
+
id: payload.result.id,
|
|
173
|
+
name: payload.result.name,
|
|
174
|
+
type: toNullableString(payload.result.type)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
async requestJson(path, schema) {
|
|
178
|
+
const url = new URL(path, this.baseUrl);
|
|
179
|
+
const response = await this.fetchImpl(url, {
|
|
180
|
+
method: "GET",
|
|
181
|
+
headers: this.headers
|
|
182
|
+
});
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
const body = await response.text();
|
|
185
|
+
throw new ExternalServiceError(`Cloudflare request failed with status ${response.status}.`, {
|
|
186
|
+
statusCode: response.status,
|
|
187
|
+
details: body
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const payload = await response.json();
|
|
191
|
+
const parsed = schema.safeParse(payload);
|
|
192
|
+
if (!parsed.success) {
|
|
193
|
+
throw new ExternalServiceError("Cloudflare returned an unexpected response shape.", {
|
|
194
|
+
details: parsed.error.flatten()
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return parsed.data;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var CloudflareWorkersServer = class extends ToolkitServer {
|
|
201
|
+
client;
|
|
202
|
+
constructor(client) {
|
|
203
|
+
super(metadata);
|
|
204
|
+
this.client = client;
|
|
205
|
+
this.registerTool(
|
|
206
|
+
defineTool({
|
|
207
|
+
name: "list_workers",
|
|
208
|
+
title: "List Workers",
|
|
209
|
+
description: "List worker scripts in the configured Cloudflare account.",
|
|
210
|
+
inputSchema: {
|
|
211
|
+
limit: z.number().int().min(1).max(100).default(20)
|
|
212
|
+
},
|
|
213
|
+
outputSchema: {
|
|
214
|
+
workers: z.array(workerSummarySchema),
|
|
215
|
+
returned: z.number().int()
|
|
216
|
+
},
|
|
217
|
+
handler: async ({ limit }, context) => {
|
|
218
|
+
await context.log("info", "Listing Cloudflare workers");
|
|
219
|
+
const workers = await this.client.listWorkers(limit);
|
|
220
|
+
return {
|
|
221
|
+
workers: [...workers],
|
|
222
|
+
returned: workers.length
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
renderText: ({ workers, returned }) => {
|
|
226
|
+
if (returned === 0) {
|
|
227
|
+
return "No Cloudflare workers found.";
|
|
228
|
+
}
|
|
229
|
+
return workers.map((worker) => `${worker.name} (${worker.usageModel ?? "standard"})`).join("\n");
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
);
|
|
233
|
+
this.registerTool(
|
|
234
|
+
defineTool({
|
|
235
|
+
name: "get_worker",
|
|
236
|
+
title: "Get worker",
|
|
237
|
+
description: "Fetch Cloudflare Worker settings for a specific script.",
|
|
238
|
+
inputSchema: {
|
|
239
|
+
scriptName: z.string().trim().min(1)
|
|
240
|
+
},
|
|
241
|
+
outputSchema: {
|
|
242
|
+
worker: workerDetailSchema
|
|
243
|
+
},
|
|
244
|
+
handler: async ({ scriptName }, context) => {
|
|
245
|
+
await context.log("info", `Fetching Cloudflare worker ${scriptName}`);
|
|
246
|
+
return {
|
|
247
|
+
worker: await this.client.getWorker(scriptName)
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
renderText: ({ worker }) => `${worker.name} uses ${worker.bindingsCount} bindings and ${worker.usageModel ?? "default"} mode.`
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
this.registerTool(
|
|
254
|
+
defineTool({
|
|
255
|
+
name: "list_routes",
|
|
256
|
+
title: "List worker routes",
|
|
257
|
+
description: "List routes attached to Cloudflare Workers in the account.",
|
|
258
|
+
inputSchema: {
|
|
259
|
+
limit: z.number().int().min(1).max(200).default(50),
|
|
260
|
+
scriptName: z.string().trim().min(1).optional()
|
|
261
|
+
},
|
|
262
|
+
outputSchema: {
|
|
263
|
+
routes: z.array(routeSchema),
|
|
264
|
+
returned: z.number().int()
|
|
265
|
+
},
|
|
266
|
+
handler: async ({ limit, scriptName }, context) => {
|
|
267
|
+
await context.log("info", "Listing Cloudflare worker routes");
|
|
268
|
+
const request = { limit };
|
|
269
|
+
if (scriptName !== void 0) {
|
|
270
|
+
request.scriptName = scriptName;
|
|
271
|
+
}
|
|
272
|
+
const routes = await this.client.listRoutes(request);
|
|
273
|
+
return {
|
|
274
|
+
routes: [...routes],
|
|
275
|
+
returned: routes.length
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
renderText: ({ routes, returned }) => {
|
|
279
|
+
if (returned === 0) {
|
|
280
|
+
return "No matching worker routes found.";
|
|
281
|
+
}
|
|
282
|
+
return routes.map((route) => `${route.pattern} -> ${route.script ?? "unbound"}`).join("\n");
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
);
|
|
286
|
+
this.registerStaticResource(
|
|
287
|
+
"account",
|
|
288
|
+
"cloudflare://account",
|
|
289
|
+
{
|
|
290
|
+
title: "Cloudflare account",
|
|
291
|
+
description: "Cloudflare account summary for the configured Workers account.",
|
|
292
|
+
mimeType: "application/json"
|
|
293
|
+
},
|
|
294
|
+
async (uri) => this.createJsonResource(uri.toString(), await this.client.getAccountSummary())
|
|
295
|
+
);
|
|
296
|
+
this.registerPrompt(
|
|
297
|
+
"edge-rollout",
|
|
298
|
+
{
|
|
299
|
+
title: "Edge rollout prompt",
|
|
300
|
+
description: "Create a rollout checklist for deploying or expanding a Worker.",
|
|
301
|
+
argsSchema: {
|
|
302
|
+
scriptName: z.string().trim().min(1),
|
|
303
|
+
routePattern: z.string().trim().min(1).optional(),
|
|
304
|
+
rolloutGoal: z.string().trim().min(1)
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
async ({ scriptName, routePattern, rolloutGoal }) => this.createTextPrompt(
|
|
308
|
+
[
|
|
309
|
+
`Plan a Cloudflare Workers rollout for "${scriptName}" with the goal: ${rolloutGoal}.`,
|
|
310
|
+
routePattern ? `Include route coverage for ${routePattern}.` : "Include route validation, traffic ramp-up, and rollback checks.",
|
|
311
|
+
"Call out caching, bindings, observability, and regional blast-radius considerations."
|
|
312
|
+
].join(" ")
|
|
313
|
+
)
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
async function createServer(options = {}) {
|
|
318
|
+
if (options.client) {
|
|
319
|
+
return new CloudflareWorkersServer(options.client);
|
|
320
|
+
}
|
|
321
|
+
const env = resolveEnv(options.env);
|
|
322
|
+
return new CloudflareWorkersServer(
|
|
323
|
+
new FetchCloudflareWorkersClient({
|
|
324
|
+
apiToken: env.CLOUDFLARE_API_TOKEN,
|
|
325
|
+
accountId: env.CLOUDFLARE_ACCOUNT_ID,
|
|
326
|
+
fetch: options.fetch ?? globalThis.fetch,
|
|
327
|
+
...env.CLOUDFLARE_API_BASE_URL ? { baseUrl: env.CLOUDFLARE_API_BASE_URL } : {}
|
|
328
|
+
})
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
function isMainModule(metaUrl) {
|
|
332
|
+
const entry = process.argv[1];
|
|
333
|
+
return typeof entry === "string" && fileURLToPath(metaUrl) === resolve(entry);
|
|
334
|
+
}
|
|
335
|
+
async function main(argv = process.argv.slice(2)) {
|
|
336
|
+
const runtimeOptions = parseRuntimeOptions(argv);
|
|
337
|
+
await runToolkitServer(
|
|
338
|
+
{
|
|
339
|
+
createServer: () => createServer(),
|
|
340
|
+
serverCard
|
|
341
|
+
},
|
|
342
|
+
runtimeOptions
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
if (isMainModule(import.meta.url)) {
|
|
346
|
+
await main();
|
|
347
|
+
}
|
|
348
|
+
export {
|
|
349
|
+
CloudflareWorkersServer,
|
|
350
|
+
createServer,
|
|
351
|
+
main,
|
|
352
|
+
metadata,
|
|
353
|
+
serverCard
|
|
354
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@universal-mcp-toolkit/server-cloudflare-workers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Worker, route, and deployment tools for Cloudflare Workers.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"server-cloudflare-workers": "./dist/index.js",
|
|
9
|
+
"umt-cloudflare-workers": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Markgatcha/universal-mcp-toolkit.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/Markgatcha/universal-mcp-toolkit#readme",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
".well-known"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"mcp",
|
|
29
|
+
"model-context-protocol",
|
|
30
|
+
"ai",
|
|
31
|
+
"developer-tools",
|
|
32
|
+
"typescript",
|
|
33
|
+
"cloudflare",
|
|
34
|
+
"workers",
|
|
35
|
+
"edge",
|
|
36
|
+
"deployments"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@universal-mcp-toolkit/core": "0.1.0",
|
|
40
|
+
"zod": "^4.3.6"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
47
|
+
"dev": "tsx watch src/index.ts",
|
|
48
|
+
"lint": "tsc --noEmit",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"test": "vitest run --passWithNoTests",
|
|
51
|
+
"clean": "rimraf dist"
|
|
52
|
+
}
|
|
53
|
+
}
|