machine-bridge-mcp 0.2.4 → 0.2.5
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/package.json +1 -1
- package/src/local/self-test.mjs +17 -1
- package/src/worker/index.ts +7 -7
package/package.json
CHANGED
package/src/local/self-test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import http from "node:http";
|
|
3
|
-
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { daemonSelfTest } from "./daemon.mjs";
|
|
@@ -10,6 +10,7 @@ import { acquireDaemonLock, ensureLocalApiKey, ensureWorkerSecrets, loadState, p
|
|
|
10
10
|
|
|
11
11
|
await daemonSelfTest();
|
|
12
12
|
await stateSelfTest();
|
|
13
|
+
await workerSourceSelfTest();
|
|
13
14
|
await apiSelfTest();
|
|
14
15
|
console.log("local daemon/state/api self-test ok");
|
|
15
16
|
|
|
@@ -57,6 +58,21 @@ async function stateSelfTest() {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
async function workerSourceSelfTest() {
|
|
62
|
+
const source = await readFile(new URL("../worker/index.ts", import.meta.url), "utf8");
|
|
63
|
+
const unawaitedAsyncRoutes = [
|
|
64
|
+
"return this.registerClient(request);",
|
|
65
|
+
"return this.authorizeSubmit(request, base);",
|
|
66
|
+
"return this.exchangeToken(request, base);",
|
|
67
|
+
"return this.acceptDaemonWebSocket(request);",
|
|
68
|
+
"return this.handleMcp(request, base);",
|
|
69
|
+
"return this.handleSamplingApi(request);",
|
|
70
|
+
].filter((snippet) => source.includes(snippet));
|
|
71
|
+
if (unawaitedAsyncRoutes.length) {
|
|
72
|
+
throw new Error(`Worker async routes must be awaited so HttpError is caught: ${unawaitedAsyncRoutes.join(", ")}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
60
76
|
|
|
61
77
|
async function apiSelfTest() {
|
|
62
78
|
const logger = createLogger({ quiet: true, component: "api-test" });
|
package/src/worker/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
2
|
|
|
3
3
|
const SERVER_NAME = "machine-bridge-mcp";
|
|
4
|
-
const SERVER_VERSION = "0.2.
|
|
4
|
+
const SERVER_VERSION = "0.2.5";
|
|
5
5
|
const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
6
6
|
const JSONRPC_VERSION = "2.0";
|
|
7
7
|
const DEFAULT_MAX_BODY_BYTES = 32 * 1024 * 1024;
|
|
@@ -253,14 +253,14 @@ export class BridgeRoom extends DurableObject<BridgeEnv> {
|
|
|
253
253
|
if (url.pathname === "/.well-known/oauth-protected-resource" || url.pathname === "/.well-known/oauth-protected-resource/mcp") {
|
|
254
254
|
return json(this.protectedResourceMetadata(base));
|
|
255
255
|
}
|
|
256
|
-
if (url.pathname === "/oauth/register" && request.method === "POST") return this.registerClient(request);
|
|
256
|
+
if (url.pathname === "/oauth/register" && request.method === "POST") return await this.registerClient(request);
|
|
257
257
|
if (url.pathname === "/oauth/authorize" && request.method === "GET") return this.authorizePage(request, base);
|
|
258
|
-
if (url.pathname === "/oauth/authorize" && request.method === "POST") return this.authorizeSubmit(request, base);
|
|
259
|
-
if (url.pathname === "/oauth/token" && request.method === "POST") return this.exchangeToken(request, base);
|
|
260
|
-
if (url.pathname === "/daemon/ws") return this.acceptDaemonWebSocket(request);
|
|
261
|
-
if (url.pathname === "/mcp") return this.handleMcp(request, base);
|
|
258
|
+
if (url.pathname === "/oauth/authorize" && request.method === "POST") return await this.authorizeSubmit(request, base);
|
|
259
|
+
if (url.pathname === "/oauth/token" && request.method === "POST") return await this.exchangeToken(request, base);
|
|
260
|
+
if (url.pathname === "/daemon/ws") return await this.acceptDaemonWebSocket(request);
|
|
261
|
+
if (url.pathname === "/mcp") return await this.handleMcp(request, base);
|
|
262
262
|
if (url.pathname === "/api/daemon/status") return json(this.daemonStatus(false));
|
|
263
|
-
if (url.pathname === "/api/mcp/sampling") return this.handleSamplingApi(request);
|
|
263
|
+
if (url.pathname === "/api/mcp/sampling") return await this.handleSamplingApi(request);
|
|
264
264
|
return json({ error: "not_found" }, 404);
|
|
265
265
|
} catch (error) {
|
|
266
266
|
if (error instanceof HttpError) return json({ error: error.code, message: error.message }, error.status);
|