Fortytwo MCP
Calls Fortytwo Prime — a collective inference system where multiple independent AI agents collaborate on every question. Paid per-token via x402 escrow using USDC on Base or Monad.
Prerequisites
The script signs on-chain payments using evm_private_key environment variable. Never ask the user to paste the key into chat — it must be set via shell:
export evm_private_key="0x..."
For full wallet setup and network details, see
setup.md.
Getting Started
Before the first query, or if the script fails with a setup error:
- 1. Explain that Prime is available and pricing is pay-per-token
- Run preflight: INLINECODE1
- If preflight fails, guide user through setup.md
- Note which networks preflight reports as READY — pass the correct
--network to the query script
Instructions
Querying Fortytwo Prime
Run the full MCP flow via script:
Run from the skill directory:
CODEBLOCK1
- - Answer goes to stdout, diagnostics to stderr
- Session is saved automatically to INLINECODE3
Follow-up queries (session reuse, no new payment)
CODEBLOCK2
Session is auto-detected from the saved file — no need to pass --session-id. Sessions live up to 90 minutes (15 min idle timeout). If the session expired, the script automatically falls through to a new payment.
Use --no-session to force a new payment. Use --session-id <uuid> to override manually.
Streaming (optional)
The bundled script does not support streaming. For incremental output on long queries, use curl with SSE directly — see streaming.md for the request format and parsing algorithm.
Key details
- - Errors are not charged. Failed requests cancel the budget reservation automatically.
- Sessions are billing-only. Prime does not remember previous questions — include context in each query.
- Retries are built in. The script retries up to 3 times on transient 400/502 with fresh signatures.
- Timeout is 600s (10 minutes). On-chain settlement + multi-agent inference takes time. Run the script with a sufficient timeout — do not kill it early or set shorter limits.
How to Present the Answer
- 1. Show the full answer — do not summarize unless the user explicitly asks for a summary. The user is paying.
- Attribute it — "Here's what Fortytwo Prime returned:"
- Add commentary if useful — your perspective after the full answer.
- Offer follow-up — "Want me to ask a follow-up?" (reuses session while budget remains).
Troubleshooting
| Error | Cause | Fix |
|---|
| INLINECODE7 | Env var missing | INLINECODE8 |
| INLINECODE9 |
Python packages |
pip install eth-account web3 |
|
low USDC balance | Wallet empty | Transfer USDC on Base or Monad |
| Transient 400/502 | On-chain timing | Script auto-retries; if persistent, surface to user |
| 402 on session call | Budget exhausted | New payment needed (script handles this) |
| 409/410 | Session closed | Script falls through to new payment |
| Invalid signature | Wrong EIP-712 domain | See
payment.md — query
name()/
version() on-chain |
References
- - setup.md — wallet setup, network config, and pricing. Read when guiding a new user through onboarding.
- payment.md — EIP-712 signing details and common mistakes. Read when debugging signature errors or building a custom payment flow.
- session.md — session lifecycle, error codes, and idempotency. Read when troubleshooting 402/409/410 errors on follow-up queries.
- streaming.md — SSE streaming via progressToken. Read when the user wants incremental output on long queries (requires curl, not the bundled script).
Fortytwo MCP
调用 Fortytwo Prime——一个集体推理系统,多个独立AI代理在每个问题上协同工作。通过x402托管方式,使用Base或Monad上的USDC按token付费。
前置条件
该脚本使用evmprivatekey环境变量签署链上支付。切勿要求用户将密钥粘贴到聊天中——必须通过shell设置:
bash
export evmprivatekey=0x...
关于完整钱包设置和网络详情,请参见setup.md。
快速开始
在首次查询前,或脚本因设置错误而失败时:
- 1. 说明Prime可用,且按token计费
- 运行预检:python scripts/preflight.py
- 如果预检失败,引导用户参考setup.md
- 记录预检报告为READY的网络——向查询脚本传递正确的--network参数
使用说明
查询Fortytwo Prime
通过脚本运行完整的MCP流程:
从技能目录运行:
bash
cd /path/to/skills/fortytwo-mcp
python scripts/fortytwo_query.py 你的问题 --network base
- - 答案输出到stdout,诊断信息输出到stderr
- 会话自动保存到/tmp/.fortytwo_session
后续查询(复用会话,无需新支付)
bash
python scripts/fortytwo_query.py 后续问题
会话从保存的文件自动检测——无需传递--session-id。会话最长存活90分钟(15分钟空闲超时)。如果会话过期,脚本会自动回退到新支付。
使用--no-session强制发起新支付。使用--session-id 手动覆盖。
流式传输(可选)
捆绑脚本不支持流式传输。如需长查询的增量输出,请直接使用curl配合SSE——参见streaming.md了解请求格式和解析算法。
关键细节
- - 错误不收费。 失败的请求会自动取消预算预留。
- 会话仅用于计费。 Prime不记忆之前的问题——请在每次查询中包含上下文。
- 内置重试机制。 脚本在遇到临时性400/502错误时会使用新签名重试最多3次。
- 超时时间为600秒(10分钟)。 链上结算+多代理推理需要时间。请以足够的超时时间运行脚本——不要提前终止或设置更短的时限。
如何呈现答案
- 1. 展示完整答案——除非用户明确要求摘要,否则不要概括。用户正在付费。
- 注明来源——以下是Fortytwo Prime返回的结果:
- 如有需要可添加评论——在完整答案后给出你的见解。
- 提供后续选项——需要我询问后续问题吗?(在预算剩余时复用会话)。
故障排除
| 错误 | 原因 | 解决方法 |
|---|
| evmprivatekey not set | 环境变量缺失 | export evmprivatekey=0x... |
| missing dependency |
Python包缺失 | pip install eth-account web3 |
| low USDC balance | 钱包余额不足 | 在Base或Monad上转入USDC |
| 临时性400/502 | 链上时序问题 | 脚本自动重试;如持续出现,告知用户 |
| 会话调用返回402 | 预算耗尽 | 需要新支付(脚本自动处理) |
| 409/410 | 会话已关闭 | 脚本回退到新支付 |
| 签名无效 | EIP-712域错误 | 参见
payment.md——在链上查询name()/version() |
参考资料
- - setup.md——钱包设置、网络配置和定价。在引导新用户入门时阅读。
- payment.md——EIP-712签名细节和常见错误。在调试签名错误或构建自定义支付流程时阅读。
- session.md——会话生命周期、错误码和幂等性。在排查后续查询中的402/409/410错误时阅读。
- streaming.md——通过progressToken实现的SSE流式传输。当用户希望长查询获得增量输出时阅读(需要使用curl,而非捆绑脚本)。