@tinycloud/mcp 0.8.7-beta.3 → 0.9.0-beta.4
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/README.md +8 -2
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/http-cli.cjs +16 -17
- package/dist/http-cli.cjs.map +1 -1
- package/dist/http-cli.js +16 -17
- package/dist/http-cli.js.map +1 -1
- package/dist/http.cjs +16 -12
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +0 -1
- package/dist/http.d.ts +0 -1
- package/dist/http.js +16 -12
- package/dist/http.js.map +1 -1
- package/dist/index.cjs +16 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/http.cjs
CHANGED
|
@@ -1943,7 +1943,7 @@ function outcomeCode(result) {
|
|
|
1943
1943
|
// package.json
|
|
1944
1944
|
var package_default = {
|
|
1945
1945
|
name: "@tinycloud/mcp",
|
|
1946
|
-
version: "0.
|
|
1946
|
+
version: "0.9.0-beta.4",
|
|
1947
1947
|
description: "TinyCloud delegated operations MCP server",
|
|
1948
1948
|
keywords: [
|
|
1949
1949
|
"tinycloud",
|
|
@@ -2040,6 +2040,7 @@ var MCP_SERVER_NAME = "tinycloud-mcp";
|
|
|
2040
2040
|
|
|
2041
2041
|
// src/http.ts
|
|
2042
2042
|
var REQUIRED_SCOPE = "tinycloud:mcp";
|
|
2043
|
+
var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID, Mcp-Method, Mcp-Name";
|
|
2043
2044
|
var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
|
|
2044
2045
|
var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
|
|
2045
2046
|
function createHostedMcpApp(config) {
|
|
@@ -2360,8 +2361,8 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
|
|
|
2360
2361
|
if (url.pathname === callbackPath) {
|
|
2361
2362
|
if (request.method === "OPTIONS") return callbackCors(new Response(null, { status: 204 }), config.openkeyHost);
|
|
2362
2363
|
if (request.method !== "POST") return methodNotAllowed("POST");
|
|
2363
|
-
const
|
|
2364
|
-
if (
|
|
2364
|
+
const originFailure = validateCallbackOrigin(request, config.openkeyHost);
|
|
2365
|
+
if (originFailure !== void 0) return callbackCors(originFailure, config.openkeyHost);
|
|
2365
2366
|
try {
|
|
2366
2367
|
await store.completeApproval(requiredState(url), request);
|
|
2367
2368
|
return callbackCors(json({ success: true }), config.openkeyHost);
|
|
@@ -2455,11 +2456,9 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
|
|
|
2455
2456
|
});
|
|
2456
2457
|
}
|
|
2457
2458
|
if (url.pathname !== resourceUrl.pathname) return json({ error: "Not found" }, 404);
|
|
2458
|
-
|
|
2459
|
-
if (originFailure !== void 0) return originFailure;
|
|
2459
|
+
if (request.method === "OPTIONS") return mcpCors(new Response(null, { status: 204 }), request);
|
|
2460
2460
|
const auth = await authenticate(request);
|
|
2461
|
-
|
|
2462
|
-
return handler.fetch(request, { authInfo: auth });
|
|
2461
|
+
return mcpCors(auth instanceof Response ? auth : await handler.fetch(request, { authInfo: auth }), request);
|
|
2463
2462
|
},
|
|
2464
2463
|
close: () => handler.close()
|
|
2465
2464
|
};
|
|
@@ -2547,11 +2546,16 @@ function requiredState(url) {
|
|
|
2547
2546
|
if (state.length > 512) throw new ApprovalRequestError("state_invalid", "Approval state is invalid.");
|
|
2548
2547
|
return state;
|
|
2549
2548
|
}
|
|
2550
|
-
function
|
|
2551
|
-
const
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2549
|
+
function mcpCors(response, request) {
|
|
2550
|
+
const headers = new Headers(response.headers);
|
|
2551
|
+
headers.append("vary", "Origin");
|
|
2552
|
+
if (request.headers.has("origin")) {
|
|
2553
|
+
headers.set("access-control-allow-origin", "*");
|
|
2554
|
+
headers.set("access-control-allow-methods", "GET, POST, DELETE, OPTIONS");
|
|
2555
|
+
headers.set("access-control-expose-headers", "WWW-Authenticate");
|
|
2556
|
+
if (request.method === "OPTIONS") headers.set("access-control-allow-headers", MCP_CORS_ALLOWED_HEADERS);
|
|
2557
|
+
}
|
|
2558
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
2555
2559
|
}
|
|
2556
2560
|
function validateCallbackOrigin(request, openkeyHost) {
|
|
2557
2561
|
const origin = request.headers.get("origin");
|