Casper MCP Server
Enables AI agents to interact with the Casper Network through six tools including account balance, agent registry, transaction status, transfers, and DeFi pools, using the Model Context Protocol.
README
<div align="center">
<img src="https://thebeastagi.com/favicon.svg" width="88" alt="The Beast" />
Beast AI Agent Gateway
Autonomous AI agents that discover, hire, and pay each other on Casper Network
The first x402 v2 payment rail for Casper — built end-to-end by an autonomous 9-agent AI fleet in under 8 hours.
🌐 thebeastagi.com · 𝕏 @thebeastagi · 🎥 Demo video · Casper Agentic Buildathon 2026
Prize tracks: 🤖 Agentic AI · 💱 DeFi · 🏛️ Real-World Assets
</div>
⚡ 30-Second Pitch
AI agents are becoming economic actors — but they have no way to pay each other on Casper. We built the missing rail: a complete x402 v2 micropayment stack (client, facilitator, gateway middleware), an on-chain agent registry with reputation (Rust/wasm smart contract), an MCP server that gives any AI assistant direct Casper access, and a TypeScript SDK that turns any agent into a paying customer in 5 lines of code.
Then we proved it works: The Beast's own 9-agent fleet registers, discovers, hires, and pays each other through the gateway — audits, code fixes, and DeFi yield routing, every interaction settled with a signed x402 micropayment.
🎥 Demo
▶️ demo-video-final.mp4 — 1 minute 9 seconds, in the repo root (direct download).
What you'll see:
- Fleet registration — Beast agents register their identity + services via x402-paid calls
- Service discovery — BEAST-AGI finds the highest-reputation auditor
- Paid audit — 0.2 CSPR x402 payment → smart-contract audit report
- Automated fixes — beast-engineer is hired to fix the findings
- DeFi execution — beast-trader runs yield optimization (0.5 CSPR swap endpoint)
- Cross-validation — beast-curator verifies the work
Or run it yourself in two commands — see Quick Start.
🧠 What We Built
| Capability | How | |
|---|---|---|
| 💸 | Agents pay agents | First x402 v2 implementation for Casper: 402 → sign → verify → 200, Ed25519, replay-protected |
| 🪪 | On-chain identity & reputation | beast-agent-registry Rust/wasm contract: register, query, reputation, discovery |
| 🤝 | Autonomous coordination | 9-agent fleet demo: discover → hire → pay → deliver → validate, no human in the loop |
| 🧰 | AI-native blockchain access | MCP server with 6 Casper tools — works with Claude, Cursor, or any MCP client |
| 📈 | DeFi operations | x402-metered swap & stake endpoints wired to Casper testnet RPC |
| 🧩 | 5-line integration | @beast/agent-sdk — register, discover, and request paid services with automatic x402 handling |
🏗️ Architecture
flowchart TB
subgraph FLEET["The Beast Fleet — 9 autonomous agents"]
AGI["BEAST-AGI (coordinator)"]
AUD["beast-auditor"]
ENG["beast-engineer"]
TRD["beast-trader"]
MORE["...5 more"]
end
subgraph GATEWAY["Beast AI Agent Gateway — Express :3456"]
MW["x402 middleware — 402 challenge / X-Payment verification"]
API["Agent Registry API · Service Marketplace · DeFi endpoints"]
FAC["Casper x402 Facilitator — Ed25519 verify · replay cache · settlement"]
end
subgraph CASPER["Casper Network (testnet)"]
RPC["JSON-RPC"]
SC["beast-agent-registry (Rust → wasm32)"]
end
CLIENTS["Claude / Cursor / any MCP client"]
MCP["Casper MCP Server — 6 tools, stdio"]
AGI -- "@beast/agent-sdk + x402 client" --> MW
AUD --> MW
ENG --> MW
TRD --> MW
MORE --> MW
MW --> API
API --> FAC
FAC --> RPC
RPC --> SC
CLIENTS --> MCP
MCP --> RPC
Monorepo layout
| Package | npm workspace | What it does |
|---|---|---|
packages/core |
@beast/casper-x402 |
First x402 v2 implementation for Casper — payment client, facilitator, Ed25519 crypto (tweetnacl + blake2b) |
packages/gateway |
@beast/agent-gateway |
Express gateway with 5 x402-protected endpoints: registration, discovery, service requests, DeFi |
packages/mcp-server |
@beast/casper-mcp-server |
Model Context Protocol server exposing Casper to AI agents (balance, registry, tx status, transfers, DeFi pools) |
packages/agent-sdk |
@beast/agent-sdk |
TypeScript SDK: BeastAgent class with automatic 402 → pay → retry flow + both runnable demos |
packages/contract |
— | beast-agent-registry Rust smart contract (casper-contract 1.4.4, wasm32, builds on stable Rust) |
🚀 Quick Start
Verified end-to-end on Node 18 / 20 / 22 — the same steps run in CI on every push.
Prerequisites
- Node.js ≥ 18, npm ≥ 9
- (contract only) Rust stable +
wasm32-unknown-unknowntarget
1. Install & build
git clone https://github.com/thebeastagi/casper-agent-gateway.git
cd casper-agent-gateway
npm install
npm run build
2. Start the gateway
npm run gateway
# 🦁 Beast AI Agent Gateway running on port 3456
# x402: Enabled (5 paid endpoints)
Poke it:
curl http://localhost:3456/api/v1/health
# {"status":"ok","gateway":"Beast AI Agent Gateway","network":"casper:testnet",...}
curl -X POST http://localhost:3456/api/v1/agents/register -H "Content-Type: application/json" -d '{}'
# HTTP 402 → {"x402Version":"2.0","accepts":[{"network":"casper:testnet","amount":"100000000",...}]}
3. Run the demos (new terminal)
npm run demo:fleet # 9-agent fleet: discover → audit → fix → trade → validate
npm run demo:marketplace # x402 service marketplace with competing providers
4. MCP server (optional — plug Casper into Claude/Cursor)
npm run mcp # stdio transport
{
"mcpServers": {
"casper": {
"command": "node",
"args": ["/path/to/casper-agent-gateway/packages/mcp-server/dist/server.js"],
"env": { "CASPER_RPC": "https://rpc.testnet.casper.network" }
}
}
}
5. Smart contract
cd packages/contract
cargo check --target wasm32-unknown-unknown # what CI runs
cargo build --release --target wasm32-unknown-unknown # produces the deployable wasm
🧪 Testing
The repo ships with a full 45-test suite across all 4 packages — zero external test deps, runs on node:test (built into Node 18+), verified green in CI across Node 18 / 20 / 22:
npm test
# ℹ tests 45 ℹ pass 45 ℹ fail 0
| Package | Tests | Covers |
|---|---|---|
@beast/casper-x402 (core) |
22 | Ed25519 round-trips, deterministic blake2b hashing, payment builder, facilitator verification matrix (valid / expired / replay / underpay / wrong-recipient / forged-signature / network-mismatch / malformed) |
@beast/agent-gateway |
9 | Health endpoint, free routes, 402 challenges, full 402→pay→201 register flow with settlement receipt, underpayment rejection, replay protection, malformed-input handling, service request settlement |
@beast/casper-mcp-server |
10 | All 6 MCP tools (balance, registry, tx status, network stats, transfer, DeFi pool), reputation filtering, unknown-tool rejection |
@beast/agent-sdk |
4 | BeastAgent identity derivation, keypair persistence, graceful offline fallback |
Plus 16 documented contract scenarios in packages/contract/tests/integration.rs (Rust) covering the full register→query→reputation→deactivate lifecycle, ready for casper-engine-test-support wiring.
CI guards the build + test + gateway smoke test + contract check on every push. A fresh judge clone passes first try — every step in the Quick Start is verified in .github/workflows/ci.yml.
💸 The x402 Payment Flow
Every paid endpoint speaks native x402 v2 — HTTP's 402 Payment Required, finally put to work:
sequenceDiagram
participant A as Agent (SDK)
participant G as Gateway
participant F as x402 Facilitator
participant C as Casper RPC
A->>G: POST /api/v1/services/request
G-->>A: 402 Payment Required + {network, amount, address}
A->>A: Build payment payload, blake2b hash, sign (Ed25519)
A->>G: Retry with X-Payment header
G->>F: verify(payment)
Note over F: signature ✓ amount ✓ recipient ✓<br/>expiry (5 min) ✓ replay nonce ✓
F->>C: settle → deploy submission
G-->>A: 200 OK + result + settlement receipt
Facilitator checks on every request: Ed25519 signature validity · exact amount · correct recipient · 5-minute expiry window · nonce-based replay protection. Settlement posts to Casper testnet RPC (with a graceful demo-mode receipt when running offline).
Gateway price list
| Endpoint | Method | Price |
|---|---|---|
/api/v1/agents/register |
POST | 0.1 CSPR |
/api/v1/agents/discover |
GET | 0.05 CSPR |
/api/v1/services/request |
POST | 0.2 CSPR |
/api/v1/defi/swap |
POST | 0.5 CSPR |
/api/v1/defi/stake |
POST | 0.3 CSPR |
/api/v1/health, /api/v1/market/stats, / |
GET | free |
🔑 Key Innovations
1. First x402 v2 implementation for Casper
No @x402/casper package exists anywhere. We built the full stack from scratch: payment client, Express middleware, and facilitator — using Casper's native Ed25519 scheme and blake2b hashing, with timestamp + nonce replay protection.
import { CasperX402Client, generateKeypair } from '@beast/casper-x402';
const client = new CasperX402Client({ keypair: generateKeypair() });
const header = client.createPaymentHeader({
network: 'casper:testnet',
amount: '200000000', // 0.2 CSPR in motes
address: '01a1b2c3...',
});
await fetch('http://localhost:3456/api/v1/services/request', {
method: 'POST',
headers: { 'X-Payment': header },
});
2. Real multi-agent coordination — not a single-contract demo
The fleet demo drives 5 of our 9 agents through a full economic loop, ~0.6 CSPR across 6 x402 payments:
BEAST-AGI ──discovers──▶ beast-auditor (0.2 CSPR → audit report)
──delegates──▶ beast-engineer (0.2 CSPR → fixes applied)
──triggers───▶ beast-trader (0.2 CSPR → yield optimization)
──validated──▶ beast-curator (quality gate)
3. MCP server: Casper for every AI assistant
Six tools any MCP client can call — GetAccountBalance, QueryAgentRegistry, GetTransactionStatus, GetNetworkStats, ExecuteTransfer, QueryDeFiPool:
{
"method": "tools/call",
"params": {
"name": "QueryAgentRegistry",
"arguments": { "serviceType": "audit", "minReputation": 90 }
}
}
4. On-chain agent identity & reputation (the RWA angle)
Agent identity — name, service catalogue, endpoint, reputation, owner — lives on Casper as a queryable asset. Reputation updates are owner-gated on-chain state transitions, giving services a portable, verifiable track record rather than a platform-locked rating.
⛓️ Smart Contract: beast-agent-registry
Rust → wasm32-unknown-unknown, built with casper-contract 1.4.4 on stable Rust (we replaced the nightly-only allocator helpers with a 30-line in-crate wasm allocator — see packages/contract/src/lib.rs).
| Entry point | Args | Returns | Access |
|---|---|---|---|
register_agent |
name, services, endpoint |
agent_id (String) |
Public |
query_agent |
agent_id |
AgentIdentity |
Public |
list_agents_by_service |
service_type |
Vec<String> |
Public |
get_agent_count |
— | u64 |
Public |
update_reputation |
agent_id, new_score, reason |
— | Registry owner |
deactivate_agent |
agent_id |
— | Agent owner / registry owner |
Design notes:
- Agents stored in a Casper dictionary under sequential IDs (
agent_0,agent_1, …) so discovery can scan without an off-chain index - Custom
ToBytes/FromBytes/CLTypedserialization forAgentIdentity - Service types validated against a fixed catalogue (reasoning, audit, code_generation, defi_execution, data_analysis, content_creation, coordination)
- Versioned contract package (
beast_agent_registry_package) → upgradeable - 16 integration test scenarios covering full lifecycle (register → query → reputation → deactivate) — see Testing above
🏆 Prize Track Alignment
| Track | Why we qualify |
|---|---|
| 🤖 Agentic AI | 9 autonomous agents with keypairs, discovery, hiring, and machine-to-machine payments; MCP server makes Casper agent-legible; SDK turns any agent into a market participant |
| 💱 DeFi | x402 micropayment rail (5 metered endpoints), agent-driven swap/stake operations, autonomous yield routing in the fleet demo |
| 🏛️ RWA | On-chain agent identity + reputation as a portable, verifiable asset — the registry pattern generalizes to any service provider whose track record should outlive a platform |
🦁 Team: The Beast
The Beast is an autonomous AGI software company — a fleet of 9 AI agents (coordinator, engineer, auditor, trader, creator, analyst, devops, curator, scout) that plans, builds, tests, and ships software with no humans in the build loop.
This entire submission — 4 TypeScript packages, the Rust contract, CI, demos, and the video — was designed, written, debugged, and shipped autonomously in under 8 hours by the same fleet that stars in the demo. The product demo is the team demo.
| 🌐 Website | thebeastagi.com |
| 𝕏 | x.com/thebeastagi |
| 📊 Live ops dashboard | dash.thebeastagi.com |
| 🧪 ATLAS (our 32B model) | demo.thebeastagi.com |
🗺️ What's Next
- [ ] Deploy
beast-agent-registryto Casper testnet + wire the gateway registry to on-chain state - [ ] Wire the 16 documented integration scenarios to
casper-engine-test-supportfor full on-chain VM testing - [ ] Real deploy construction in
settle()(fullaccount_put_deploysigning path) - [ ] CSPR.trade integration for live DeFi routing
- [ ] Publish
@beast/casper-x402to npm as a public good for the Casper ecosystem
🏆 BUIDL 46763 submitted to the Casper Agentic Buildathon 2026 — this README reflects the submitted state.
📄 License
<div align="center">
Built with 🦁 by The Beast — the world's first autonomous AGI software company.
"The Beast doesn't just deploy smart contracts. The Beast deploys autonomous fleets."
</div>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。