@tinycloud/mcp 0.10.0-beta.4 → 0.10.0-beta.41

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.cjs CHANGED
@@ -273,6 +273,7 @@ function logToolCall(tool, code, startedAt, replayedGrants) {
273
273
  }
274
274
 
275
275
  // src/remote-store.ts
276
+ var import_sdk_core = require("@tinycloud/sdk-core");
276
277
  var import_node_crypto3 = require("crypto");
277
278
  var import_promises = require("fs/promises");
278
279
  var import_node_path = require("path");
@@ -352,7 +353,7 @@ var NATIVE_GRANT_IMPORT_REJECTION_CODES = /* @__PURE__ */ new Set([
352
353
  "DELEGATION_HOST_MISMATCH",
353
354
  "DELEGATION_REJECTED"
354
355
  ]);
355
- var LEGACY_DEFAULT_NODE_HOST = "https://node.tinycloud.xyz";
356
+ var PRODUCTION_NODE_HOSTS = /* @__PURE__ */ new Set(["https://node.tinycloud.xyz", "https://tee.node.tinycloud.xyz"]);
356
357
  var BOOTSTRAP_PERMISSIONS = [
357
358
  {
358
359
  service: "tinycloud.kv",
@@ -775,14 +776,16 @@ var RemoteTenantStore = class {
775
776
  did: tenant.sessionDid,
776
777
  callback: callback.toString(),
777
778
  host: this.#config.nodeHost,
778
- jwk: Buffer.from(JSON.stringify(publicJwk(tenant.jwk))).toString("base64url"),
779
+ requesterOrigin: this.#config.publicUrl.origin,
780
+ jwk: Buffer.from(JSON.stringify((0, import_node_sdk2.publicJwk)(tenant.jwk))).toString("base64url"),
779
781
  permissions: Buffer.from(JSON.stringify({
780
782
  permissions: pending.permissions,
781
783
  reason: [
782
784
  pending.kind === "bootstrap" ? "Connect this TinyCloud account to the hosted MCP delegate." : (0, import_tc_apps.tcAppsApprovalReason)(pending.permissions) ?? "Approve the exact capabilities requested by the TinyCloud MCP operation.",
783
785
  // Owner DIDs come from the verified OpenKey access token of the MCP
784
- // client that created this link, never from the link itself.
785
- ...pending.ownerDids.length === 0 ? [] : [`Requested by TinyCloud account ${pending.ownerDids.join(", ")}; approve only if that is you.`]
786
+ // client that created this link, never from the link itself. The
787
+ // callback refuses a signer outside them, so the approver isn't asked to check.
788
+ ...pending.ownerDids.length === 0 ? [] : [`Requested by TinyCloud account ${pending.ownerDids.join(", ")}.`]
786
789
  ].join(" ")
787
790
  })).toString("base64url"),
788
791
  expiry: this.#config.delegationExpiry
@@ -1081,10 +1084,10 @@ var RemoteTenantStore = class {
1081
1084
  authMethod: "openkey",
1082
1085
  openkeyHost: this.#config.openkeyHost
1083
1086
  });
1084
- } else if (typeof profile.host === "string" && profile.host.replace(/\/+$/, "") === LEGACY_DEFAULT_NODE_HOST && this.#config.nodeHost.replace(/\/+$/, "") !== LEGACY_DEFAULT_NODE_HOST) {
1087
+ } else if (typeof profile.host === "string" && PRODUCTION_NODE_HOSTS.has(profile.host.replace(/\/+$/, "")) && PRODUCTION_NODE_HOSTS.has(this.#config.nodeHost.replace(/\/+$/, "")) && profile.host.replace(/\/+$/, "") !== this.#config.nodeHost.replace(/\/+$/, "")) {
1085
1088
  await secureWrite(profilePath, { ...profile, host: this.#config.nodeHost });
1086
1089
  process.stderr.write(
1087
- `[tinycloud-mcp-http] tenant node host migrated: from=${LEGACY_DEFAULT_NODE_HOST} to=${new URL(this.#config.nodeHost).origin}
1090
+ `[tinycloud-mcp-http] tenant node host migrated: from=${profile.host.replace(/\/+$/, "")} to=${new URL(this.#config.nodeHost).origin}
1088
1091
  `
1089
1092
  );
1090
1093
  }
@@ -1390,11 +1393,6 @@ function sessionFromCallback(data, privateJwk) {
1390
1393
  signature: data.signature
1391
1394
  };
1392
1395
  }
1393
- function publicJwk(jwk) {
1394
- const copy = { ...jwk };
1395
- for (const field of ["d", "p", "q", "dp", "dq", "qi", "oth", "k"]) delete copy[field];
1396
- return copy;
1397
- }
1398
1396
  function samePrincipal(left, right) {
1399
1397
  if (typeof left !== "string") return false;
1400
1398
  try {
@@ -1407,6 +1405,7 @@ function normalizeDid(value) {
1407
1405
  return value.split("#", 1)[0];
1408
1406
  }
1409
1407
  function sameNodeHost(left, right) {
1408
+ if (PRODUCTION_NODE_HOSTS.has(left) && (0, import_sdk_core.sameTinyCloudNode)(left, right)) return true;
1410
1409
  try {
1411
1410
  const normalize = (value) => {
1412
1411
  const url = new URL(value);
@@ -1849,7 +1848,7 @@ var TOOL_BINDINGS = [
1849
1848
  operationVersion: 1,
1850
1849
  readOnlyHint: false,
1851
1850
  idempotentHint: true,
1852
- destructiveHint: true,
1851
+ destructiveHint: false,
1853
1852
  openWorldHint: false,
1854
1853
  surfaces: ["hosted", "public"]
1855
1854
  },
@@ -1879,19 +1878,9 @@ var TOOL_BINDINGS = [
1879
1878
  operationVersion: 1,
1880
1879
  readOnlyHint: false,
1881
1880
  idempotentHint: true,
1882
- destructiveHint: true,
1883
- openWorldHint: false,
1884
- surfaces: ["hosted", "public"]
1885
- },
1886
- {
1887
- name: "tinycloud_apps_move",
1888
- operationId: "tinycloud.apps.move",
1889
- operationVersion: 1,
1890
- readOnlyHint: false,
1891
- idempotentHint: true,
1892
1881
  destructiveHint: false,
1893
1882
  openWorldHint: false,
1894
- surfaces: ["hosted"]
1883
+ surfaces: ["hosted", "public"]
1895
1884
  }
1896
1885
  ];
1897
1886
  var definitions = new Map(generatedCatalog.operations.map((operation) => [
@@ -1984,7 +1973,7 @@ function outcomeCode(result) {
1984
1973
  // package.json
1985
1974
  var package_default = {
1986
1975
  name: "@tinycloud/mcp",
1987
- version: "0.10.0-beta.4",
1976
+ version: "0.10.0-beta.41",
1988
1977
  description: "TinyCloud delegated operations MCP server",
1989
1978
  keywords: [
1990
1979
  "tinycloud",
@@ -2055,9 +2044,10 @@ var package_default = {
2055
2044
  dependencies: {
2056
2045
  "@modelcontextprotocol/node": "2.0.0-beta.5",
2057
2046
  "@modelcontextprotocol/server": "2.0.0-beta.5",
2058
- "@tinycloud/node-sdk": "3.12.0-beta.2",
2059
- "@tinycloud/node-sdk-wasm": "1.7.8",
2060
- "@tinycloud/operations": "0.9.0-beta.3",
2047
+ "@tinycloud/node-sdk": "3.12.0-beta.34",
2048
+ "@tinycloud/sdk-core": "3.12.0-beta.34",
2049
+ "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
2050
+ "@tinycloud/operations": "0.9.0-beta.37",
2061
2051
  jose: "6.2.4"
2062
2052
  },
2063
2053
  devDependencies: {
@@ -2082,6 +2072,7 @@ var MCP_SERVER_NAME = "tinycloud-mcp";
2082
2072
  // src/http.ts
2083
2073
  var REQUIRED_SCOPE = "tinycloud:mcp";
2084
2074
  var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID, Mcp-Method, Mcp-Name";
2075
+ var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
2085
2076
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2086
2077
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2087
2078
  function createHostedMcpApp(config) {
@@ -2379,10 +2370,12 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
2379
2370
  try {
2380
2371
  const destination = await store.approvalRedirect(requiredState(url));
2381
2372
  return Response.redirect(destination, 302);
2382
- } catch {
2373
+ } catch (error) {
2374
+ const reason = error instanceof ApprovalRequestError ? error.detail : "unknown";
2375
+ writeDiagnostic(`connect rejected: reason=${reason} path=${connectPath}`);
2383
2376
  if (request.headers.get("accept")?.includes("text/html")) {
2384
2377
  return new Response(
2385
- '<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>TinyCloud approval unavailable</title><main><h1>This approval link is unavailable</h1><p>It may have expired or already been used. No new approval was accepted through this link.</p><p>Return to the conversation that requested access. In ChatGPT, select @TinyCloud and ask it to continue your original request. If access is still needed, it can provide a fresh approval link.</p><p>If you declined access, no further approval is required. Never paste passwords, codes or approval links into support messages.</p></main></html>',
2378
+ '<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>TinyCloud approval unavailable</title><main><h1>This approval link is unavailable</h1><p>It may have expired or already been used. Go back to the assistant that sent it and ask it to connect TinyCloud again.</p><p>If you declined access, no further approval is required. Never paste passwords, codes or approval links into support messages.</p></main></html>',
2386
2379
  {
2387
2380
  status: 400,
2388
2381
  headers: {
@@ -2593,7 +2586,7 @@ function mcpCors(response, request) {
2593
2586
  if (request.headers.has("origin")) {
2594
2587
  headers.set("access-control-allow-origin", "*");
2595
2588
  headers.set("access-control-allow-methods", "GET, POST, DELETE, OPTIONS");
2596
- headers.set("access-control-expose-headers", "WWW-Authenticate");
2589
+ headers.set("access-control-expose-headers", MCP_CORS_EXPOSED_HEADERS);
2597
2590
  if (request.method === "OPTIONS") headers.set("access-control-allow-headers", MCP_CORS_ALLOWED_HEADERS);
2598
2591
  }
2599
2592
  return new Response(response.body, { status: response.status, statusText: response.statusText, headers });