@tinycloud/mcp 0.10.0-beta.46 → 0.10.0-beta.48

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.cjs CHANGED
@@ -555,7 +555,7 @@ function outcomeCode(result) {
555
555
  // package.json
556
556
  var package_default = {
557
557
  name: "@tinycloud/mcp",
558
- version: "0.10.0-beta.46",
558
+ version: "0.10.0-beta.48",
559
559
  description: "TinyCloud delegated operations MCP server",
560
560
  keywords: [
561
561
  "tinycloud",
@@ -629,7 +629,7 @@ var package_default = {
629
629
  "@tinycloud/node-sdk": "3.12.0-beta.38",
630
630
  "@tinycloud/sdk-core": "3.12.0-beta.37",
631
631
  "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
632
- "@tinycloud/operations": "0.9.0-beta.42",
632
+ "@tinycloud/operations": "0.9.0-beta.43",
633
633
  jose: "6.2.4"
634
634
  },
635
635
  devDependencies: {
@@ -2237,30 +2237,39 @@ var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protoco
2237
2237
  var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
2238
2238
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2239
2239
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2240
+ var RESTRICTED_ADDRESS_PREFIXES = ["chatgpt", "claude", "grok", "muse"];
2240
2241
  function createHostedMcpApp(config) {
2241
2242
  if (config.nativeServiceCredential !== void 0 && Buffer.byteLength(config.nativeServiceCredential, "utf8") < 32) {
2242
2243
  throw new Error("TC_MCP_NATIVE_SERVICE_CREDENTIAL must contain at least 32 bytes.");
2243
2244
  }
2244
2245
  const resourceUrl = canonicalResourceUrl(config.publicUrl);
2245
- const pluginUrl = new URL("./chatgpt/mcp", resourceUrl);
2246
2246
  const statusFor = (resource) => config.introspection === void 0 ? void 0 : createTokenStatusChecker({ ...config.introspection, resourceUrl: resource.toString() });
2247
2247
  const hosted = createHostedSurface(config, resourceUrl, "hosted", statusFor(resourceUrl));
2248
- const plugin = createHostedSurface({
2249
- ...config,
2250
- nativeServiceCredential: void 0,
2251
- stateDir: (0, import_node_path4.join)(config.stateDir, "chatgpt"),
2252
- approvalPath: new URL("./connect", pluginUrl).pathname
2253
- }, pluginUrl, "public", statusFor(pluginUrl));
2254
- const pluginPaths = {
2255
- [pluginUrl.pathname]: true,
2256
- [new URL("./connect", pluginUrl).pathname]: true,
2257
- [new URL("./connect/callback", pluginUrl).pathname]: true,
2258
- [new URL((0, import_server5.getOAuthProtectedResourceMetadataUrl)(pluginUrl)).pathname]: true
2259
- };
2248
+ const surfaces = [hosted];
2249
+ const restrictedByPath = /* @__PURE__ */ new Map();
2250
+ for (const prefix of RESTRICTED_ADDRESS_PREFIXES) {
2251
+ const restrictedUrl = new URL(`./${prefix}/mcp`, resourceUrl);
2252
+ const connectUrl = new URL("./connect", restrictedUrl);
2253
+ const restricted = createHostedSurface({
2254
+ ...config,
2255
+ nativeServiceCredential: void 0,
2256
+ stateDir: (0, import_node_path4.join)(config.stateDir, prefix),
2257
+ approvalPath: connectUrl.pathname
2258
+ }, restrictedUrl, "public", statusFor(restrictedUrl));
2259
+ surfaces.push(restricted);
2260
+ for (const owned of [
2261
+ restrictedUrl,
2262
+ connectUrl,
2263
+ new URL("./connect/callback", restrictedUrl),
2264
+ new URL((0, import_server5.getOAuthProtectedResourceMetadataUrl)(restrictedUrl))
2265
+ ]) {
2266
+ restrictedByPath.set(owned.pathname, restricted);
2267
+ }
2268
+ }
2260
2269
  return {
2261
- fetch: (request) => (pluginPaths[new URL(request.url).pathname] === true ? plugin : hosted).fetch(request),
2270
+ fetch: (request) => (restrictedByPath.get(new URL(request.url).pathname) ?? hosted).fetch(request),
2262
2271
  close: async () => {
2263
- await Promise.all([hosted.close(), plugin.close()]);
2272
+ await Promise.all(surfaces.map((surface) => surface.close()));
2264
2273
  }
2265
2274
  };
2266
2275
  }