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

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/index.js CHANGED
@@ -169,8 +169,7 @@ var TOOL_NAMES = [
169
169
  "tinycloud_apps_context",
170
170
  "tinycloud_apps_read",
171
171
  "tinycloud_apps_write",
172
- "tinycloud_apps_query",
173
- "tinycloud_apps_move"
172
+ "tinycloud_apps_query"
174
173
  ];
175
174
  function invocationTargetForMcp(selection) {
176
175
  return {
@@ -394,7 +393,7 @@ var TOOL_BINDINGS = [
394
393
  operationVersion: 1,
395
394
  readOnlyHint: false,
396
395
  idempotentHint: true,
397
- destructiveHint: true,
396
+ destructiveHint: false,
398
397
  openWorldHint: false,
399
398
  surfaces: ["hosted", "public"]
400
399
  },
@@ -424,19 +423,9 @@ var TOOL_BINDINGS = [
424
423
  operationVersion: 1,
425
424
  readOnlyHint: false,
426
425
  idempotentHint: true,
427
- destructiveHint: true,
428
- openWorldHint: false,
429
- surfaces: ["hosted", "public"]
430
- },
431
- {
432
- name: "tinycloud_apps_move",
433
- operationId: "tinycloud.apps.move",
434
- operationVersion: 1,
435
- readOnlyHint: false,
436
- idempotentHint: true,
437
426
  destructiveHint: false,
438
427
  openWorldHint: false,
439
- surfaces: ["hosted"]
428
+ surfaces: ["hosted", "public"]
440
429
  }
441
430
  ];
442
431
  var definitions = new Map(generatedCatalog.operations.map((operation) => [
@@ -529,7 +518,7 @@ function outcomeCode(result) {
529
518
  // package.json
530
519
  var package_default = {
531
520
  name: "@tinycloud/mcp",
532
- version: "0.10.0-beta.4",
521
+ version: "0.10.0-beta.40",
533
522
  description: "TinyCloud delegated operations MCP server",
534
523
  keywords: [
535
524
  "tinycloud",
@@ -600,9 +589,10 @@ var package_default = {
600
589
  dependencies: {
601
590
  "@modelcontextprotocol/node": "2.0.0-beta.5",
602
591
  "@modelcontextprotocol/server": "2.0.0-beta.5",
603
- "@tinycloud/node-sdk": "3.12.0-beta.2",
604
- "@tinycloud/node-sdk-wasm": "1.7.8",
605
- "@tinycloud/operations": "0.9.0-beta.3",
592
+ "@tinycloud/node-sdk": "3.12.0-beta.33",
593
+ "@tinycloud/sdk-core": "3.12.0-beta.33",
594
+ "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
595
+ "@tinycloud/operations": "0.9.0-beta.36",
606
596
  jose: "6.2.4"
607
597
  },
608
598
  devDependencies: {
@@ -991,6 +981,7 @@ function claims(token) {
991
981
  }
992
982
 
993
983
  // src/remote-store.ts
984
+ import { sameTinyCloudNode } from "@tinycloud/sdk-core";
994
985
  import { createHmac, randomBytes, timingSafeEqual as timingSafeEqual2 } from "crypto";
995
986
  import { chmod, mkdir, readFile, readdir, rename, rm, writeFile } from "fs/promises";
996
987
  import { dirname, join as join2 } from "path";
@@ -1004,6 +995,7 @@ import {
1004
995
  UnsupportedSessionRestoreError,
1005
996
  isCapabilitySubset,
1006
997
  principalDidEquals,
998
+ publicJwk,
1007
999
  siweRuntimeDelegation,
1008
1000
  signedCompactUcanExpiry
1009
1001
  } from "@tinycloud/node-sdk";
@@ -1082,7 +1074,7 @@ var NATIVE_GRANT_IMPORT_REJECTION_CODES = /* @__PURE__ */ new Set([
1082
1074
  "DELEGATION_HOST_MISMATCH",
1083
1075
  "DELEGATION_REJECTED"
1084
1076
  ]);
1085
- var LEGACY_DEFAULT_NODE_HOST = "https://node.tinycloud.xyz";
1077
+ var PRODUCTION_NODE_HOSTS = /* @__PURE__ */ new Set(["https://node.tinycloud.xyz", "https://tee.node.tinycloud.xyz"]);
1086
1078
  var BOOTSTRAP_PERMISSIONS = [
1087
1079
  {
1088
1080
  service: "tinycloud.kv",
@@ -1505,14 +1497,16 @@ var RemoteTenantStore = class {
1505
1497
  did: tenant.sessionDid,
1506
1498
  callback: callback.toString(),
1507
1499
  host: this.#config.nodeHost,
1500
+ requesterOrigin: this.#config.publicUrl.origin,
1508
1501
  jwk: Buffer.from(JSON.stringify(publicJwk(tenant.jwk))).toString("base64url"),
1509
1502
  permissions: Buffer.from(JSON.stringify({
1510
1503
  permissions: pending.permissions,
1511
1504
  reason: [
1512
1505
  pending.kind === "bootstrap" ? "Connect this TinyCloud account to the hosted MCP delegate." : tcAppsApprovalReason(pending.permissions) ?? "Approve the exact capabilities requested by the TinyCloud MCP operation.",
1513
1506
  // Owner DIDs come from the verified OpenKey access token of the MCP
1514
- // client that created this link, never from the link itself.
1515
- ...pending.ownerDids.length === 0 ? [] : [`Requested by TinyCloud account ${pending.ownerDids.join(", ")}; approve only if that is you.`]
1507
+ // client that created this link, never from the link itself. The
1508
+ // callback refuses a signer outside them, so the approver isn't asked to check.
1509
+ ...pending.ownerDids.length === 0 ? [] : [`Requested by TinyCloud account ${pending.ownerDids.join(", ")}.`]
1516
1510
  ].join(" ")
1517
1511
  })).toString("base64url"),
1518
1512
  expiry: this.#config.delegationExpiry
@@ -1811,10 +1805,10 @@ var RemoteTenantStore = class {
1811
1805
  authMethod: "openkey",
1812
1806
  openkeyHost: this.#config.openkeyHost
1813
1807
  });
1814
- } else if (typeof profile.host === "string" && profile.host.replace(/\/+$/, "") === LEGACY_DEFAULT_NODE_HOST && this.#config.nodeHost.replace(/\/+$/, "") !== LEGACY_DEFAULT_NODE_HOST) {
1808
+ } 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(/\/+$/, "")) {
1815
1809
  await secureWrite(profilePath, { ...profile, host: this.#config.nodeHost });
1816
1810
  process.stderr.write(
1817
- `[tinycloud-mcp-http] tenant node host migrated: from=${LEGACY_DEFAULT_NODE_HOST} to=${new URL(this.#config.nodeHost).origin}
1811
+ `[tinycloud-mcp-http] tenant node host migrated: from=${profile.host.replace(/\/+$/, "")} to=${new URL(this.#config.nodeHost).origin}
1818
1812
  `
1819
1813
  );
1820
1814
  }
@@ -2120,11 +2114,6 @@ function sessionFromCallback(data, privateJwk) {
2120
2114
  signature: data.signature
2121
2115
  };
2122
2116
  }
2123
- function publicJwk(jwk) {
2124
- const copy = { ...jwk };
2125
- for (const field of ["d", "p", "q", "dp", "dq", "qi", "oth", "k"]) delete copy[field];
2126
- return copy;
2127
- }
2128
2117
  function samePrincipal(left, right) {
2129
2118
  if (typeof left !== "string") return false;
2130
2119
  try {
@@ -2137,6 +2126,7 @@ function normalizeDid(value) {
2137
2126
  return value.split("#", 1)[0];
2138
2127
  }
2139
2128
  function sameNodeHost(left, right) {
2129
+ if (PRODUCTION_NODE_HOSTS.has(left) && sameTinyCloudNode(left, right)) return true;
2140
2130
  try {
2141
2131
  const normalize = (value) => {
2142
2132
  const url = new URL(value);
@@ -2231,6 +2221,7 @@ function samePendingRequest(pending, expected) {
2231
2221
  // src/http.ts
2232
2222
  var REQUIRED_SCOPE = "tinycloud:mcp";
2233
2223
  var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID, Mcp-Method, Mcp-Name";
2224
+ var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
2234
2225
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2235
2226
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2236
2227
  function createHostedMcpApp(config) {
@@ -2528,10 +2519,12 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
2528
2519
  try {
2529
2520
  const destination = await store.approvalRedirect(requiredState(url));
2530
2521
  return Response.redirect(destination, 302);
2531
- } catch {
2522
+ } catch (error) {
2523
+ const reason = error instanceof ApprovalRequestError ? error.detail : "unknown";
2524
+ writeDiagnostic(`connect rejected: reason=${reason} path=${connectPath}`);
2532
2525
  if (request.headers.get("accept")?.includes("text/html")) {
2533
2526
  return new Response(
2534
- '<!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>',
2527
+ '<!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>',
2535
2528
  {
2536
2529
  status: 400,
2537
2530
  headers: {
@@ -2742,7 +2735,7 @@ function mcpCors(response, request) {
2742
2735
  if (request.headers.has("origin")) {
2743
2736
  headers.set("access-control-allow-origin", "*");
2744
2737
  headers.set("access-control-allow-methods", "GET, POST, DELETE, OPTIONS");
2745
- headers.set("access-control-expose-headers", "WWW-Authenticate");
2738
+ headers.set("access-control-expose-headers", MCP_CORS_EXPOSED_HEADERS);
2746
2739
  if (request.method === "OPTIONS") headers.set("access-control-allow-headers", MCP_CORS_ALLOWED_HEADERS);
2747
2740
  }
2748
2741
  return new Response(response.body, { status: response.status, statusText: response.statusText, headers });