@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.js CHANGED
@@ -518,7 +518,7 @@ function outcomeCode(result) {
518
518
  // package.json
519
519
  var package_default = {
520
520
  name: "@tinycloud/mcp",
521
- version: "0.10.0-beta.46",
521
+ version: "0.10.0-beta.48",
522
522
  description: "TinyCloud delegated operations MCP server",
523
523
  keywords: [
524
524
  "tinycloud",
@@ -592,7 +592,7 @@ var package_default = {
592
592
  "@tinycloud/node-sdk": "3.12.0-beta.38",
593
593
  "@tinycloud/sdk-core": "3.12.0-beta.37",
594
594
  "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
595
- "@tinycloud/operations": "0.9.0-beta.42",
595
+ "@tinycloud/operations": "0.9.0-beta.43",
596
596
  jose: "6.2.4"
597
597
  },
598
598
  devDependencies: {
@@ -2224,30 +2224,39 @@ var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protoco
2224
2224
  var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
2225
2225
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2226
2226
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2227
+ var RESTRICTED_ADDRESS_PREFIXES = ["chatgpt", "claude", "grok", "muse"];
2227
2228
  function createHostedMcpApp(config) {
2228
2229
  if (config.nativeServiceCredential !== void 0 && Buffer.byteLength(config.nativeServiceCredential, "utf8") < 32) {
2229
2230
  throw new Error("TC_MCP_NATIVE_SERVICE_CREDENTIAL must contain at least 32 bytes.");
2230
2231
  }
2231
2232
  const resourceUrl = canonicalResourceUrl(config.publicUrl);
2232
- const pluginUrl = new URL("./chatgpt/mcp", resourceUrl);
2233
2233
  const statusFor = (resource) => config.introspection === void 0 ? void 0 : createTokenStatusChecker({ ...config.introspection, resourceUrl: resource.toString() });
2234
2234
  const hosted = createHostedSurface(config, resourceUrl, "hosted", statusFor(resourceUrl));
2235
- const plugin = createHostedSurface({
2236
- ...config,
2237
- nativeServiceCredential: void 0,
2238
- stateDir: join3(config.stateDir, "chatgpt"),
2239
- approvalPath: new URL("./connect", pluginUrl).pathname
2240
- }, pluginUrl, "public", statusFor(pluginUrl));
2241
- const pluginPaths = {
2242
- [pluginUrl.pathname]: true,
2243
- [new URL("./connect", pluginUrl).pathname]: true,
2244
- [new URL("./connect/callback", pluginUrl).pathname]: true,
2245
- [new URL(getOAuthProtectedResourceMetadataUrl(pluginUrl)).pathname]: true
2246
- };
2235
+ const surfaces = [hosted];
2236
+ const restrictedByPath = /* @__PURE__ */ new Map();
2237
+ for (const prefix of RESTRICTED_ADDRESS_PREFIXES) {
2238
+ const restrictedUrl = new URL(`./${prefix}/mcp`, resourceUrl);
2239
+ const connectUrl = new URL("./connect", restrictedUrl);
2240
+ const restricted = createHostedSurface({
2241
+ ...config,
2242
+ nativeServiceCredential: void 0,
2243
+ stateDir: join3(config.stateDir, prefix),
2244
+ approvalPath: connectUrl.pathname
2245
+ }, restrictedUrl, "public", statusFor(restrictedUrl));
2246
+ surfaces.push(restricted);
2247
+ for (const owned of [
2248
+ restrictedUrl,
2249
+ connectUrl,
2250
+ new URL("./connect/callback", restrictedUrl),
2251
+ new URL(getOAuthProtectedResourceMetadataUrl(restrictedUrl))
2252
+ ]) {
2253
+ restrictedByPath.set(owned.pathname, restricted);
2254
+ }
2255
+ }
2247
2256
  return {
2248
- fetch: (request) => (pluginPaths[new URL(request.url).pathname] === true ? plugin : hosted).fetch(request),
2257
+ fetch: (request) => (restrictedByPath.get(new URL(request.url).pathname) ?? hosted).fetch(request),
2249
2258
  close: async () => {
2250
- await Promise.all([hosted.close(), plugin.close()]);
2259
+ await Promise.all(surfaces.map((surface) => surface.close()));
2251
2260
  }
2252
2261
  };
2253
2262
  }