@tinycloud/mcp 0.10.0-beta.45 → 0.10.0-beta.47

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