pi-cloudflare 0.1.1 → 0.2.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/dist/oauth.js CHANGED
@@ -1,13 +1,13 @@
1
- import { randomBytes, createHash } from "node:crypto";
1
+ import { randomBytes, createHash } from 'node:crypto';
2
2
  function base64Url(bytes) {
3
3
  return Buffer.from(bytes)
4
- .toString("base64")
5
- .replace(/\+/g, "-")
6
- .replace(/\//g, "_")
7
- .replace(/=+$/, "");
4
+ .toString('base64')
5
+ .replace(/\+/g, '-')
6
+ .replace(/\//g, '_')
7
+ .replace(/=+$/, '');
8
8
  }
9
9
  export function pkceChallengeFor(verifier) {
10
- return base64Url(createHash("sha256").update(verifier).digest());
10
+ return base64Url(createHash('sha256').update(verifier).digest());
11
11
  }
12
12
  export function generatePkcePair() {
13
13
  const verifier = base64Url(randomBytes(32));
@@ -17,7 +17,7 @@ export function generateState() {
17
17
  return base64Url(randomBytes(16));
18
18
  }
19
19
  async function fetchJson(url) {
20
- const response = await fetch(url, { headers: { Accept: "application/json" } });
20
+ const response = await fetch(url, { headers: { Accept: 'application/json' } });
21
21
  if (!response.ok) {
22
22
  throw new Error(`GET ${url} failed with ${response.status}`);
23
23
  }
@@ -25,14 +25,14 @@ async function fetchJson(url) {
25
25
  }
26
26
  export async function discoverAuthServer(mcpUrl) {
27
27
  const challenge = await fetch(mcpUrl, {
28
- method: "POST",
29
- headers: { "Content-Type": "application/json" },
30
- body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "ping" }),
28
+ method: 'POST',
29
+ headers: { 'Content-Type': 'application/json' },
30
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'ping' }),
31
31
  });
32
32
  if (challenge.status !== 401) {
33
33
  throw new Error(`Expected 401 auth challenge from ${mcpUrl}, got ${challenge.status}`);
34
34
  }
35
- const wwwAuth = challenge.headers.get("www-authenticate") ?? "";
35
+ const wwwAuth = challenge.headers.get('www-authenticate') ?? '';
36
36
  const metadataUrl = /resource_metadata="([^"]+)"/.exec(wwwAuth)?.[1];
37
37
  if (!metadataUrl)
38
38
  throw new Error(`No resource metadata advertised by ${mcpUrl}`);
