Skip to content

Bunny mcp - #747

Merged
fretchen merged 8 commits into
mainfrom
bunny_mcp
Oct 20, 2026
Merged

fretchen merged 8 commits into
mainfrom
bunny_mcp

Conversation

@fretchen

Copy link
Copy Markdown
Owner

No description provided.

- src/llm_routes.ts: native routing mirror of scw_js/sc_llm_x402.ts (challenge-before-
  validation, ceiling-then-usage settle, testnet-mock gate, tools/messages caps,
  tool_choice enum, openapi price.max override)
- Deviation, decided + gated by the wall-clock spike (504 at 59.2s on bunny): the twin
  advertises/verifies with LLM_MAX_TIMEOUT_SECONDS=40 (vs scw's 120) and races the
  unbounded callLLMAPI at that bound, so the handler answers (lock released, nothing
  settled) before the edge kills the request. Channels funded against the scw chat's
  120s advertisement stay usable (maxTimeoutSeconds is per-route, not in channelId).
- test/llm.test.ts: 72 tests translated from sc_llm_x402.test.ts (Request-returning
  makeEvent, legacy adapter, native favicon bytes) — 237 total green
- Multi-entry layout: routers searchapi_routes/llm_routes + entries searchapi/llm ->
  dist/searchapi.js (397.6 KB) + dist/llm.js (402.3 KB); per-entry build scripts;
  deploy script + workflow now target dist/searchapi.js
- src/response.ts: shared toResponse/byteStringHeaderValue extracted from the
  searchapi router for all three twins
- src/mcp_routes.ts: stateless JSON-RPC 2.0 dispatch (initialize, tools/list,
  tools/call, notifications -> 202), ported from scw_js/mcp_server.ts, plus the
  decided GET deviation: root HTML + /favicon.png answer 200 for scanners,
  other GETs return an honest 404 with the stateless notice instead of the
  scw original's blanket 405; DELETE keeps 405 (no sessions, spec-legal)
- src/mcp_tools.ts: relay layer over the REAL twin routers via synthetic
  Requests — payment header translation both ways (meta -> payment-signature;
  402 -> isError + structuredContent; Payment-Response -> _meta receipt).
  @x402/mcp dropped after build showed its root-export pulls the full
  @modelcontextprotocol/sdk with top-level 'import "ajv"' (unresolved in the
  edge bundle = load-time crash); the two meta-key constants are inlined as
  literals, values verified against @x402/mcp 2.28.0 and pinned by the tests
- src/mcp.ts entry; build:mcp wired -> dist/mcp.js 421.7 KB, externals only
  the five node:* builtins, zero ajv references
- test/mcp.test.ts: 16 tests translated (transport tests rewritten for the
  GET deviation; relay tests pin mainnet-only search / testnet-chat asymmetry,
  usage-derived settlement of 13 atomic USDC, receipt in _meta) — after fixing
  stale vi.mock registration paths that silently disabled the mocks
- Local deno smoke: initialize/tools/list correct; unpaid tools/call returns
  the real mainnet-only demands as isError; GET HTML 200, GET /mcp 404
Same recipe as the search buyer: env path ../.env (bunny_js's local .env
copy), three-way SERVER selector (bunny-local :8080 / bunny-trial with
TRIAL_URL / scw-deployed for the A/B), outputs cleared. The mcp notebook's
findings cell pins the payoff measurement: cold initialize ~0.3 s on the
twin vs the ~26-27 s measured three times on the scw function. The llm
notebook's header notes the twin's 40 s completion cap (vs scw's 120 s).
Typecheck: mcp buyer zero errors; llm buyer 3 pre-existing TS2551 union
quirks (5 in the original — the SERVER-block rewrite removed two), same
class the jupyter kernel does not enforce.
Local smoke through the notebooks' own request shape: env loads, initialize
negotiates 2025-06-18, unpaid chat_completion returns isError + testnet
accepts (the chat's intentional asymmetry, verified end to end).
- package.json: dev:searchapi / dev:llm / dev:mcp (deno run on the source
  entry, --sloppy-imports for the shared packages' extensionless tsc
  output); 'dev' aliased to dev:searchapi — the old 'dev' still pointed at
  the pre-rename src/index.ts, which no longer exists
- README: the three dev scripts + the --env-file=.env flag documented
- notebooks: llm_mcp_buyer's three scw-era references (cd scw_js && npm run
  dev:mcp, port 8086) and llm_x402_buyer's dev:llmx402 reference now point
  at the bunny twins (port 8080)
- Verified live: npm run dev:mcp serves, initialize answers 2025-06-18
npm run dev:mcp --env-file=.env does not work — npm eats unknown flags as
its own config ('Unknown cli config --env-file'), so the flag never reaches
deno; the escape hatch is 'npm run dev:<x> -- <flags>'. Since the env file
is wanted for every local run anyway, the dev scripts now include
--env-file=.env themselves; a missing .env only warns (verified), so fresh
clones do not break. README documents both the baked-in flag and the --
escape hatch.
@fretchen
fretchen merged commit 2b55d87 into main Oct 20, 2026
3 checks passed
@fretchen
fretchen deleted the bunny_mcp branch October 20, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant