@tinycloud/mcp 0.10.1-beta.4 → 0.11.0-beta.10

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/http.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/http.ts
2
- import { join as join3 } from "path";
2
+ import { join as join4 } from "path";
3
3
  import {
4
4
  McpServer as McpServer2,
5
5
  createMcpHandler,
@@ -11,6 +11,95 @@ import {
11
11
  } from "@modelcontextprotocol/server";
12
12
  import { RUNTIME_DELEGATION_REJECTIONS } from "@tinycloud/node-sdk";
13
13
 
14
+ // src/agent-discovery.ts
15
+ import { createHash } from "crypto";
16
+ import { readFileSync } from "fs";
17
+ import { dirname, join } from "path";
18
+ import { fileURLToPath } from "url";
19
+ var DOCUMENTATION_URL = "https://docs.tinycloud.xyz/cli/mcp";
20
+ var SKILL_NAME = "tinycloud-delegated-secrets";
21
+ var LOCAL_PACKAGES = [["@tinycloud", "cli"].join("/"), ["@tinycloud", "mcp"].join("/")];
22
+ var WEBMCP_SCRIPT_PATH = "/webmcp.js";
23
+ var WEBMCP_TOOL_NAME = "get_tinycloud_mcp_connection";
24
+ var A2A_AGENT_CARD_URL = "https://tinycloud.xyz/.well-known/agent-card.json";
25
+ var moduleDirectory = typeof __dirname === "string" ? __dirname : dirname(fileURLToPath(import.meta.url));
26
+ var skillPath = join(moduleDirectory, "..", "skills", SKILL_NAME, "SKILL.md");
27
+ function agentDiscoveryRoutes(resourceUrl, issuer, requiredScope) {
28
+ const at = (path) => new URL(path, resourceUrl).toString();
29
+ const serverCardUrl = at("/.well-known/mcp/server-card.json");
30
+ const skillUrlPath = `/.well-known/agent-skills/${SKILL_NAME}/SKILL.md`;
31
+ const skill = readFileSync(skillPath);
32
+ const apiCatalog = JSON.stringify({
33
+ linkset: [{
34
+ anchor: resourceUrl.toString(),
35
+ "service-desc": [{ href: serverCardUrl, type: "application/json" }],
36
+ "service-doc": [{ href: DOCUMENTATION_URL, type: "text/html" }],
37
+ status: [{ href: at("/healthz"), type: "application/json" }]
38
+ }]
39
+ });
40
+ const skillsIndex = JSON.stringify({
41
+ $schema: "https://schemas.agentskills.io/discovery/0.2.0/schema.json",
42
+ skills: [{
43
+ name: SKILL_NAME,
44
+ type: "skill-md",
45
+ description: skillDescription(skill.toString("utf8")),
46
+ url: at(skillUrlPath),
47
+ digest: `sha256:${createHash("sha256").update(skill).digest("hex")}`
48
+ }]
49
+ });
50
+ const connection = {
51
+ endpoint: resourceUrl.toString(),
52
+ transport: "streamable-http",
53
+ authorization: {
54
+ type: "oauth2",
55
+ authorizationServer: issuer,
56
+ protectedResourceMetadata: at(`/.well-known/oauth-protected-resource${resourceUrl.pathname}`),
57
+ scope: requiredScope
58
+ },
59
+ serverCard: serverCardUrl,
60
+ documentation: DOCUMENTATION_URL,
61
+ localAlternative: { packages: LOCAL_PACKAGES, stdioServer: "tinycloud-mcp" }
62
+ };
63
+ const webMcpScript = `(() => {
64
+ const modelContext = (typeof document !== "undefined" && document.modelContext) ||
65
+ (typeof navigator !== "undefined" && navigator.modelContext);
66
+ if (!modelContext || typeof modelContext.registerTool !== "function") return;
67
+ const connection = ${JSON.stringify(connection)};
68
+ modelContext.registerTool({
69
+ name: ${JSON.stringify(WEBMCP_TOOL_NAME)},
70
+ description: "Returns how to connect to TinyCloud MCP: the hosted endpoint, its transport, OAuth discovery, the documentation link and the local stdio option shown on this page.",
71
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
72
+ annotations: { readOnlyHint: true },
73
+ execute() {
74
+ return { content: [{ type: "text", text: JSON.stringify(connection) }], structuredContent: connection };
75
+ },
76
+ });
77
+ })();
78
+ `;
79
+ const cached = (body, contentType) => () => new Response(body, {
80
+ headers: {
81
+ "content-type": contentType,
82
+ "cache-control": "public, max-age=300",
83
+ "x-content-type-options": "nosniff"
84
+ }
85
+ });
86
+ return /* @__PURE__ */ new Map([
87
+ ["/.well-known/api-catalog", cached(apiCatalog, 'application/linkset+json; profile="https://www.rfc-editor.org/info/rfc9727"')],
88
+ ["/.well-known/agent-skills/index.json", cached(skillsIndex, "application/json; charset=utf-8")],
89
+ [skillUrlPath, cached(skill, "text/markdown; charset=utf-8")],
90
+ ["/.well-known/agent-card.json", () => new Response(null, {
91
+ status: 302,
92
+ headers: { location: A2A_AGENT_CARD_URL, "cache-control": "public, max-age=300" }
93
+ })],
94
+ [WEBMCP_SCRIPT_PATH, cached(webMcpScript, "text/javascript; charset=utf-8")]
95
+ ]);
96
+ }
97
+ function skillDescription(skill) {
98
+ const description = /^---\n(?:.*\n)*?description: (.+)\n(?:.*\n)*?---\n/.exec(skill)?.[1];
99
+ if (description === void 0) throw new Error(`${SKILL_NAME}/SKILL.md must declare a frontmatter description.`);
100
+ return description;
101
+ }
102
+
14
103
  // src/oauth.ts
15
104
  import {
16
105
  OAuthError,
@@ -104,7 +193,7 @@ function firstString(...values) {
104
193
  }
105
194
 
106
195
  // src/token-status.ts
107
- import { createHash } from "crypto";
196
+ import { createHash as createHash2 } from "crypto";
108
197
  import { decodeJwt } from "jose";
109
198
  var ACTIVE_CACHE_MS = 3e4;
110
199
  var UNKNOWN_TOLERANCE_MS = 6e4;
@@ -201,7 +290,7 @@ function createTokenStatusChecker(config) {
201
290
  }
202
291
  return {
203
292
  async tokenStatus(token) {
204
- const key = createHash("sha256").update(token).digest("hex");
293
+ const key = createHash2("sha256").update(token).digest("hex");
205
294
  const now = clock();
206
295
  const elapsed = monotonic();
207
296
  const inactiveUntil = inactive.get(key);
@@ -216,7 +305,7 @@ function createTokenStatusChecker(config) {
216
305
  },
217
306
  toleratesUnknown(token) {
218
307
  if (credentialsRefused) return false;
219
- const confirmed = confirmedActive.get(createHash("sha256").update(token).digest("hex"));
308
+ const confirmed = confirmedActive.get(createHash2("sha256").update(token).digest("hex"));
220
309
  if (confirmed === void 0) return false;
221
310
  return confirmed.expiresAt > clock() && monotonic() - confirmed.at < UNKNOWN_TOLERANCE_MS;
222
311
  }
@@ -263,7 +352,7 @@ function logToolCall(tool, code, startedAt, replayedGrants) {
263
352
  import { sameTinyCloudNode } from "@tinycloud/sdk-core";
264
353
  import { createHmac, randomBytes, timingSafeEqual as timingSafeEqual2 } from "crypto";
265
354
  import { chmod, mkdir, readFile, readdir, rename, rm, writeFile } from "fs/promises";
266
- import { dirname, join } from "path";
355
+ import { dirname as dirname2, join as join2 } from "path";
267
356
  import {
268
357
  activateValidatedRuntimeDelegation,
269
358
  deserializeDelegation,
@@ -428,7 +517,7 @@ var RemoteTenantStore = class {
428
517
  const canonical = canonicalOwnerDid(ownerDid);
429
518
  if (canonical === void 0) throw new NativeGrantValidationError("rejected");
430
519
  const tenant = createHmac("sha256", this.#config.stateSecret).update(`native-tenant:${canonical}`).digest("hex");
431
- return join(this.#config.stateDir, "native-tenants", tenant);
520
+ return join2(this.#config.stateDir, "native-tenants", tenant);
432
521
  }
433
522
  async acceptNativeGrant(serializedDelegation) {
434
523
  if (Buffer.byteLength(serializedDelegation) > MAX_CALLBACK_BYTES) {
@@ -596,7 +685,7 @@ var RemoteTenantStore = class {
596
685
  if (Date.parse(stored.expiresAt) <= Date.now()) throw new NativeGrantValidationError("expired");
597
686
  }
598
687
  tenantStateRoot(subject) {
599
- return join(this.#config.stateDir, "tenants", this.#tenantId(subject));
688
+ return join2(this.#config.stateDir, "tenants", this.#tenantId(subject));
600
689
  }
601
690
  /** Prepare only this authenticated account's profile before its first operation. */
602
691
  async initializeTenant(subject) {
@@ -809,7 +898,7 @@ var RemoteTenantStore = class {
809
898
  }
810
899
  if (!isRecord(data)) throw new ApprovalRequestError("body_invalid", "Callback body is invalid.");
811
900
  const pending = await this.#readPending(state, true);
812
- const stateRoot = join(this.#config.stateDir, "tenants", pending.tenantId);
901
+ const stateRoot = join2(this.#config.stateDir, "tenants", pending.tenantId);
813
902
  const prior = this.#approvalProcessing.get(stateRoot);
814
903
  const processing = (async () => {
815
904
  if (prior) await prior.catch(() => void 0);
@@ -1047,7 +1136,7 @@ var RemoteTenantStore = class {
1047
1136
  approvalEpoch: this.#approvalEpochs.get(tenant.stateRoot)
1048
1137
  });
1049
1138
  await rm(this.#additionalPath(tenant.stateRoot), { force: true });
1050
- await rm(join(tenant.stateRoot, ".tinycloud", "profiles", PROFILE, "auth-requests.json"), { force: true });
1139
+ await rm(join2(tenant.stateRoot, ".tinycloud", "profiles", PROFILE, "auth-requests.json"), { force: true });
1051
1140
  await rm(this.#pendingDirectory(tenant.stateRoot), { recursive: true, force: true });
1052
1141
  await rm(this.#sessionPath(tenant.stateRoot), { force: true });
1053
1142
  })().finally(() => this.#clearing.delete(tenant.stateRoot));
@@ -1055,9 +1144,9 @@ var RemoteTenantStore = class {
1055
1144
  await clearing;
1056
1145
  }
1057
1146
  async #initializeTenant(tenantId) {
1058
- const stateRoot = join(this.#config.stateDir, "tenants", tenantId);
1147
+ const stateRoot = join2(this.#config.stateDir, "tenants", tenantId);
1059
1148
  const keyPath = this.#keyPath(stateRoot);
1060
- await secureDirectory(join(stateRoot, ".tinycloud", "profiles", PROFILE));
1149
+ await secureDirectory(join2(stateRoot, ".tinycloud", "profiles", PROFILE));
1061
1150
  let jwk = await readJson(keyPath);
1062
1151
  let sessionDid;
1063
1152
  if (jwk === null) {
@@ -1097,7 +1186,7 @@ var RemoteTenantStore = class {
1097
1186
  }
1098
1187
  async #readTenant(tenantId) {
1099
1188
  if (!/^[a-f0-9]{64}$/.test(tenantId)) throw new ApprovalRequestError("state_invalid", "Approval state is invalid.");
1100
- const stateRoot = join(this.#config.stateDir, "tenants", tenantId);
1189
+ const stateRoot = join2(this.#config.stateDir, "tenants", tenantId);
1101
1190
  const jwk = await readJson(this.#keyPath(stateRoot));
1102
1191
  if (jwk === null) throw new ApprovalRequestError("tenant_missing", "The TinyCloud delegate no longer exists.");
1103
1192
  const profile = await readJson(this.#profilePath(stateRoot));
@@ -1151,7 +1240,7 @@ var RemoteTenantStore = class {
1151
1240
  if (supplied.length !== expectedBytes.length || !timingSafeEqual2(supplied, expectedBytes)) {
1152
1241
  throw new ApprovalRequestError("state_invalid", "Approval state is invalid.");
1153
1242
  }
1154
- const stateRoot = join(this.#config.stateDir, "tenants", tenantId);
1243
+ const stateRoot = join2(this.#config.stateDir, "tenants", tenantId);
1155
1244
  const path = this.#pendingPath(stateRoot, nonce);
1156
1245
  const claimed = `${path}.processing`;
1157
1246
  if (consume) {
@@ -1190,7 +1279,7 @@ var RemoteTenantStore = class {
1190
1279
  }
1191
1280
  }
1192
1281
  async #restorePending(pending) {
1193
- const stateRoot = join(this.#config.stateDir, "tenants", pending.tenantId);
1282
+ const stateRoot = join2(this.#config.stateDir, "tenants", pending.tenantId);
1194
1283
  const path = this.#pendingPath(stateRoot, pending.nonce);
1195
1284
  await rename(`${path}.processing`, path);
1196
1285
  }
@@ -1225,8 +1314,8 @@ var RemoteTenantStore = class {
1225
1314
  return this.#nativeIdentity;
1226
1315
  }
1227
1316
  async #readOrCreateNativeServiceKey() {
1228
- const path = join(this.#config.stateDir, ".tinycloud", "native-service-key.json");
1229
- await secureDirectory(dirname(path));
1317
+ const path = join2(this.#config.stateDir, ".tinycloud", "native-service-key.json");
1318
+ await secureDirectory(dirname2(path));
1230
1319
  let stored = await readJson(path);
1231
1320
  if (stored === null) {
1232
1321
  const generated = generateSessionKey();
@@ -1314,7 +1403,7 @@ var RemoteTenantStore = class {
1314
1403
  }
1315
1404
  }
1316
1405
  #nativeGrantPath(stateRoot) {
1317
- return join(stateRoot, ".tinycloud", "native-grant.json");
1406
+ return join2(stateRoot, ".tinycloud", "native-grant.json");
1318
1407
  }
1319
1408
  #tenantId(subject) {
1320
1409
  return createHmac("sha256", this.#config.stateSecret).update(`tenant:${subject}`).digest("hex");
@@ -1323,22 +1412,22 @@ var RemoteTenantStore = class {
1323
1412
  return createHmac("sha256", this.#config.stateSecret).update(`approval:${tenantId}:${nonce}`).digest("base64url");
1324
1413
  }
1325
1414
  #profilePath(stateRoot) {
1326
- return join(stateRoot, ".tinycloud", "profiles", PROFILE, "profile.json");
1415
+ return join2(stateRoot, ".tinycloud", "profiles", PROFILE, "profile.json");
1327
1416
  }
1328
1417
  #keyPath(stateRoot) {
1329
- return join(stateRoot, ".tinycloud", "profiles", PROFILE, "key.json");
1418
+ return join2(stateRoot, ".tinycloud", "profiles", PROFILE, "key.json");
1330
1419
  }
1331
1420
  #sessionPath(stateRoot) {
1332
- return join(stateRoot, ".tinycloud", "profiles", PROFILE, "session.json");
1421
+ return join2(stateRoot, ".tinycloud", "profiles", PROFILE, "session.json");
1333
1422
  }
1334
1423
  #additionalPath(stateRoot) {
1335
- return join(stateRoot, ".tinycloud", "profiles", PROFILE, "additional-delegations.json");
1424
+ return join2(stateRoot, ".tinycloud", "profiles", PROFILE, "additional-delegations.json");
1336
1425
  }
1337
1426
  #pendingPath(stateRoot, nonce) {
1338
- return join(this.#pendingDirectory(stateRoot), `${nonce}.json`);
1427
+ return join2(this.#pendingDirectory(stateRoot), `${nonce}.json`);
1339
1428
  }
1340
1429
  #pendingDirectory(stateRoot) {
1341
- return join(stateRoot, ".tinycloud", "profiles", PROFILE, "pending");
1430
+ return join2(stateRoot, ".tinycloud", "profiles", PROFILE, "pending");
1342
1431
  }
1343
1432
  };
1344
1433
  var wasmInitialized = false;
@@ -1431,7 +1520,7 @@ async function secureDirectory(path) {
1431
1520
  await chmod(path, 448);
1432
1521
  }
1433
1522
  async function secureWrite(path, value) {
1434
- const directory = dirname(path);
1523
+ const directory = dirname2(path);
1435
1524
  await secureDirectory(directory);
1436
1525
  const temporary = `${path}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
1437
1526
  await writeFile(temporary, `${JSON.stringify(value, jsonReplacer, 2)}
@@ -1463,7 +1552,7 @@ async function restoreOptionalText(path, contents) {
1463
1552
  await rm(path, { force: true });
1464
1553
  return;
1465
1554
  }
1466
- await secureDirectory(dirname(path));
1555
+ await secureDirectory(dirname2(path));
1467
1556
  await writeFile(path, contents, { mode: 384 });
1468
1557
  await chmod(path, 384);
1469
1558
  }
@@ -1478,7 +1567,7 @@ async function reusablePending(directory, expected) {
1478
1567
  const active = [];
1479
1568
  for (const name of names) {
1480
1569
  if (!name.endsWith(".json")) continue;
1481
- const path = join(directory, name);
1570
+ const path = join2(directory, name);
1482
1571
  const pending = await readJson(path).catch(() => null);
1483
1572
  if (pending === null || new Date(pending.expiresAt).getTime() <= Date.now()) {
1484
1573
  await rm(path, { force: true });
@@ -1489,7 +1578,7 @@ async function reusablePending(directory, expected) {
1489
1578
  }
1490
1579
  if (active.length >= 64) {
1491
1580
  active.sort((left, right) => Date.parse(left.createdAt) - Date.parse(right.createdAt));
1492
- await rm(join(directory, `${active[0].nonce}.json`), { force: true });
1581
+ await rm(join2(directory, `${active[0].nonce}.json`), { force: true });
1493
1582
  }
1494
1583
  return void 0;
1495
1584
  }
@@ -1503,7 +1592,7 @@ import { serveStdio } from "@modelcontextprotocol/server/stdio";
1503
1592
 
1504
1593
  // src/tools.ts
1505
1594
  import { createRequire } from "module";
1506
- import { join as join2 } from "path";
1595
+ import { join as join3 } from "path";
1507
1596
  import { fromJsonSchema } from "@modelcontextprotocol/server";
1508
1597
  import { AjvJsonSchemaValidator } from "@modelcontextprotocol/server/validators/ajv";
1509
1598
  import { invokeOperation as invokeOperation2 } from "@tinycloud/operations";
@@ -1634,7 +1723,7 @@ function invocationTargetForMcp(selection) {
1634
1723
  };
1635
1724
  }
1636
1725
  var packageRequire = createRequire(
1637
- typeof __dirname === "string" ? join2(__dirname, "tools.cjs") : import.meta.url
1726
+ typeof __dirname === "string" ? join3(__dirname, "tools.cjs") : import.meta.url
1638
1727
  );
1639
1728
  var generatedCatalog = packageRequire(
1640
1729
  "@tinycloud/operations/operations.json"
@@ -2009,7 +2098,7 @@ function outcomeCode(result) {
2009
2098
  // package.json
2010
2099
  var package_default = {
2011
2100
  name: "@tinycloud/mcp",
2012
- version: "0.10.1-beta.4",
2101
+ version: "0.11.0-beta.10",
2013
2102
  description: "TinyCloud delegated operations MCP server",
2014
2103
  keywords: [
2015
2104
  "tinycloud",
@@ -2080,10 +2169,10 @@ var package_default = {
2080
2169
  dependencies: {
2081
2170
  "@modelcontextprotocol/node": "2.0.0-beta.5",
2082
2171
  "@modelcontextprotocol/server": "2.0.0-beta.5",
2083
- "@tinycloud/node-sdk": "3.13.0-beta.3",
2084
- "@tinycloud/sdk-core": "3.13.0-beta.3",
2172
+ "@tinycloud/node-sdk": "3.13.0-beta.9",
2173
+ "@tinycloud/sdk-core": "3.13.0-beta.9",
2085
2174
  "@tinycloud/node-sdk-wasm": "1.7.9",
2086
- "@tinycloud/operations": "0.9.1-beta.4",
2175
+ "@tinycloud/operations": "0.9.1-beta.10",
2087
2176
  jose: "6.2.4"
2088
2177
  },
2089
2178
  devDependencies: {
@@ -2128,7 +2217,7 @@ function createHostedMcpApp(config) {
2128
2217
  const restricted = createHostedSurface({
2129
2218
  ...config,
2130
2219
  nativeServiceCredential: void 0,
2131
- stateDir: join3(config.stateDir, prefix),
2220
+ stateDir: join4(config.stateDir, prefix),
2132
2221
  approvalPath: connectUrl.pathname
2133
2222
  }, restrictedUrl, "public", statusFor(restrictedUrl), ANNOTATION_TITLE_PREFIXES.has(prefix));
2134
2223
  surfaces.push(restricted);
@@ -2210,6 +2299,7 @@ function createHostedSurface(config, resourceUrl, surface, tokenStatus, annotati
2210
2299
  scopesSupported: [REQUIRED_SCOPE],
2211
2300
  resourceName: surface === "public" ? "TinyCloud personal records" : "TinyCloud hosted MCP"
2212
2301
  };
2302
+ const discoveryRoutes = surface === "hosted" ? agentDiscoveryRoutes(resourceUrl, issuer, REQUIRED_SCOPE) : /* @__PURE__ */ new Map();
2213
2303
  const allowedHosts = [resourceUrl.hostname];
2214
2304
  return {
2215
2305
  async fetch(request) {
@@ -2316,9 +2406,22 @@ function createHostedSurface(config, resourceUrl, surface, tokenStatus, annotati
2316
2406
  ].join("\n") + "\n";
2317
2407
  return publicMetadataCors(publicText(authDoc, "text/markdown; charset=utf-8"), request);
2318
2408
  }
2409
+ const discoveryRoute = discoveryRoutes.get(url.pathname);
2410
+ if (discoveryRoute !== void 0) {
2411
+ if (request.method === "OPTIONS") {
2412
+ return publicMetadataCors(new Response(null, { status: 204 }), request);
2413
+ }
2414
+ if (request.method !== "GET" && request.method !== "HEAD") return methodNotAllowed("GET, HEAD");
2415
+ const response = discoveryRoute();
2416
+ return publicMetadataCors(
2417
+ request.method === "HEAD" ? new Response(null, { status: response.status, headers: response.headers }) : response,
2418
+ request
2419
+ );
2420
+ }
2319
2421
  if (url.pathname === "/robots.txt" && surface === "hosted") {
2320
2422
  return request.method === "GET" ? publicText(`User-agent: *
2321
2423
  Allow: /
2424
+ Content-Signal: search=yes, ai-input=yes, ai-train=no
2322
2425
  Sitemap: ${new URL("/sitemap.xml", resourceUrl)}
2323
2426
  Agentmap: ${new URL("/.well-known/ai-catalog.json", resourceUrl)}
2324
2427
  `, "text/plain; charset=utf-8") : methodNotAllowed("GET");
@@ -2395,17 +2498,17 @@ Hosted endpoint: <https://mcp.tinycloud.xyz/mcp> (Streamable HTTP, OpenKey OAuth
2395
2498
  [Connection documentation](https://docs.tinycloud.xyz/cli/mcp).
2396
2499
 
2397
2500
  Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\` and connect the \`tinycloud-mcp\` stdio server.
2398
- ` : `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="ai-catalog" href="/.well-known/ai-catalog.json"><title>TinyCloud MCP</title></head><main><h1>TinyCloud MCP</h1><p>Hosted MCP endpoint: <code>https://mcp.tinycloud.xyz/mcp</code> (Streamable HTTP, OpenKey OAuth).</p><p><a href="https://docs.tinycloud.xyz/cli/mcp">Connection documentation</a></p><p>Local alternative: install <code>${LOCAL_CLI_PACKAGE}</code> and <code>${LOCAL_MCP_PACKAGE}</code> and connect the <code>tinycloud-mcp</code> stdio server.</p></main></html>`;
2501
+ ` : `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="ai-catalog" href="/.well-known/ai-catalog.json"><script src="${WEBMCP_SCRIPT_PATH}" defer></script><title>TinyCloud MCP</title></head><main><h1>TinyCloud MCP</h1><p>Hosted MCP endpoint: <code>https://mcp.tinycloud.xyz/mcp</code> (Streamable HTTP, OpenKey OAuth).</p><p><a href="https://docs.tinycloud.xyz/cli/mcp">Connection documentation</a></p><p>Local alternative: install <code>${LOCAL_CLI_PACKAGE}</code> and <code>${LOCAL_MCP_PACKAGE}</code> and connect the <code>tinycloud-mcp</code> stdio server.</p></main></html>`;
2399
2502
  const headers = new Headers({
2400
2503
  "content-type": markdown ? "text/markdown; charset=utf-8" : "text/html; charset=utf-8",
2401
2504
  "cache-control": "public, max-age=300",
2402
- "content-security-policy": "default-src 'none'; base-uri 'none'; frame-ancestors 'none'",
2505
+ "content-security-policy": "default-src 'none'; script-src 'self'; base-uri 'none'; frame-ancestors 'none'",
2403
2506
  "x-content-type-options": "nosniff",
2404
2507
  vary: "Accept"
2405
2508
  });
2406
2509
  headers.set(
2407
2510
  "link",
2408
- `<${new URL("/mcp/server-card", resourceUrl)}>; rel="describedby"; type="application/json", <https://docs.tinycloud.xyz/cli/mcp>; rel="service-doc"`
2511
+ `<${new URL("/mcp/server-card", resourceUrl)}>; rel="describedby"; type="application/json", <https://docs.tinycloud.xyz/cli/mcp>; rel="service-doc", <${new URL("/.well-known/api-catalog", resourceUrl)}>; rel="api-catalog"`
2409
2512
  );
2410
2513
  return new Response(request.method === "HEAD" ? null : content, { headers });
2411
2514
  }