@@ -40,7 +40,7 @@ export async function discoverAuthServer(mcpUrl) {
40
40
  const issuer = resource.authorization_servers?.[0];
41
41
  if (!issuer)
42
42
  throw new Error(`No authorization server advertised by ${mcpUrl}`);
43
- const metadata = (await fetchJson(`${issuer.replace(/\/$/, "")}/.well-known/oauth-authorization-server`));
43
+ const metadata = (await fetchJson(`${issuer.replace(/\/$/, '')}/.well-known/oauth-authorization-server`));
44
44
  if (!metadata.authorization_endpoint || !metadata.token_endpoint) {
45
45
  throw new Error(`Incomplete OAuth metadata from ${issuer}`);
46
46
  }
@@ -53,13 +53,13 @@ export async function discoverAuthServer(mcpUrl) {
53
53
  }
54
54
  export async function registerClient(registrationEndpoint, redirectUri) {
55
55
  const response = await fetch(registrationEndpoint, {
56
- method: "POST",
57
- headers: { "Content-Type": "application/json" },
56
+ method: 'POST',
57
+ headers: { 'Content-Type': 'application/json' },
58
58
  body: JSON.stringify({
59
59
  redirect_uris: [redirectUri],
60
- grant_types: ["authorization_code", "refresh_token"],
61
- token_endpoint_auth_method: "none",
62
- client_name: "pi-cloudflare",
60
+ grant_types: ['authorization_code', 'refresh_token'],
61
+ token_endpoint_auth_method: 'none',
62
+ client_name: 'pi-cloudflare',
63
63
  }),
64
64
  });
65
65
  if (!response.ok) {
@@ -67,16 +67,16 @@ export async function registerClient(registrationEndpoint, redirectUri) {
67
67
  }
68
68
  const body = (await response.json());
69
69
  if (!body.client_id)
70
- throw new Error("Registration response had no client_id");
70
+ throw new Error('Registration response had no client_id');
71
71
  return { clientId: body.client_id, tokenEndpoint: registrationEndpoint };
72
72
  }
73
73
  export function buildAuthorizeUrl(options) {
74
74
  const params = new URLSearchParams({
75
- response_type: "code",
75
+ response_type: 'code',
76
76
  client_id: options.clientId,
77
77
  redirect_uri: options.redirectUri,
78
78
  code_challenge: options.challenge,
79
- code_challenge_method: "S256",
79
+ code_challenge_method: 'S256',
80
80
  state: options.state,
81
81
  resource: options.resource,
82
82
  });
@@ -84,15 +84,15 @@ export function buildAuthorizeUrl(options) {
84
84
  }
85
85
  export async function exchangeCode(options) {
86
86
  const body = new URLSearchParams({
87
- grant_type: "authorization_code",
87
+ grant_type: 'authorization_code',
88
88
  client_id: options.clientId,
89
89
  code: options.code,
90
90
  redirect_uri: options.redirectUri,
91
91
  code_verifier: options.verifier,
92
92
  });
93
93
  const response = await fetch(options.tokenEndpoint, {
94
- method: "POST",
95
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
94
+ method: 'POST',
95
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
96
96
  body: body.toString(),
97
97
  });
98
98
  if (!response.ok) {
@@ -102,13 +102,13 @@ export async function exchangeCode(options) {
102
102
  }
103
103
  export async function refreshAccessToken(options) {
104
104
  const body = new URLSearchParams({
105
- grant_type: "refresh_token",
105
+ grant_type: 'refresh_token',
106
106
  client_id: options.clientId,
107
107
  refresh_token: options.refreshToken,
108
108
  });
109
109
  const response = await fetch(options.tokenEndpoint, {
110
- method: "POST",
111
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
110
+ method: 'POST',
111
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
112
112
  body: body.toString(),
113
113
  });
114
114
  if (!response.ok) {
@@ -122,13 +122,13 @@ export async function refreshAccessToken(options) {
122
122
  }
123
123
  function readTokens(body) {
124
124
  const record = body;
125
- if (typeof record.access_token !== "string" || !record.access_token) {
126
- throw new Error("Token response had no access_token");
125
+ if (typeof record.access_token !== 'string' || !record.access_token) {
126
+ throw new Error('Token response had no access_token');
127
127
  }
128
- const lifetime = typeof record.expires_in === "number" ? record.expires_in : 3600;
128
+ const lifetime = typeof record.expires_in === 'number' ? record.expires_in : 3600;
129
129
  return {
130
130
  accessToken: record.access_token,
131
- refreshToken: typeof record.refresh_token === "string" ? record.refresh_token : undefined,
131
+ refreshToken: typeof record.refresh_token === 'string' ? record.refresh_token : undefined,
132
132
  expiresAt: Date.now() + Math.max(lifetime - 60, 0) * 1000,
133
133
  };
134
134
  }
package/dist/oauth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoBtD,SAAS,SAAS,CAAC,KAA0B;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SACtB,QAAQ,CAAC,QAAQ,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,GAAW;IAClC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;IAC/E,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG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;KACtB,CAAC,CAAA;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IACjE,CAAC;IACD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAChD,OAAO;QACL,GAAG,MAAM;QACT,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY;KAC1D,CAAA;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAa;IAC/B,MAAM,MAAM,GAAG,IAAiF,CAAA;IAChG,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAA;IACjF,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,YAAY,EAAE,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;QACzF,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI;KAC1D,CAAA;AACH,CAAC"}
package/dist/proxy.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ServerConnection } from "./client.js";
1
+ import type { ServerConnection } from './client.js';
2
2
  export interface ToolRegistration {
3
3
  name: string;
4
4
  label: string;
@@ -23,7 +23,7 @@ export declare function buildToolRegistrations(prefix: string, tools: UpstreamTo
23
23
  export declare function buildAllRegistrations(connections: Array<{
24
24
  prefix: string;
25
25
  tools: UpstreamTool[];
26
- callTool: ServerConnection["callTool"];
26
+ callTool: ServerConnection['callTool'];
27
27
  }>): ToolRegistration[];
28
28
  export {};
29
29
  //# sourceMappingURL=proxy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CACP,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,WAAW,GAAG,SAAS,KAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACzD;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAcD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,EAAE,EACrB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAChF,gBAAgB,EAAE,CAiBpB;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,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/dist/proxy.js CHANGED
@@ -1,12 +1,12 @@
1
- import { Type } from "typebox";
1
+ import { Type } from 'typebox';
2
2
  function toToolContent(result) {
3
- if (typeof result !== "object" || result === null) {
4
- return { content: [{ type: "text", text: String(result) }] };
3
+ if (typeof result !== 'object' || result === null) {
4
+ return { content: [{ type: 'text', text: String(result) }] };
5
5
  }
6
6
  const record = result;
7
7
  const content = Array.isArray(record.content) ? record.content : [];
8
- const output = content.length > 0 ? content : [{ type: "text", text: "" }];
9
- return typeof record.isError === "boolean" && record.isError
8
+ const output = content.length > 0 ? content : [{ type: 'text', text: '' }];
9
+ return typeof record.isError === 'boolean' && record.isError
10
10
  ? { content: output, isError: true }
11
11
  : { content: output };
12
12
  }
@@ -18,8 +18,8 @@ export function buildToolRegistrations(prefix, tools, callUpstream) {
18
18
  return tools.map((tool) => {
19
19
  const name = `${prefix}${tool.name}`;
20
20
  const description = tool.description?.trim()
21
- ? `[${prefix.replace(/_$/, "")}] ${tool.description}`
22
- : `[${prefix.replace(/_$/, "")}] ${tool.name}`;
21
+ ? `[${prefix.replace(/_$/, '')}] ${tool.description}`
22
+ : `[${prefix.replace(/_$/, '')}] ${tool.name}`;
23
23
  return {
24
24
  name,
25
25
  label: name,
package/dist/proxy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAsB/B,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/D,CAAC;IACD,MAAM,MAAM,GAAG,MAAkD,CAAC;IAClE,MAAM,OAAO,GAAG,KAAK,CAAC,OAA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MAAM,EAAE,CAAA;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAc,EACd,KAAqB,EACrB,YAAiF;IAEjF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QACpC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE;YAC1C,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,WAAW,EAAE;YACrD,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAA;QAChD,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI;YACX,WAAW;YACX,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;YACzC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;gBACrC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC,CAAA;gBAC1D,OAAO,aAAa,CAAC,MAAM,CAAC,CAAA;YAC9B,CAAC;SACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,qBAAqB,CACnC,WAIE;IAEF,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CACxC,sBAAsB,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CACjF,CAAA;AACH,CAAC"}
package/dist/servers.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Streamable HTTP endpoints; authentication (when required) is a Bearer
4
4
  * token from the environment, never from config files.
5
5
  */
6
- export type CloudflareServerId = "api" | "docs" | "bindings" | "builds" | "observability";
6
+ export type CloudflareServerId = 'api' | 'docs' | 'bindings' | 'builds' | 'observability';
7
7
  export interface CloudflareServerDefinition {
8
8
  id: CloudflareServerId;
9
9
  /** Tool prefix, e.g. `cf_api_` for the API server. */
@@ -1 +1 @@
1
- {"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../src/servers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE1F,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,kBAAkB,CAAC;IACvB,sDAAsD;IACtD,MAAM,EAAE,MAAM,MAAM,GAAG,CAAC;IACxB,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,EAAE,SAAS,0BAA0B,EAiCnE,CAAC;AAEF,wBAAgB,UAAU,CAAC,EAAE,EAAE,kBAAkB,GAAG,0BAA0B,CAI7E"}
1
+ {"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../src/servers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,eAAe,CAAA;AAEzF,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,kBAAkB,CAAA;IACtB,sDAAsD;IACtD,MAAM,EAAE,MAAM,MAAM,GAAG,CAAA;IACvB,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,eAAO,MAAM,kBAAkB,EAAE,SAAS,0BAA0B,EAiCnE,CAAA;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,kBAAkB,GAAG,0BAA0B,CAI7E"}
package/dist/servers.js CHANGED
@@ -1,34 +1,34 @@
1
1
  export const CLOUDFLARE_SERVERS = [
2
2
  {
3
- id: "api",
4
- prefix: "cf_api_",
5
- url: "https://mcp.cloudflare.com/mcp",
6
- description: "Full Cloudflare API (2,500+ endpoints: Workers, R2, DNS, Zero Trust) via search and execute tools.",
3
+ id: 'api',
4
+ prefix: 'cf_api_',
5
+ url: 'https://mcp.cloudflare.com/mcp',
6
+ description: 'Full Cloudflare API (2,500+ endpoints: Workers, R2, DNS, Zero Trust) via search and execute tools.',
7
7
  },
8
8
  {
9
- id: "docs",
10
- prefix: "cf_docs_",
11
- url: "https://docs.mcp.cloudflare.com/mcp",
9
+ id: 'docs',
10
+ prefix: 'cf_docs_',
11
+ url: 'https://docs.mcp.cloudflare.com/mcp',
12
12
  public: true,
13
- description: "Up-to-date Cloudflare developer documentation search and fetch.",
13
+ description: 'Up-to-date Cloudflare developer documentation search and fetch.',
14
14
  },
15
15
  {
16
- id: "bindings",
17
- prefix: "cf_bindings_",
18
- url: "https://bindings.mcp.cloudflare.com/mcp",
19
- description: "Workers primitives guidance (KV, R2, D1, Durable Objects, AI).",
16
+ id: 'bindings',
17
+ prefix: 'cf_bindings_',
18
+ url: 'https://bindings.mcp.cloudflare.com/mcp',
19
+ description: 'Workers primitives guidance (KV, R2, D1, Durable Objects, AI).',
20
20
  },
21
21
  {
22
- id: "builds",
23
- prefix: "cf_builds_",
24
- url: "https://builds.mcp.cloudflare.com/mcp",
25
- description: "Workers Builds insights and management.",
22
+ id: 'builds',
23
+ prefix: 'cf_builds_',
24
+ url: 'https://builds.mcp.cloudflare.com/mcp',
25
+ description: 'Workers Builds insights and management.',
26
26
  },
27
27
  {
28
- id: "observability",
29
- prefix: "cf_obs_",
30
- url: "https://observability.mcp.cloudflare.com/mcp",
31
- description: "Workers logs, metrics, and traces analysis.",
28
+ id: 'observability',
29
+ prefix: 'cf_obs_',
30
+ url: 'https://observability.mcp.cloudflare.com/mcp',
31
+ description: 'Workers logs, metrics, and traces analysis.',
32
32
  },
33
33
  ];
34
34
  export function serverById(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"servers.js","sourceRoot":"","sources":["../src/servers.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,kBAAkB,GAA0C;IACvE;QACE,EAAE,EAAE,KAAK;QACT,MAAM,EAAE,SAAS;QACjB,GAAG,EAAE,gCAAgC;QACrC,WAAW,EACT,oGAAoG;KACvG;IACD;QACE,EAAE,EAAE,MAAM;QACV,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE,qCAAqC;QAC1C,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,iEAAiE;KAC/E;IACD;QACE,EAAE,EAAE,UAAU;QACd,MAAM,EAAE,cAAc;QACtB,GAAG,EAAE,yCAAyC;QAC9C,WAAW,EAAE,gEAAgE;KAC9E;IACD;QACE,EAAE,EAAE,QAAQ;QACZ,MAAM,EAAE,YAAY;QACpB,GAAG,EAAE,uCAAuC;QAC5C,WAAW,EAAE,yCAAyC;KACvD;IACD;QACE,EAAE,EAAE,eAAe;QACnB,MAAM,EAAE,SAAS;QACjB,GAAG,EAAE,8CAA8C;QACnD,WAAW,EAAE,6CAA6C;KAC3D;CACF,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,EAAsB;IAC/C,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"servers.js","sourceRoot":"","sources":["../src/servers.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,kBAAkB,GAA0C;IACvE;QACE,EAAE,EAAE,KAAK;QACT,MAAM,EAAE,SAAS;QACjB,GAAG,EAAE,gCAAgC;QACrC,WAAW,EACT,oGAAoG;KACvG;IACD;QACE,EAAE,EAAE,MAAM;QACV,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE,qCAAqC;QAC1C,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,iEAAiE;KAC/E;IACD;QACE,EAAE,EAAE,UAAU;QACd,MAAM,EAAE,cAAc;QACtB,GAAG,EAAE,yCAAyC;QAC9C,WAAW,EAAE,gEAAgE;KAC9E;IACD;QACE,EAAE,EAAE,QAAQ;QACZ,MAAM,EAAE,YAAY;QACpB,GAAG,EAAE,uCAAuC;QAC5C,WAAW,EAAE,yCAAyC;KACvD;IACD;QACE,EAAE,EAAE,eAAe;QACnB,MAAM,EAAE,SAAS;QACjB,GAAG,EAAE,8CAA8C;QACnD,WAAW,EAAE,6CAA6C;KAC3D;CACF,CAAA;AAED,MAAM,UAAU,UAAU,CAAC,EAAsB;IAC/C,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACnE,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAA;IACnE,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { CloudflareServerId } from "./servers.js";
2
- import type { OAuthTokens } from "./oauth.js";
1
+ import type { CloudflareServerId } from './servers.js';
2
+ import type { OAuthTokens } from './oauth.js';
3
3
  export interface StoredServerTokens extends OAuthTokens {
4
4
  clientId: string;
5
5
  tokenEndpoint: string;
@@ -13,7 +13,7 @@ export declare function tokenFilePath(home?: string): string;
13
13
  export declare function readTokenFile(home?: string): TokenFile | undefined;
14
14
  /** Persist per-server tokens with owner-only permissions. Never logs values. */
15
15
  export declare function writeTokenFile(servers: Partial<Record<CloudflareServerId, StoredServerTokens>>, home?: string): void;
16
- export declare function isExpired(tokens: Pick<OAuthTokens, "expiresAt">, skewMs?: number): boolean;
16
+ export declare function isExpired(tokens: Pick<OAuthTokens, 'expiresAt'>, skewMs?: number): boolean;
17
17
  /** Split server ids into fresh (skip) vs needing approval. */
18
18
  export declare function partitionServers(ids: CloudflareServerId[], stored: Partial<Record<CloudflareServerId, StoredServerTokens>> | undefined): {
19
19
  fresh: CloudflareServerId[];
@@ -1 +1 @@
1
- {"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../src/token-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,SAAS;IACjB,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAClE;AAED,wBAAgB,aAAa,CAAC,IAAI,SAAY,GAAG,MAAM,CAEtD;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,SAAY,GAAG,SAAS,GAAG,SAAS,CAUrE;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,EAChE,IAAI,SAAY,GACf,IAAI,CAON;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,MAAM,SAAS,GAAG,OAAO,CAE1F;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,EAAE,OAAO,CAAC,MAAM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
@@ -1,8 +1,8 @@
1
- import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
4
  export function tokenFilePath(home = homedir()) {
5
- return join(home, ".pi", "cloudflare-tokens.json");
5
+ return join(home, '.pi', 'cloudflare-tokens.json');
6
6
  }
7
7
  /** Read stored per-server OAuth tokens. Missing file means not authenticated. */
8
8
  export function readTokenFile(home = homedir()) {
@@ -10,8 +10,8 @@ export function readTokenFile(home = homedir()) {
10
10
  if (!existsSync(path))
11
11
  return undefined;
12
12
  try {
13
- const parsed = JSON.parse(readFileSync(path, "utf8"));
14
- if (parsed?.version !== 1 || typeof parsed.servers !== "object")
13
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
14
+ if (parsed?.version !== 1 || typeof parsed.servers !== 'object')
15
15
  return undefined;
16
16
  return parsed;
17
17
  }
@@ -22,8 +22,8 @@ export function readTokenFile(home = homedir()) {
22
22
  /** Persist per-server tokens with owner-only permissions. Never logs values. */
23
23
  export function writeTokenFile(servers, home = homedir()) {
24
24
  const path = tokenFilePath(home);
25
- mkdirSync(join(home, ".pi"), { recursive: true });
26
- writeFileSync(path, JSON.stringify({ version: 1, servers }, null, 2) + "\n", {
25
+ mkdirSync(join(home, '.pi'), { recursive: true });
26
+ writeFileSync(path, JSON.stringify({ version: 1, servers }, null, 2) + '\n', {
27
27
  mode: 0o600,
28
28
  });
29
29
  chmodSync(path, 0o600);
@@ -1 +1 @@
1
- {"version":3,"file":"token-store.js","sourceRoot":"","sources":["../src/token-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;A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AE,CAAC,CAAA;;YACzC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cloudflare",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Pi extension proxying Cloudflare's official MCP servers (API, docs, bindings, builds, observability) with cf_ prefixed tools.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -1,79 +0,0 @@
1
- # Cloudflare Artifacts
2
-
3
- Store versioned file trees behind a repo-style interface that works from Workers, the REST API, and Git-compatible tooling.
4
-
5
- ## Overview
6
-
7
- Use **Artifacts** when the thing you need to store is a versioned filesystem tree rather than a single object, key, or SQL row.
8
-
9
- Typical Artifacts use cases:
10
- - Git-style repositories
11
- - Per-agent, per-session, or per-task repos
12
- - Build outputs and deployment bundles
13
- - Checkpoints and generated assets
14
- - Shared file trees passed between developer tools and Workers
15
-
16
- Artifacts is a good fit when the same content needs to be addressable from **Workers**, the **REST API**, and **Git-compatible clients**.
17
-
18
- Artifacts is especially useful for agent and automation workflows where each unit of work should have its own isolated repo and token.
19
-
20
- **Prefer retrieval over memory** for current availability, authentication details, route shapes, limits, and pricing. Start at `https://developers.cloudflare.com/artifacts/`.
21
-
22
- ## When to Use Artifacts
23
-
24
- | Need | Use | Why |
25
- |------|-----|-----|
26
- | Versioned file trees such as repos, build outputs, checkpoints, or generated assets | Artifacts | Artifacts stores and shares **versioned filesystem content** |
27
- | A git-compatible workflow with `clone`, `fetch`, `pull`, or `push` | Artifacts | Artifacts exposes **git-over-HTTPS remotes** and repo-scoped tokens |
28
- | The same artifact accessible from Workers, HTTP APIs, and developer tooling | Artifacts | Artifacts is available through a **Workers binding**, **REST API**, and **git-compatible interface** |
29
- | Large files by object key, app config by key, or relational app data | R2, KV, or D1 | Use storage products directly when you need **objects, key-value entries, or SQL rows**, not versioned file trees |
30
-
31
- ## Recommended Workflow
32
-
33
- - Create one repo per agent, session, user workspace, or task when work should stay isolated.
34
- - Fork from a stable baseline when many repos need the same starter files or prompts.
35
- - Use branches only when collaborators share the same lifecycle and need to work in one repo.
36
- - Use namespaces to separate environments, teams, or high-rate workloads.
37
-
38
- ## Quick Start
39
-
40
- **From a Worker:**
41
-
42
- ```typescript
43
- interface Env {
44
- ARTIFACTS: Artifacts;
45
- }
46
-
47
- const created = await env.ARTIFACTS.create("starter-repo");
48
- // created.remote -> git remote URL
49
- // created.token -> initial repo token
50
- ```
51
-
52
- **From the REST API:**
53
-
54
- Use the namespace-scoped Artifacts base URL plus a gateway JWT. For imports from existing HTTPS remotes, use the REST API rather than the Workers binding.
55
-
56
- ## Reading Order
57
-
58
- | Task | Read |
59
- |------|------|
60
- | Decide whether Artifacts is the right product | README only |
61
- | Create or manage repos from a Worker | README → configuration.md → api.md |
62
- | Integrate Artifacts from an external system | README → api.md |
63
- | Set up agent or sandbox workflows | README → configuration.md |
64
- | Verify exact auth, routes, limits, or pricing | Live docs first: `https://developers.cloudflare.com/artifacts/` |
65
-
66
- ## In This Reference
67
-
68
- - **[api.md](api.md)** - Workers binding methods, REST routes, token and repo operations
69
- - **[configuration.md](configuration.md)** - Wrangler binding shape, Worker typing, REST configuration guidance
70
-
71
- ## See Also
72
-
73
- - [Cloudflare Artifacts Docs](https://developers.cloudflare.com/artifacts/)
74
- - [Artifacts Git Protocol Docs](https://developers.cloudflare.com/artifacts/api/git-protocol/)
75
- - [ArtifactFS Docs](https://developers.cloudflare.com/artifacts/api/artifactfs/)
76
- - [Cloudflare Workers Docs](https://developers.cloudflare.com/workers/)
77
- - [Cloudflare Durable Objects Docs](https://developers.cloudflare.com/durable-objects/)
78
- - [Cloudflare R2 Docs](https://developers.cloudflare.com/r2/)
79
- - [Cloudflare D1 Docs](https://developers.cloudflare.com/d1/)
@@ -1,128 +0,0 @@
1
- # Artifacts API Reference
2
-
3
- Use Artifacts through the **Workers binding**, the **REST control plane**, and **Git-compatible remotes**.
4
-
5
- **Prefer retrieval** for exact request and response details. Verify current behavior at `https://developers.cloudflare.com/artifacts/` before relying on specific auth flows, route details, or generated binding types.
6
-
7
- ## Workers Binding
8
-
9
- Artifacts exposes a Worker binding on `env.ARTIFACTS`.
10
-
11
- ### Namespace Methods
12
-
13
- | Method | Use For |
14
- |--------|---------|
15
- | `create(name, opts?)` | Create a repo and receive its initial remote and token |
16
- | `get(name)` | Resolve a repo handle for repo-scoped operations |
17
- | `list(opts?)` | List repos in a namespace |
18
- | `delete(name)` | Delete a repo |
19
-
20
- ```typescript
21
- const created = await env.ARTIFACTS.create("starter-repo", {
22
- description: "Repository for automation experiments",
23
- setDefaultBranch: "main"
24
- });
25
- const repo = await env.ARTIFACTS.get("starter-repo");
26
- const page = await env.ARTIFACTS.list({ limit: 10 });
27
- ```
28
-
29
- Use the REST API when you need to import a repo from another HTTPS remote.
30
-
31
- ### Repo Handle Methods
32
-
33
- Use a repo handle returned by `get()` or `create()`.
34
-
35
- | Method | Use For |
36
- |--------|---------|
37
- | `info()` | Read repo metadata, including the remote URL |
38
- | `createToken(scope?, ttl?)` | Mint a repo-scoped read or write token |
39
- | `listTokens()` | Inspect active tokens |
40
- | `validateToken(token)` | Check whether a token is still valid |
41
- | `revokeToken(tokenOrId)` | Revoke a token by ID or value |
42
- | `fork(name, opts?)` | Fork one repo into another |
43
-
44
- ```typescript
45
- const repo = await env.ARTIFACTS.get("starter-repo");
46
- if (!repo) throw new Error("Repo not found");
47
-
48
- const info = await repo.info();
49
- const token = await repo.createToken("read", 3600);
50
- const forked = await repo.fork("starter-repo-copy", {
51
- defaultBranchOnly: true
52
- });
53
- ```
54
-
55
- ### Binding Notes
56
-
57
- - Current docs describe the runtime binding surface as `create`, `get`, `list`, `delete`, and repo-handle methods like `info`, `createToken`, and `fork`.
58
- - Use `npx wrangler types` in the target project and treat the generated `worker-configuration.d.ts` as the source of truth for that environment.
59
- - If generated types appear to expose `import()` or a different `get()` shape, verify the live docs before depending on those methods.
60
-
61
- Verify current runtime behavior in the live docs before depending on methods that are not shown in the Workers binding reference.
62
-
63
- ## REST API
64
-
65
- Artifacts currently documents a namespace-scoped control plane:
66
-
67
- ```txt
68
- https://artifacts.cloudflare.net/v1/api/namespaces/$ARTIFACTS_NAMESPACE
69
- ```
70
-
71
- Some deployments also expose an `/edge/v1/api/...` base path. Verify the correct base URL for your environment in the live docs.
72
-
73
- Requests to the standard `/v1/api/...` routes use a **gateway JWT** with Bearer authentication.
74
-
75
- Returned repo tokens authenticate **Git operations** against the repo `remote`. They do not authenticate REST control-plane requests.
76
-
77
- Current docs show the standard Cloudflare v4 response envelope around REST results.
78
-
79
- ### Repo Routes
80
-
81
- | Route | Use For |
82
- |-------|---------|
83
- | `POST /repos` | Create a repo |
84
- | `GET /repos` | List repos |
85
- | `GET /repos/:name` | Read repo metadata and remote |
86
- | `DELETE /repos/:name` | Delete a repo |
87
- | `POST /repos/:name/fork` | Fork a repo |
88
- | `POST /repos/:name/import` | Import a public HTTPS remote |
89
-
90
- ```bash
91
- curl --request POST "$ARTIFACTS_BASE_URL/repos" \
92
- --header "Authorization: Bearer $ARTIFACTS_JWT" \
93
- --header "Content-Type: application/json" \
94
- --data '{"name":"starter-repo"}'
95
- ```
96
-
97
- Important current details from the docs draft:
98
- - `POST /repos/:name/import` accepts a full HTTPS remote URL such as GitHub or GitLab.
99
- - Import supports options such as `branch`, `depth`, and `read_only`.
100
- - Repo metadata includes fields such as description, default branch, timestamps, and the Git `remote`.
101
-
102
- ### Token Routes
103
-
104
- | Route | Use For |
105
- |-------|---------|
106
- | `GET /repos/:name/tokens` | List repo tokens |
107
- | `POST /tokens` | Create a token for a repo |
108
- | `DELETE /tokens/:id` | Revoke a token by ID |
109
-
110
- Current docs show list-token filtering and pagination by token state. Retrieve the exact query shape from the live docs when you need token audit or cleanup workflows.
111
-
112
- Use **read** tokens for clone, fetch, pull, and indexing workflows. Use **write** tokens only when a workflow must push or otherwise mutate a repo.
113
-
114
- ## Git-Compatible Access
115
-
116
- Artifacts returns repo `remote` URLs that work with standard git-over-HTTPS tooling.
117
-
118
- Recommended current auth pattern for local workflows:
119
-
120
- ```bash
121
- git -c http.extraHeader="Authorization: Bearer $ARTIFACTS_TOKEN" clone "$ARTIFACTS_REMOTE" artifacts-clone
122
- ```
123
-
124
- Use a self-contained Basic-auth remote only for short-lived commands that need credentials embedded in the URL.
125
-
126
- `read` tokens support `clone`, `fetch`, and `pull`. `git push` requires a `write` token.
127
-
128
- For large repos where startup time matters more than a full clone, Artifacts also documents **ArtifactFS**. Retrieve current details from `https://developers.cloudflare.com/artifacts/` when you need mount-style access.