@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-cli.cjs CHANGED
@@ -1990,7 +1990,7 @@ function outcomeCode(result) {
1990
1990
  // package.json
1991
1991
  var package_default = {
1992
1992
  name: "@tinycloud/mcp",
1993
- version: "0.10.0-beta.46",
1993
+ version: "0.10.0-beta.48",
1994
1994
  description: "TinyCloud delegated operations MCP server",
1995
1995
  keywords: [
1996
1996
  "tinycloud",
@@ -2064,7 +2064,7 @@ var package_default = {
2064
2064
  "@tinycloud/node-sdk": "3.12.0-beta.38",
2065
2065
  "@tinycloud/sdk-core": "3.12.0-beta.37",
2066
2066
  "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
2067
- "@tinycloud/operations": "0.9.0-beta.42",
2067
+ "@tinycloud/operations": "0.9.0-beta.43",
2068
2068
  jose: "6.2.4"
2069
2069
  },
2070
2070
  devDependencies: {
@@ -2092,30 +2092,39 @@ var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protoco
2092
2092
  var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
2093
2093
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2094
2094
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2095
+ var RESTRICTED_ADDRESS_PREFIXES = ["chatgpt", "claude", "grok", "muse"];
2095
2096
  function createHostedMcpApp(config) {
2096
2097
  if (config.nativeServiceCredential !== void 0 && Buffer.byteLength(config.nativeServiceCredential, "utf8") < 32) {
2097
2098
  throw new Error("TC_MCP_NATIVE_SERVICE_CREDENTIAL must contain at least 32 bytes.");
2098
2099
  }
2099
2100
  const resourceUrl = canonicalResourceUrl(config.publicUrl);
2100
- const pluginUrl = new URL("./chatgpt/mcp", resourceUrl);
2101
2101
  const statusFor = (resource) => config.introspection === void 0 ? void 0 : createTokenStatusChecker({ ...config.introspection, resourceUrl: resource.toString() });
2102
2102
  const hosted = createHostedSurface(config, resourceUrl, "hosted", statusFor(resourceUrl));
2103
- const plugin = createHostedSurface({
2104
- ...config,
2105
- nativeServiceCredential: void 0,
2106
- stateDir: (0, import_node_path3.join)(config.stateDir, "chatgpt"),
2107
- approvalPath: new URL("./connect", pluginUrl).pathname
2108
- }, pluginUrl, "public", statusFor(pluginUrl));
2109
- const pluginPaths = {
2110
- [pluginUrl.pathname]: true,
2111
- [new URL("./connect", pluginUrl).pathname]: true,
2112
- [new URL("./connect/callback", pluginUrl).pathname]: true,
2113
- [new URL((0, import_server4.getOAuthProtectedResourceMetadataUrl)(pluginUrl)).pathname]: true
2114
- };
2103
+ const surfaces = [hosted];
2104
+ const restrictedByPath = /* @__PURE__ */ new Map();
2105
+ for (const prefix of RESTRICTED_ADDRESS_PREFIXES) {
2106
+ const restrictedUrl = new URL(`./${prefix}/mcp`, resourceUrl);
2107
+ const connectUrl = new URL("./connect", restrictedUrl);
2108
+ const restricted = createHostedSurface({
2109
+ ...config,
2110
+ nativeServiceCredential: void 0,
2111
+ stateDir: (0, import_node_path3.join)(config.stateDir, prefix),
2112
+ approvalPath: connectUrl.pathname
2113
+ }, restrictedUrl, "public", statusFor(restrictedUrl));
2114
+ surfaces.push(restricted);
2115
+ for (const owned of [
2116
+ restrictedUrl,
2117
+ connectUrl,
2118
+ new URL("./connect/callback", restrictedUrl),
2119
+ new URL((0, import_server4.getOAuthProtectedResourceMetadataUrl)(restrictedUrl))
2120
+ ]) {
2121
+ restrictedByPath.set(owned.pathname, restricted);
2122
+ }
2123
+ }
2115
2124
  return {
2116
- fetch: (request) => (pluginPaths[new URL(request.url).pathname] === true ? plugin : hosted).fetch(request),
2125
+ fetch: (request) => (restrictedByPath.get(new URL(request.url).pathname) ?? hosted).fetch(request),
2117
2126
  close: async () => {
2118
- await Promise.all([hosted.close(), plugin.close()]);
2127
+ await Promise.all(surfaces.map((surface) => surface.close()));
2119
2128
  }
2120
2129
  };
2121
2130
  }