@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/README.md +8 -2
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/http-cli.cjs +18 -19
- package/dist/http-cli.cjs.map +1 -1
- package/dist/http-cli.js +18 -19
- package/dist/http-cli.js.map +1 -1
- package/dist/http.cjs +18 -14
- 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 +18 -14
- package/dist/http.js.map +1 -1
- package/dist/index.cjs +18 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -14
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +3 -3
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/http-cli.js
CHANGED
|
@@ -1958,7 +1958,7 @@ function outcomeCode(result) {
|
|
|
1958
1958
|
// package.json
|
|
1959
1959
|
var package_default = {
|
|
1960
1960
|
name: "@tinycloud/mcp",
|
|
1961
|
-
version: "0.8.7
|
|
1961
|
+
version: "0.8.7",
|
|
1962
1962
|
description: "TinyCloud delegated operations MCP server",
|
|
1963
1963
|
keywords: [
|
|
1964
1964
|
"tinycloud",
|
|
@@ -2029,9 +2029,9 @@ var package_default = {
|
|
|
2029
2029
|
dependencies: {
|
|
2030
2030
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
2031
2031
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
2032
|
-
"@tinycloud/node-sdk": "3.
|
|
2032
|
+
"@tinycloud/node-sdk": "3.10.0",
|
|
2033
2033
|
"@tinycloud/node-sdk-wasm": "1.7.8",
|
|
2034
|
-
"@tinycloud/operations": "0.7.
|
|
2034
|
+
"@tinycloud/operations": "0.7.10",
|
|
2035
2035
|
jose: "6.2.4"
|
|
2036
2036
|
},
|
|
2037
2037
|
devDependencies: {
|
|
@@ -2055,6 +2055,7 @@ var MCP_SERVER_NAME = "tinycloud-mcp";
|
|
|
2055
2055
|
|
|
2056
2056
|
// src/http.ts
|
|
2057
2057
|
var REQUIRED_SCOPE = "tinycloud:mcp";
|
|
2058
|
+
var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID, Mcp-Method, Mcp-Name";
|
|
2058
2059
|
var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
|
|
2059
2060
|
var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
|
|
2060
2061
|
function createHostedMcpApp(config) {
|
|
@@ -2375,8 +2376,8 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
|
|
|
2375
2376
|
if (url.pathname === callbackPath) {
|
|
2376
2377
|
if (request.method === "OPTIONS") return callbackCors(new Response(null, { status: 204 }), config.openkeyHost);
|
|
2377
2378
|
if (request.method !== "POST") return methodNotAllowed("POST");
|
|
2378
|
-
const
|
|
2379
|
-
if (
|
|
2379
|
+
const originFailure = validateCallbackOrigin(request, config.openkeyHost);
|
|
2380
|
+
if (originFailure !== void 0) return callbackCors(originFailure, config.openkeyHost);
|
|
2380
2381
|
try {
|
|
2381
2382
|
await store.completeApproval(requiredState(url), request);
|
|
2382
2383
|
return callbackCors(json({ success: true }), config.openkeyHost);
|
|
@@ -2470,11 +2471,9 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
|
|
|
2470
2471
|
});
|
|
2471
2472
|
}
|
|
2472
2473
|
if (url.pathname !== resourceUrl.pathname) return json({ error: "Not found" }, 404);
|
|
2473
|
-
|
|
2474
|
-
if (originFailure !== void 0) return originFailure;
|
|
2474
|
+
if (request.method === "OPTIONS") return mcpCors(new Response(null, { status: 204 }), request);
|
|
2475
2475
|
const auth = await authenticate(request);
|
|
2476
|
-
|
|
2477
|
-
return handler.fetch(request, { authInfo: auth });
|
|
2476
|
+
return mcpCors(auth instanceof Response ? auth : await handler.fetch(request, { authInfo: auth }), request);
|
|
2478
2477
|
},
|
|
2479
2478
|
close: () => handler.close()
|
|
2480
2479
|
};
|
|
@@ -2562,11 +2561,16 @@ function requiredState(url) {
|
|
|
2562
2561
|
if (state.length > 512) throw new ApprovalRequestError("state_invalid", "Approval state is invalid.");
|
|
2563
2562
|
return state;
|
|
2564
2563
|
}
|
|
2565
|
-
function
|
|
2566
|
-
const
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2564
|
+
function mcpCors(response, request) {
|
|
2565
|
+
const headers = new Headers(response.headers);
|
|
2566
|
+
headers.append("vary", "Origin");
|
|
2567
|
+
if (request.headers.has("origin")) {
|
|
2568
|
+
headers.set("access-control-allow-origin", "*");
|
|
2569
|
+
headers.set("access-control-allow-methods", "GET, POST, DELETE, OPTIONS");
|
|
2570
|
+
headers.set("access-control-expose-headers", "WWW-Authenticate");
|
|
2571
|
+
if (request.method === "OPTIONS") headers.set("access-control-allow-headers", MCP_CORS_ALLOWED_HEADERS);
|
|
2572
|
+
}
|
|
2573
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
2570
2574
|
}
|
|
2571
2575
|
function validateCallbackOrigin(request, openkeyHost) {
|
|
2572
2576
|
const origin = request.headers.get("origin");
|
|
@@ -2679,7 +2683,6 @@ async function main() {
|
|
|
2679
2683
|
openkeyHost,
|
|
2680
2684
|
approvalTtlSeconds: positiveInteger(process.env.TC_MCP_APPROVAL_TTL_SECONDS, 300),
|
|
2681
2685
|
delegationExpiry: process.env.TC_MCP_DELEGATION_EXPIRY ?? "1h",
|
|
2682
|
-
allowedOrigins: commaList(process.env.TC_MCP_ALLOWED_ORIGINS),
|
|
2683
2686
|
...process.env.TC_MCP_NATIVE_SERVICE_CREDENTIAL === void 0 ? {} : { nativeServiceCredential: process.env.TC_MCP_NATIVE_SERVICE_CREDENTIAL },
|
|
2684
2687
|
oauthMetadata,
|
|
2685
2688
|
introspection: {
|
|
@@ -2731,10 +2734,6 @@ function positiveInteger(value, fallback) {
|
|
|
2731
2734
|
if (!Number.isInteger(parsed) || parsed <= 0) throw new Error("Expected a positive integer environment value.");
|
|
2732
2735
|
return parsed;
|
|
2733
2736
|
}
|
|
2734
|
-
function commaList(value) {
|
|
2735
|
-
if (value === void 0) return void 0;
|
|
2736
|
-
return value.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
2737
|
-
}
|
|
2738
2737
|
void main().catch(() => {
|
|
2739
2738
|
process.stderr.write("[tinycloud-mcp-http] Startup failed.\n");
|
|
2740
2739
|
process.exitCode = 1;
|