Skip to content

Commit 5cba9b4

Browse files
fix(mcp-bridge): Node compat + JSR slow-types (main.d.ts) (#96)
## Summary Two small fixes that close known cross-runtime + JSR posture gaps surfaced during the v0.4.7 publish attempts. ## 1. Node compat — \`Deno.env.get\` at line 256 Bridge used \`Deno.env.get(\"COORD_BACKEND_URL\")\` directly, which throws \`ReferenceError: Deno is not defined\` on Node and Bun. Switched to the \`env.get\` shim from \`./lib/runtime.js\` that's already used for every other env-var read in this file. \`\`\`diff -const LOCAL_COORD_URL = Deno.env.get("COORD_BACKEND_URL") ?? "http://127.0.0.1:7745"; +const LOCAL_COORD_URL = env.get("COORD_BACKEND_URL") ?? "http://127.0.0.1:7745"; \`\`\` Bridge now runs cleanly on Deno, Node, and Bun — matches the runtime support claimed in the README and \`jsr.json\`. ## 2. JSR slow-types — \`mcp-bridge/main.d.ts\` JSR's \`deno publish\` warns with \`unsupported-javascript-entrypoint\` because the entrypoint declared in \`jsr.json\` (\`./mcp-bridge/main.js\`) has no type declarations. Added a minimal \`main.d.ts\` declaring the entrypoint as a script with no public exports (\`export {}\`), which is accurate — \`main.js\` is run as a process via npx/deno-run, not imported as a library. The \`.d.ts\` also documents which \`lib/*\` modules ARE intended for library import (\`tools\`, \`resources\`, \`prompts\`, \`runtime\`, \`otel\`, \`security\`, \`api-clients\`, \`nickel-validator\`, \`logger\`) for downstream consumers. ## Verification \`\`\`bash $ echo '{...initialize...}' | node mcp-bridge/main.js # works $ echo '{...initialize...}' | deno run -A mcp-bridge/main.js # works \`\`\` Both runtimes return the expected initialize response. Existing tests still green. ## Scope This is a packaging/compat fix — no behavioral or API change. Targets the **next** release (0.4.8 or whenever you cut next). The currently-failing 0.4.7 publish failures are auth-related (npm Trusted Publisher / JSR linkage), not code-related, so this PR doesn't need to land before the v0.4.7 re-tag. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 576f80d commit 5cba9b4

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

mcp-bridge/main.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: MPL-2.0
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
//
4+
// Type declaration for mcp-bridge/main.js — script entrypoint
5+
//
6+
// `main.js` is an executable stdio bridge, not a library. It is the
7+
// command run by MCP clients via `npx -y @hyperpolymath/boj-server@latest`
8+
// or `deno run -A mcp-bridge/main.js`. It reads JSON-RPC from stdin,
9+
// writes responses to stdout, and exits when stdin closes.
10+
//
11+
// This file exists solely to satisfy JSR's slow-types check for the
12+
// entrypoint declared in `jsr.json`'s `exports` field. The public
13+
// surface is intentionally empty — clients interact with this module
14+
// by running it as a process, not by importing it.
15+
//
16+
// Library APIs (intended for direct import) live under `lib/`:
17+
// - lib/tools.js — buildToolList()
18+
// - lib/resources.js — listResources(), readResource(uri)
19+
// - lib/prompts.js — listPrompts(), getPrompt(name, args)
20+
// - lib/runtime.js — env, stdout, stderr, isDeno
21+
// - lib/otel.js — startSpan(), endSpan(), flush(), init(), isEnabled()
22+
// - lib/security.js — sanitizeErrorMessage(), rateLimitAllow(), …
23+
// - lib/api-clients.js — fetchHealth(), fetchMenu(), invokeCartridge(), …
24+
// - lib/nickel-validator.js — validateEnvelope(), tryParseEnvelope()
25+
// - lib/logger.js — info(), warn(), error(), setLevel()
26+
27+
export {};

mcp-bridge/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ async function dispatchTool(toolName, args) {
253253
// local-coord-mcp direct dispatch (loopback only, port 7745)
254254
// ===================================================================
255255

256-
const LOCAL_COORD_URL = Deno.env.get("COORD_BACKEND_URL") ?? "http://127.0.0.1:7745";
256+
const LOCAL_COORD_URL = env.get("COORD_BACKEND_URL") ?? "http://127.0.0.1:7745";
257257

258258
// Nickel contracts run on coord_send / coord_send_gated only — those
259259
// are the two tools whose `message` argument carries an A2ML envelope.

0 commit comments

Comments
 (0)