feat(mcp): MPP payment sessions + execute_code tool#27
Merged
Conversation
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)
7 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
execute_codeMCP tool: sandboxed JS execution via Dynamic Workers ($0.01/call)mpp-apitemplate for deploying paid AI APIs with MPPmpp-computetemplate (replaced by platform primitive)Architecture
Test plan
worker_loaders,COMPUTE_SESSIONDO)MPP_SECRET_KEY,TEMPO_RECIPIENTexecute_codereturns 402 payment challenge for unauthenticated callsstage_filerejects MPP-only authtempo request