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>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.