@tinycloud/mcp 0.8.7-beta.3 → 0.8.7

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.d.cts CHANGED
@@ -37,7 +37,6 @@ interface RemoteStoreConfig {
37
37
 
38
38
  interface HostedMcpConfig extends RemoteStoreConfig {
39
39
  readonly oauthMetadata: OAuthMetadata;
40
- readonly allowedOrigins?: readonly string[];
41
40
  /**
42
41
  * OpenKey token introspection client (`TC_MCP_INTROSPECTION_URL` and client
43
42
  * credentials). The hosted server always sets this; without it only the
package/dist/http.d.ts CHANGED
@@ -37,7 +37,6 @@ interface RemoteStoreConfig {
37
37
 
38
38
  interface HostedMcpConfig extends RemoteStoreConfig {
39
39
  readonly oauthMetadata: OAuthMetadata;
40
- readonly allowedOrigins?: readonly string[];
41
40
  /**
42
41
  * OpenKey token introspection client (`TC_MCP_INTROSPECTION_URL` and client
43
42
  * credentials). The hosted server always sets this; without it only the
package/dist/http.js CHANGED
@@ -1941,7 +1941,7 @@ function outcomeCode(result) {
1941
1941
  // package.json
1942
1942
  var package_default = {
1943
1943
  name: "@tinycloud/mcp",
1944
- version: "0.8.7-beta.3",
1944
+ version: "0.8.7",
1945
1945
  description: "TinyCloud delegated operations MCP server",
1946
1946
  keywords: [
1947
1947
  "tinycloud",
@@ -2012,9 +2012,9 @@ var package_default = {
2012
2012
  dependencies: {
2013
2013
  "@modelcontextprotocol/node": "2.0.0-beta.5",
2014
2014
  "@modelcontextprotocol/server": "2.0.0-beta.5",
2015
- "@tinycloud/node-sdk": "3.11.0-beta.2",
2015
+ "@tinycloud/node-sdk": "3.10.0",
2016
2016
  "@tinycloud/node-sdk-wasm": "1.7.8",
2017
- "@tinycloud/operations": "0.7.11-beta.2",
2017
+ "@tinycloud/operations": "0.7.10",
2018
2018
  jose: "6.2.4"
2019
2019
  },
2020
2020
  devDependencies: {
@@ -2038,6 +2038,7 @@ var MCP_SERVER_NAME = "tinycloud-mcp";
2038
2038
 
2039
2039
  // src/http.ts
2040
2040
  var REQUIRED_SCOPE = "tinycloud:mcp";
2041
+ var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID, Mcp-Method, Mcp-Name";
2041
2042
  var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
2042
2043
  var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
2043
2044
  function createHostedMcpApp(config) {
@@ -2358,8 +2359,8 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
2358
2359
  if (url.pathname === callbackPath) {
2359
2360
  if (request.method === "OPTIONS") return callbackCors(new Response(null, { status: 204 }), config.openkeyHost);
2360
2361
  if (request.method !== "POST") return methodNotAllowed("POST");
2361
- const originFailure2 = validateCallbackOrigin(request, config.openkeyHost);
2362
- if (originFailure2 !== void 0) return callbackCors(originFailure2, config.openkeyHost);
2362
+ const originFailure = validateCallbackOrigin(request, config.openkeyHost);
2363
+ if (originFailure !== void 0) return callbackCors(originFailure, config.openkeyHost);
2363
2364
  try {
2364
2365
  await store.completeApproval(requiredState(url), request);
2365
2366
  return callbackCors(json({ success: true }), config.openkeyHost);
@@ -2453,11 +2454,9 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
2453
2454
  });
2454
2455
  }
2455
2456
  if (url.pathname !== resourceUrl.pathname) return json({ error: "Not found" }, 404);
2456
- const originFailure = validateOrigin(request, config.allowedOrigins);
2457
- if (originFailure !== void 0) return originFailure;
2457
+ if (request.method === "OPTIONS") return mcpCors(new Response(null, { status: 204 }), request);
2458
2458
  const auth = await authenticate(request);
2459
- if (auth instanceof Response) return auth;
2460
- return handler.fetch(request, { authInfo: auth });
2459
+ return mcpCors(auth instanceof Response ? auth : await handler.fetch(request, { authInfo: auth }), request);
2461
2460
  },
2462
2461
  close: () => handler.close()
2463
2462
  };
@@ -2545,11 +2544,16 @@ function requiredState(url) {
2545
2544
  if (state.length > 512) throw new ApprovalRequestError("state_invalid", "Approval state is invalid.");
2546
2545
  return state;
2547
2546
  }
2548
- function validateOrigin(request, allowed) {
2549
- const origin = request.headers.get("origin");
2550
- if (origin === null) return void 0;
2551
- const allowlist = allowed ?? [];
2552
- return allowlist.includes(origin) ? void 0 : json({ error: "Origin is not allowed." }, 403);
2547
+ function mcpCors(response, request) {
2548
+ const headers = new Headers(response.headers);
2549
+ headers.append("vary", "Origin");
2550
+ if (request.headers.has("origin")) {
2551
+ headers.set("access-control-allow-origin", "*");
2552
+ headers.set("access-control-allow-methods", "GET, POST, DELETE, OPTIONS");
2553
+ headers.set("access-control-expose-headers", "WWW-Authenticate");
2554
+ if (request.method === "OPTIONS") headers.set("access-control-allow-headers", MCP_CORS_ALLOWED_HEADERS);
2555
+ }
2556
+ return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
2553
2557
  }
2554
2558
  function validateCallbackOrigin(request, openkeyHost) {
2555
2559
  const origin = request.headers.get("origin");