Skip to content

feat(mcp): MPP payment sessions + execute_code tool#27

Merged
hellno merged 7 commits intomainfrom
hellno/machine-payments
Mar 30, 2026
Merged

feat(mcp): MPP payment sessions + execute_code tool#27
hellno merged 7 commits intomainfrom
hellno/machine-payments

Conversation

@hellno
Copy link
Copy Markdown
Contributor

@hellno hellno commented Mar 26, 2026

Summary

  • Add MPP (Machine Payments Protocol) to the MCP worker so agents can pay via Tempo stablecoins and execute code without a human account
  • New execute_code MCP tool: sandboxed JS execution via Dynamic Workers ($0.01/call)
  • ComputeSession Durable Object for session balance tracking via mppx SDK
  • New mpp-api template for deploying paid AI APIs with MPP
  • Remove mpp-compute template (replaced by platform primitive)

Architecture

Agent → MCP Worker (mcp.getjack.org)
         ├── No auth? "Bearer mpp" pseudo-token
         ├── execute_code tool
         │   ├── Validate code (500KB, JS only)
         │   ├── chargeSession() → ComputeSession DO
         │   │   ├── No credential → 402 MPP challenge
         │   │   └── Valid voucher → deduct $0.01
         │   └── Dynamic Workers: LOADER.get() → run(input)
         └── Other tools: require real auth (jkt_ or WorkOS)

Test plan

  • Deploy MCP worker with new bindings (worker_loaders, COMPUTE_SESSION DO)
  • Set secrets: MPP_SECRET_KEY, TEMPO_RECIPIENT
  • Verify execute_code returns 402 payment challenge for unauthenticated calls
  • Verify existing tools (deploy, list_projects) still work with jkt_ tokens
  • Verify stage_file rejects MPP-only auth
  • Test full MPP payment flow with tempo request

hellno added 5 commits March 26, 2026 12:30
Add Machine Payments Protocol (MPP) support to the MCP worker so agents
can pay via Tempo stablecoins (USDC) and execute code without a human
account.

New MCP tool: execute_code — sandboxed JS execution via Dynamic Workers
(worker_loaders). Agents pay $0.01 per execution using MPP session
protocol. Code runs in V8 isolate with no outbound HTTP, no host secrets,
50ms CPU limit.

Architecture:
- ComputeSession Durable Object for session balance tracking
- mppx SDK with Transport.mcp() handles payment challenges/receipts
- MPP pseudo-auth bypass lets unauthenticated agents reach execute_code
- Auth guard on stage_file/list_staged_files prevents KV tampering
- WorkerEntrypoint wrapper for correct Dynamic Workers contract

Also adds mpp-api template for deploying paid AI APIs with MPP,
and removes mpp-compute template (replaced by platform primitive).
- Add receipt check in chargeSession — reject if DO returns 200 without
  a valid payment receipt (prevents free execution bypass)
- Import err() in server.ts so requireAuth works for stage_file guard
The mppx handler returns a wrapper with .status/.challenge/.withReceipt,
not a raw JSON-RPC response. Fix to check result.status === 402 and use
result.withReceipt() to materialize receipts. Use explicit "tempo/session"
key and add jsonrpc field to input.
Add /mcp/public endpoint that bypasses OAuth for MPP-paying agents.
Inject Accept header for MCP SDK compatibility since tempo/mppx
clients don't send it.
The MCP transport uses JSON-RPC error codes for payment challenges,
which HTTP payment clients (tempo request, mppx) can't parse. Add a
direct HTTP /execute endpoint that returns standard 402 + WWW-Authenticate
headers. Same Dynamic Workers execution, HTTP transport for payments.

Routes:
- /execute — HTTP clients (tempo request, mppx, curl)
- /mcp/public — MCP clients without OAuth (future)
- /mcp — authenticated MCP clients (Claude, Cursor)
hellno added 2 commits March 26, 2026 16:06
Static file at docs.getjack.org/SKILL.md that tells agents how to use
Jack Cloud's /execute endpoint with tempo request. Follows the same
pattern as tempo.xyz/SKILL.md — agents read it and know how to pay
and run code.
@hellno hellno merged commit 1a820f1 into main Mar 30, 2026
1 check failed
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