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