Defai Gateway
FreeNot checkedThe first MCP server connecting AI agents to Base Chain DeFi. Check balances, swap tokens, track pools, analyze wallets — all via natural language.
About
The first MCP server connecting AI agents to Base Chain DeFi. Check balances, swap tokens, track pools, analyze wallets — all via natural language.
README
🚀 Try it free → Deploy in 5 minutes
GitHub Stars MCP Base Solana License Python CI Docker
The first production-ready MCP server connecting AI Agents to Base + Solana DeFi.
21 tools. Two chains. One line to deploy.
pip install -r requirements.txt && python server.py
Deploy Now → · View on GitHub · Join the Community
💎 Why DeFAI Gateway?
AI agents are the new user interface. Every DeFi protocol will be accessed through them — and DeFAI Gateway is the infrastructure layer that makes it possible.
Give any AI agent full read + limited execute access to Base Chain and Solana DeFi. Check balances, analyze wallets, track liquidity pools, discover new tokens, and prepare swaps — all through natural language.
No private keys required. No database. No storage. 100% auditable open source.
"The MCP connector for the on-chain economy."
💰 Pricing — Start Free, Upgrade for Power
| Tier | Monthly Operations | Price | What You Get |
|---|---|---|---|
| 🆓 Free | 1,000/mo | $0.00 ✅ | Balances, token info, gas prices, Solana tools, 10 free calls/day |
| ⭐ Pro | 10,000/mo | $19.99/mo 🔥 | All 21 tools + analytics + WebSocket tracking + priority support |
| 🏢 Enterprise | Unlimited | $99/mo 🚀 | Dedicated RPC, custom integrations, SLA, white-label |
| 🔒 $GATE Holder | Unlimited | Hold $GATE 🪙 | All Pro features + swap execution + revenue share + governance |
💳 Pay with SOL, ETH (Base), USDC, or credit card. No crypto required.
👉 Start Free → Deploy in 5 minutes
🛠️ Tools (21 Total) + x402 Payment Gateway + WebSocket Tracking + Solana
| # | Tool | Description | Tier | Chain |
|---|---|---|---|---|
| 1 | get_balance |
ETH + ERC-20 token balances | 🆓 Free | Base |
| 2 | get_token_info |
Token name, symbol, decimals, supply | 🆓 Free | Base |
| 3 | get_gas_price |
Live Base gas in gwei | 🆓 Free | Base |
| 4 | get_pools |
Top Aerodrome liquidity pools (3 data sources) | ⭐ Pro | Base |
| 5 | analyze_wallet |
Full wallet breakdown + portfolio | ⭐ Pro | Base |
| 6 | track_new_tokens |
Scan for new token deployments (3-tier fallback) | ⭐ Pro | Base |
| 7 | get_swap_quote |
Live swap quote with price impact + route info | 🔒 $GATE | Base |
| 8 | build_swap_transaction |
Full EIP-1559 swap tx (nonce, gas, chainId) | 🔒 $GATE | Base |
| 9 | build_approve_transaction |
Token approval tx for Aerodrome Router | 🆓 Free | Base |
| 10 | check_allowance |
Check current allowance before swapping | 🆓 Free | Base |
| 11 | monitor_price |
Price check + target comparison (limit-order style) | ⭐ Pro | Base |
| 12 | get_token_price |
Live price in USD (CoinGecko) | ⭐ Pro | Base |
| 13 | get_recent_transactions |
Recent wallet activity (Blockscout) | ⭐ Pro | Base |
| 14 | get_payment_status |
Your tier + remaining free calls | ⭐ Pro | Base |
| 15 | subscribe |
Subscribe to real-time WebSocket streams | ⭐ Pro | Base |
| 16 | get_ws_info |
WebSocket connection info + active channels | 🆓 Free | Base |
| 17 | sol_get_balance |
SOL + SPL token balances for Solana wallets | 🆓 Free | Solana |
| 18 | sol_get_token_info |
Solana SPL token metadata (supply, decimals) | 🆓 Free | Solana |
| 19 | sol_get_recent_txs |
Recent transaction history on Solana | 🆓 Free | Solana |
| 20 | sol_get_gas_price |
Current Solana fee (lamports per signature) | 🆓 Free | Solana |
| 21 | sol_analyze_wallet |
Full Solana wallet analysis + portfolio | ⭐ Pro | Solana |
Tool Tiers Explained
- 🆓 Free — No payment needed. Ever. Great for basic queries and monitoring.
- ⭐ Pro ($19.99/mo) — Unlock analytics, tracking, and premium data tools.
- 🔒 $GATE — Hold the $GATE token for unlimited access to everything including swap execution.
Pro Tip: Start with Free. When you hit the 1,000 ops/month limit, upgrade to Pro for $19.99. Holding $GATE unlocks everything.
💸 Save on Hosting — Deploy DeFAI Gateway on These Providers
We recommend the following cloud providers to run DeFAI Gateway in production. Using these links helps support development at no extra cost to you.
| Provider | Starting At | Best For | Referral Link |
|---|---|---|---|
| DigitalOcean | $4/mo | Simple VPS, 1-click deploy | Deploy on DO → |
| Vultr | $2.50/mo | Global edge, NVMe storage | Deploy on Vultr → |
| Hetzner | €3.99/mo | Best price/performance in EU | Deploy on Hetzner → |
All three run python server.py with zero config. A $4 Droplet handles 100+ concurrent agents.
🪙 x402 Payment Gateway (New in v2.3)
AI Agents pay per API call in USDC on Base Chain.
The x402 standard lets AI agents make HTTP calls with embedded USDC micropayments.
How it works
1. Agent sends USDC to FEE_WALLET on Base
2. Agent calls POST /deposit with tx_hash
3. Server verifies on-chain → adds credit balance
4. Agent calls POST /mcp with tool + args
5. Server deducts ~$0.001 per call from credit
6. Response returned normally
Start the x402 server
python x402_server.py --port 4020 --fee-wallet 0xYourWallet
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/mcp |
POST | Call any MCP tool (requires x402 header or credit) |
/deposit |
POST | Verify USDC tx and add credits |
/status |
GET | Check credit balance and usage |
/pricing |
GET | Get pricing table + curl example |
/health |
GET | Server health check |
Per-Call Pricing
| Feature | Cost |
|---|---|
| Free tier | 10 calls/day (no payment needed) |
| Per call | ~$0.001 USDC |
| Minimum deposit | $0.01 USDC |
| $GATE holders | Unlimited (no per-call fee) |
🏗️ Architecture
AI Agent ──┬── MCP (stdio) ──→ DeFAI Gateway ──┬── Base RPC (on-chain)
│ 21 Tools (Base + Solana) ├── Solana RPC (JSON-RPC)
│ ├── Blockscout API (transactions)
│ ├── Aerodrome API (pools)
│ ├── CoinGecko API (prices)
│ ├── Jupiter API (Solana prices)
│ └── Clanker API (new tokens)
│
├── HTTP (x402) ──→ x402 Payment Gateway ──┬── USDC verification (on-chain)
│ ├── Credit ledger
│ ├── /mcp (forward to MCP)
│ ├── /deposit (add credits)
│ ├── /status (check balance)
│ └── /pricing (per-call costs)
│
└── WebSocket ──→ Real-Time Tracking ──┬── Pools (30s)
├── Wallet (15s)
└── Tokens (60s)
Key design decisions:
- Read-only by default — no private keys needed for 9/10 tools
- Stateless — no database, no storage, no user data
- Payment gating built-in — free tier, premium, token-gated
- Layered API fallbacks — always returns data even if upstream APIs fail
📡 WebSocket Real-Time Tracking (New in v2.4)
Live streaming of pools, wallets, and tokens via WebSocket.
No polling needed — subscribe to a channel and receive push updates.
Quick Start
# Terminal 1: Start WebSocket server
python ws_server.py --port 4021
# Terminal 2: Connect with any WebSocket client
python -c "
import asyncio, websockets
async def main():
async with websockets.connect('ws://localhost:4021') as ws:
await ws.send('{\"subscribe\": \"pools\"}')
async for msg in ws:
print(msg)
asyncio.run(main())
"
Channels
| Channel | Data | Interval | Example |
|---|---|---|---|
pools |
Aerodrome pool TVL/APR changes | 30s | {"subscribe": "pools"} |
wallet:0x... |
New wallet transactions | 15s | {"subscribe": "wallet:0xYourAddress"} |
tokens |
New token deployments | 60s | {"subscribe": "tokens"} |
Protocol
All messages are JSON. Server pushes updates with timestamp and change deltas.
// Server → Client update
{"channel": "pools", "type": "pool_update", "data": [...], "timestamp": 1712345678}
// Change detection (only pushes when TVL/APR changes)
{"channel": "pools", "type": "pool_update", "data": [{
"name": "AERO/WETH", "tvl_usd": 48200000, "apr": 14.8,
"change": {"tvl_delta": 250000, "apr_delta": 0.3}
}]}
Run modes
# Standalone
python ws_server.py --port 4021
# Via server.py
python server.py --ws
🌐 Solana Cross-Chain Support (New in v2.5)
One server. Two chains. Auto-detect. DeFAI Gateway now routes to Base or Solana based on the address format.
| Input | Detected Chain |
|---|---|
0x... (42 hex chars) |
Base (EVM) |
base58... (32-44 chars) |
Solana |
Solana Tools
| Tool | What it does |
|---|---|
sol_get_balance |
SOL balance + all SPL token balances |
sol_get_token_info |
Token metadata (name, supply, decimals) |
sol_get_recent_txs |
Recent transaction history with Solscan links |
sol_get_gas_price |
Current fee in lamports per signature |
sol_analyze_wallet |
Full portfolio: balance + tokens + recent txs |
Supported Tokens
SOL, USDC, USDT, RAY, SRM, JUP, BONK, PYTH, WIF + any SPL token by mint address.
Architecture
AI Agent → MCP ──→ DeFAI Gateway ──┬── Base RPC (EVM)
├── Solana RPC (JSON-RPC)
├── Jupiter API (prices)
└── Auto-Detect: 0x→Base, base58→Solana
🔄 Swap Flow (AI Agent Example)
A complete swap from USDC → AERO:
1. check_allowance("USDC", "0xYourWallet")
→ Needs approval? Yes →
2. build_approve_transaction("USDC", caller_address="0xYourWallet")
→ Sign tx in wallet → Wait for confirmation →
3. get_swap_quote("USDC", "AERO", 100, caller_address="0xYourWallet")
→ Expected: 850.5 AERO, Route: direct, Price Impact: 0.02%
4. build_swap_transaction("USDC", "AERO", 100, slippage=0.5, caller_address="0xYourWallet")
→ Full EIP-1559 tx with nonce, gas, chainId → Sign + send in wallet
AI agents execute this autonomously: The agent builds the tx, the user signs with their wallet, the agent tracks the result.
🗺️ Roadmap
✅ v1 (launched)
- 6 core tools: balances, tokens, gas, pools, analytics, tracking
- Payment gating (free/premium/$GATE)
✅ v2 (current)
- 10 tools: + token price, recent txs, payment status, swap prep
- Blockscout integration (no API key needed)
- Aerodrome v2 API fallback
- Retry logic + structured error handling
- CI/CD with GitHub Actions
- Tests (20 test cases)
- Docker multi-stage build
- Smithery.yaml for Smithery deployment
✅ v2.2
- 14 tools: + swap execution system (quote + EIP-1559 tx + approval + allowance + price monitoring)
- Multi-hop routing (direct → via WETH → via USDC)
exact_inandexact_outswap types- EIP-1559 transaction builder with nonce, gas, chainId, deadline
- Token approval system (free tier)
- Price monitoring with target comparison (limit-order style)
- Aerodrome Router ABI integration (full)
✅ v2.4
- WebSocket Real-Time Tracking — live streaming of pools, wallets, and tokens
- 16 tools: + subscribe, get_ws_info
- 3 channels: pools (30s), wallet (15s), tokens (60s)
- Change detection — only pushes when data changes (TVL delta, APR delta)
- Auto-cleanup of dead WebSocket connections
- Standalone:
python ws_server.pyor integrated:python server.py --ws - 18 WebSocket tests (63 total across test suite)
- x402 Payment Gateway — AI agents pay per API call in USDC on Base
✅ v2.5 (current)
- Solana Cross-Chain Support — 5 Solana tools (tools 17-21)
sol_get_balance— SOL + SPL token balancessol_get_token_info— Token metadata (supply, decimals, explorer)sol_get_recent_txs— Recent transaction historysol_get_gas_price— Current fee in lamports per signaturesol_analyze_wallet— Full portfolio + recent activity- Multi-chain auto-detect —
0x→ Base,base58→ Solana - Token registry (9 well-known SPL tokens)
- 19 Solana-specific tests (82 total across test suite)
🔜 v2.6 — Next Sprint
- Limit orders via Aerodrome
- Solana swap execution — Jupiter integration
- Interactive demo on landing page — try it in your browser
- Multi-wallet support — manage multiple addresses
🔮 v3.0 — $GATE Token Launch on Base
- $GATE token launch on Base chain — governance + utility token
- Unlimited access for $GATE holders — no per-call fees, no monthly limits
- Revenue share — $GATE stakers earn a cut of protocol fees
- DAO governance — vote on tool prioritization, pricing, and protocol upgrades
- Token-gated premium tools — exclusive features for $GATE holders
- Cross-chain expansion — additional L2s and non-EVM chains
🔌 Integration Examples
Claude Desktop
{
"mcpServers": {
"defai-gateway": {
"command": "python",
"args": ["/path/to/server.py"],
"env": {
"RPC_URL": "https://mainnet.base.org"
}
}
}
}
VS Code (Continue extension)
- Open VS Code → Continue extension
- Go to MCP Server settings
- Add:
{
"mcpServers": {
"defai-gateway": {
"command": "python",
"args": ["/path/to/server.py"]
}
}
}
Docker
docker build -t defai-gateway .
docker run --rm defai-gateway python server.py --http 8080
Hermes Agent
# In hermes config.yaml
tools:
mcp_servers:
- name: "defai-gateway"
command: "python"
args: ["/home/henri/defai-gateway/server.py"]
Smithery
Deploy to Smithery in one click — your own hosted instance with auto-scaling.
⚙️ Configuration
| Env Var | Default | Description |
|---|---|---|
RPC_URL |
https://mainnet.base.org |
Base RPC endpoint |
SOLANA_RPC |
https://api.mainnet-beta.solana.com |
Solana RPC endpoint |
SOLANA_RPC_FALLBACK |
https://solana-api.projectserum.com |
Solana fallback RPC |
GATE_TOKEN |
"" |
$GATE token address for gating |
FEE_WALLET |
0x000... |
Fee collection wallet |
FEE_BPS |
5 |
Fee basis points (0.05%) |
DAILY_FREE_CALLS |
10 |
Free calls per wallet per day |
🧪 Development
# Run tests
pip install pytest pytest-asyncio
pytest tests/ -v
# Run with HTTP (SSE) mode
python server.py --http 8080
# Run in x402 mode
python server.py --x402 4020
🔐 Security
- Server NEVER touches your private key — all swap data is unsigned
- Open source — 100% auditable, ~800 lines
- No data stored — queries go directly to public RPC + APIs
- Rate limited to prevent abuse
⚡ Support the Project
DeFAI Gateway is open-source and free to use. If it saves you time or makes you money, consider supporting development.
☕ Buy Me a Coffee
ETH / USDC (Base): 0xYourWalletAddressHere
SOL / USDC (Solana): YourSolanaAddressHere
🐙 GitHub Sponsors
🔗 Referral Links (You Save, We Earn)
Using these links to deploy your infrastructure helps fund development at zero cost to you:
| Provider | Starting At | Referral Link |
|---|---|---|
| DigitalOcean | $4/mo | Sign Up → |
| Vultr | $2.50/mo | Sign Up → |
| Hetzner | €3.99/mo | Sign Up → |
Every sign-up funds more features, better infrastructure, and faster development. 🙏
📬 Contact & Support
- Email: [email protected]
- GitHub Issues: Report a bug
- Token: $GATE — coming to Base chain. Ask about $GATE at your favorite DEX.
📋 MCP Marketplace Submissions
Get DeFAI Gateway listed on the major MCP registries:
- mcp.so → Submit — Type: "MCP Server", URL:
https://github.com/Dev-Herni/defai-gateway. Requires GitHub login. - Smithery →
PUT /servers/{namespace/server}/releaseswith API key from smithery.ai account settings.
⚠️ Both require the user (Henri) to log in via browser once — the agent can fill the form but can't authenticate.
📜 License
MIT — free to use, modify, and distribute. Built on Base and Solana.
Part of the DeFAI ecosystem · Powered by Hermes Agent
Installing Defai Gateway
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/Dev-Herni/defai-gatewayFAQ
Is Defai Gateway MCP free?
Yes, Defai Gateway MCP is free — one-click install via Unyly at no cost.
Does Defai Gateway need an API key?
No, Defai Gateway runs without API keys or environment variables.
Is Defai Gateway hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Defai Gateway in Claude Desktop, Claude Code or Cursor?
Open Defai Gateway on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzCompare Defai Gateway with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
