@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/http.cjs CHANGED
@@ -1973,7 +1973,7 @@ function outcomeCode(result) {
1973
1973
  // package.json
1974
1974
  var package_default = {
1975
1975
  name: "@tinycloud/mcp",
1976
- version: "0.10.0-beta.46",
1976
+ version: "0.10.0-beta.48",
1977
1977
  description: "TinyCloud delegated operations MCP server",
1978
1978
  keywords: [
1979
1979
  "tinycloud",
@@ -2047,7 +2047,7 @@ var package_default = {
2047
2047
  "@tinycloud/node-sdk": "3.12.0-beta.38",
2048
2048
  "@tinycloud/sdk-core": "3.12.0-beta.37",
2049
2049
  "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
2050
- "@tinycloud/operations": "0.9.0-beta.42",
2050
+ "@tinycloud/operations": "0.9.0-beta.43",
2051
2051
  jose: "6.2.4"
2052
2052
  },
2053
2053
  devDependencies: {
@@ -2075,30 +2075,39 @@ var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protoco
2075
2075
  var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
2076
2076
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2077
2077
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2078
+ var RESTRICTED_ADDRESS_PREFIXES = ["chatgpt", "claude", "grok", "muse"];
2078
2079
  function createHostedMcpApp(config) {
2079
2080
  if (config.nativeServiceCredential !== void 0 && Buffer.byteLength(config.nativeServiceCredential, "utf8") < 32) {
2080
2081
  throw new Error("TC_MCP_NATIVE_SERVICE_CREDENTIAL must contain at least 32 bytes.");
2081
2082
  }
2082
2083
  const resourceUrl = canonicalResourceUrl(config.publicUrl);
2083
- const pluginUrl = new URL("./chatgpt/mcp", resourceUrl);
2084
2084
  const statusFor = (resource) => config.introspection === void 0 ? void 0 : createTokenStatusChecker({ ...config.introspection, resourceUrl: resource.toString() });
2085
2085
  const hosted = createHostedSurface(config, resourceUrl, "hosted", statusFor(resourceUrl));
2086
- const plugin = createHostedSurface({
2087
- ...config,
2088
- nativeServiceCredential: void 0,
2089
- stateDir: (0, import_node_path3.join)(config.stateDir, "chatgpt"),
2090
- approvalPath: new URL("./connect", pluginUrl).pathname
2091
- }, pluginUrl, "public", statusFor(pluginUrl));
2092
- const pluginPaths = {
2093
- [pluginUrl.pathname]: true,
2094
- [new URL("./connect", pluginUrl).pathname]: true,
2095
- [new URL("./connect/callback", pluginUrl).pathname]: true,
2096
- [new URL((0, import_server4.getOAuthProtectedResourceMetadataUrl)(pluginUrl)).pathname]: true
2097
- };
2086
+ const surfaces = [hosted];
2087
+ const restrictedByPath = /* @__PURE__ */ new Map();
2088
+ for (const prefix of RESTRICTED_ADDRESS_PREFIXES) {
2089
+ const restrictedUrl = new URL(`./${prefix}/mcp`, resourceUrl);
2090
+ const connectUrl = new URL("./connect", restrictedUrl);
2091
+ const restricted = createHostedSurface({
2092
+ ...config,
2093
+ nativeServiceCredential: void 0,
2094
+ stateDir: (0, import_node_path3.join)(config.stateDir, prefix),
2095
+ approvalPath: connectUrl.pathname
2096
+ }, restrictedUrl, "public", statusFor(restrictedUrl));
2097
+ surfaces.push(restricted);
2098
+ for (const owned of [
2099
+ restrictedUrl,
2100
+ connectUrl,
2101
+ new URL("./connect/callback", restrictedUrl),
2102
+ new URL((0, import_server4.getOAuthProtectedResourceMetadataUrl)(restrictedUrl))
2103
+ ]) {
2104
+ restrictedByPath.set(owned.pathname, restricted);
2105
+ }
2106
+ }
2098
2107
  return {
2099
- fetch: (request) => (pluginPaths[new URL(request.url).pathname] === true ? plugin : hosted).fetch(request),
2108
+ fetch: (request) => (restrictedByPath.get(new URL(request.url).pathname) ?? hosted).fetch(request),
2100
2109
  close: async () => {
2101
- await Promise.all([hosted.close(), plugin.close()]);
2110
+ await Promise.all(surfaces.map((surface) => surface.close()));
2102
2111
  }
2103
2112
  };
2104
2113
  }