What if your AI assistant could check your crypto wallet balance, monitor mining rewards, and browse open bounties —
all from a single chat? That's exactly what I built: an MCP (Model Context Protocol) server that connects Claude Code
directly to the RustChain blockchain.
Here's the walkthrough.
What is RustChain?
https://github.com/Scottcjn/Rustchain is a Proof-of-Antiquity (PoA) blockchain with a twist: old hardware earns more
than new hardware. A PowerPC G4 Mac from 2002 gets a higher antiquity multiplier than a brand-new GPU server. The
chain pays out RTC tokens every epoch (~10 minutes) to miners who attest their hardware fingerprint.
What makes it interesting from a developer standpoint is the REST API — the node exposes endpoints for balances, epoch
info, miner lists, and more. That makes it a perfect candidate for an MCP integration.
What is MCP?
Model Context Protocol (MCP) is Anthropic's open standard for connecting AI assistants to external tools and data
sources. Think of it like a plugin system for Claude: you write a server that exposes "tools" (functions the AI can
call), and Claude can invoke them during a conversation.
The key insight: the LLM decides when to call your tools, based on natural language context. You describe what a tool
does, and Claude figures out when to use it.
Building the Server
I used https://github.com/jlowin/fastmcp — a Python framework that turns decorated functions into MCP tools
automatically.
Setup
pip install fastmcp httpx
# rustchain_mcp/server.py
from fastmcp import FastMCP
import httpx
NODE_URL = "https://50.28.86.131"
mcp = FastMCP("RustChain MCP")
Tool 1: Check Node Health
@mcp.tool()
async def rustchain_health() -> dict:
"""Check if the RustChain node is online and healthy."""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.get(f"{NODE_URL}/health")
r.raise_for_status()
data = r.json()
return {
"ok": data.get("ok"),
"version": data.get("version"),
"uptime_hours": round(data.get("uptime_s", 0) / 3600, 1),
}
Simple: decorate a function with @mcp.tool(), give it a docstring Claude can understand, and return structured data.
Tool 2: Wallet Balance (with USD conversion)
@mcp.tool()
async def rustchain_balance(wallet_id: str) -> dict:
"""
Get the RTC token balance for a wallet.
Args:
wallet_id: The miner/wallet identifier (e.g. 'my-miner-name')
"""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.get(
f"{NODE_URL}/wallet/balance",
params={"miner_id": wallet_id},
)
r.raise_for_status()
data = r.json()
amount_rtc = data.get("amount_rtc", 0)
RTC_PRICE_USD = 0.10
return {
"wallet": wallet_id,
"balance_rtc": amount_rtc,
"balance_usd": round(amount_rtc * RTC_PRICE_USD, 2),
}
Tool 3: Epoch Status
Each RustChain epoch lasts ~100 slots at 10 minutes each. At the end of every epoch, the pot is distributed
proportionally to active miners.
@mcp.tool()
async def rustchain_epoch() -> dict:
"""Get current epoch number, time remaining, and pot size."""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.get(f"{NODE_URL}/epoch")
r.raise_for_status()
data = r.json()
return {
"epoch": data.get("epoch"),
"slots_remaining": data.get("slots_remaining"),
"pot_rtc": data.get("pot_rtc"),
}
Tool 4: List Active Miners
@mcp.tool()
async def rustchain_miners() -> dict:
"""List all active miners and their hardware types."""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.get(f"{NODE_URL}/miners")
r.raise_for_status()
data = r.json()
return {
"count": len(data.get("miners", [])),
"miners": data.get("miners", [])[:10],
}
Tool 5: Browse Open Bounties
@mcp.tool()
async def rustchain_bounties() -> dict:
"""List open bounties available for contribution."""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.get(f"{NODE_URL}/bounties")
r.raise_for_status()
data = r.json()
return {
"open": [b for b in data.get("bounties", []) if b.get("status") == "open"],
}
Tool 6: Submit Attestation
@mcp.tool()
async def rustchain_submit_attestation(miner_id: str, hardware_fingerprint: str) -> dict:
"""
Submit a hardware attestation to earn RTC tokens.
Args:
miner_id: Your miner identifier
hardware_fingerprint: Hardware fingerprint string from the miner client
"""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.post(
f"{NODE_URL}/attest",
json={"miner_id": miner_id, "fingerprint": hardware_fingerprint},
)
r.raise_for_status()
return r.json()
Tool 7: Create Wallet
@mcp.tool()
async def rustchain_create_wallet(miner_id: str) -> dict:
"""
Create a new RustChain wallet/miner identity.
Args:
miner_id: Desired miner name (must be unique on the network)
"""
async with httpx.AsyncClient(verify=False, timeout=10) as client:
r = await client.post(
f"{NODE_URL}/wallet/create",
json={"miner_id": miner_id},
)
r.raise_for_status()
return r.json()
Running It
# Install dependencies
pip install fastmcp httpx
# Run the MCP server
python -m rustchain_mcp.server
Then in your Claude Code settings.json:
{
"mcpServers": {
"rustchain": {
"command": "python",
"args": ["-m", "rustchain_mcp.server"]
}
}
}
What I Learned
Structured data beats prose. Return dicts with clear keys — Claude reasons better over {"balance_rtc": 42} than
"Your balance is 42 RTC".Docstrings are your API contract. Claude reads your docstrings to decide when and how to call your tools. Write
them like you're explaining to a smart colleague, not a compiler.Async all the way. FastMCP is async-native. Mix sync and async and you'll hit subtle deadlocks. Just go full async
from the start.TLS cert quirks. The RustChain node uses a self-signed cert. verify=False in httpx handles it — but log a warning
in production so you don't forget it's there.
The Result
Once connected, Claude can answer questions like:
- "What's my RustChain balance?"
- "How many slots until the next epoch payout?"
- "What bounties are open right now?"
- "Create a new wallet called my-powerpc-miner"
All from natural language, no manual API calls.
Try It
The full source is in the https://github.com/Scottcjn/rustchain-bounties. If you want to earn RTC while contributing
to open source, check the open bounties — there's usually something for every skill level.
Built with FastMCP + httpx + Claude Code. RustChain is open source and actively developed.
복사 다 됐으면 오른쪽 위 Publish 버튼 눌러서 발행하고 URL 나오면 나한테 알려줘.
Top comments (0)