How We Built a Claude Skill for Our DeFi MCP Server
Our MCP server @y0exchange/mcp gives AI agents 8 tools across 5 chains — balances, prices, gas, swaps, transfers, history. But raw tool access without workflow guidance leads to costly mistakes. We built a Claude Skill that turns isolated tool calls into safe, gas-optimized DeFi workflows. Here's how — and what we learned.
⚡ Quick Reference
| What | Details |
|---|---|
| MCP Server | @y0exchange/mcp (npm) |
| Tools | 8 (get_balance, get_portfolio, get_price, get_gas, get_quote, get_history, swap, send) |
| Chains | Ethereum, Arbitrum, Base, Polygon, BNB Chain |
| Skill | mcp/skill/ on GitHub |
| Architecture | Non-custodial — unsigned transactions, user signs on device |
| License | MIT |
🤷 The Problem: Access Without Expertise
Connect the MCP server and ask Claude to swap tokens. Here's what happens:
| ❌ Without Skill | ✅ With Skill |
|---|---|
Calls without checking balance | Calls first |
| No gas cost shown before execution | Calls , compares chains |
| Default 1% slippage on stablecoin pairs | Smart slippage: 0.1% for USDC→USDT |
| Ignores cheaper L2 chains | Suggests Arbitrum when ETH gas is $30 |
| Swaps entire ETH balance, no gas left | Warns to keep 2× gas reserve |
Every one of these costs real money. The tools work fine — the problem is workflow.
🧩 What Is a Claude Skill?
Anthropic released Agent Skills — an open standard for teaching Claude domain-specific workflows. A skill is a folder with a
SKILL.md file and optional reference docs. When installed, Claude loads the instructions automatically when a relevant task comes up.
The analogy: MCP provides the professional kitchen (tools, ingredients, equipment). Skills provide the recipes.
mcp/skill/ ├── SKILL.md # Core instructions + YAML frontmatter └── references/ ├── chains.md # Chain details, gas estimates, token lists └── safety.md # Slippage tables, gas thresholds, risk rules
SKILL.md uses Anthropic's progressive disclosure pattern — three-level loading:
| Level | What | When loaded |
|---|---|---|
| YAML frontmatter | Name, description, trigger phrases | Always |
| SKILL.md body | Workflows, tool reference, safety rules | When skill is relevant |
| references/ files | Chain details, slippage tables, token lists | On demand |
This keeps context efficient. The frontmatter triggers activation:
name: y0-defi-assistant description: DeFi portfolio management, token swaps, transfers, gas optimization, and price research using the y0 MCP server. Use when user asks to "check my portfolio", "swap tokens", "send crypto", "check gas", "token price", "transaction history", or any crypto/DeFi/blockchain wallet operation.
Claude reads this and decides whether to load the full skill. The trigger phrases ensure it activates on natural language like "how's my crypto" or "buy some ETH."
🔄 Before vs After: Token Swap
Without Skill:
User: "Swap 100 USDC to ETH" → Claude calls
swap directly → might fail on insufficient balance, gas might eat 10% of swap value, slippage too high. User finds out after the fact.
With Skill:
User: "Swap 100 USDC to ETH"
— confirms 100 USDC availableget_balance
— checks gas costs, compares chainsget_gas
— gets expected output with exchange rateget_quote- Claude shows everything: "You'll get ~0.0312 ETH. Gas: $0.08 on Arbitrum vs $14.50 on Ethereum. Recommend Arbitrum. Confirm?"
- User confirms →
swap
Same tools. Completely different experience.
📋 The Eight Workflows
| Workflow | What It Does | Key Safety Check |
|---|---|---|
| Portfolio Check | Aggregates holdings across 5 chains with USD values | Flags concentration risk if >80% in one asset |
| Token Swap | Balance → gas → quote → confirm → execute | Smart slippage by token type, gas-to-value ratio |
| Send Tokens | Address verification → balance → gas → confirm | Suggests test transaction for amounts >$1,000 |
| Gas Optimization | Cross-chain gas comparison with USD estimates | Recommends L2s when ETH gas >50 gwei |
| Price Research | Current prices with 24h change | Notes volatility >10%, follows up with |
| Transaction History | Filtered by type with IN/OUT direction | Explains approvals when users ask |
| Portfolio Rebalance | Full reallocation: analyze → plan → quote each → execute | Individual confirmation per swap |
| Cross-Chain Comparison | Find cheapest chain for any operation | Checks where you already hold the token |
🛡️ Domain Knowledge That Saves Money
The real value isn't workflow orchestration — it's the DeFi expertise embedded in each step.
Native token reserve. You try to swap your entire ETH balance. Claude stops you — you need ETH for gas. The skill recommends keeping at least 2× the estimated gas cost. This catches even experienced DeFi users.
Gas-to-value ratio. Gas would eat >5% of your swap value? Warning. More than 10%? Strong recommendation to use a different chain or wait. A $20 swap on Ethereum when gas is $15 is a bad deal.
Smart slippage.
| Token Type | Slippage | Example |
|---|---|---|
| Stablecoin pairs | 0.1–0.3% | USDC → USDT |
| Major pairs | 0.5% | ETH → USDC |
| Default | 1.0% | Any other pair |
| Large swaps (>$5k) | Reduced further | Lower impact tolerance |
Default 1% slippage on a USDC→USDT swap is throwing money away. The skill knows this.
Chain-aware routing. USDC exists on Ethereum, Arbitrum, Base, and Polygon. Gas cost difference: 100×. The skill checks where you already hold the token and suggests the cheapest chain.
🔒 Non-Custodial, Enforced at Every Layer
The MCP server builds unsigned transactions. The user signs on their device. y0 never touches private keys.
The skill adds a second enforcement layer — it tells Claude to never call
or swap
without user confirmation. Display all details first. Show the recipient address. Show the gas cost. Wait for "yes."send
Defense in depth. Even if someone tries to prompt-inject Claude into executing a transaction, the skill's instructions create friction. Not bulletproof — nothing in LLM-land is — but a meaningful safety layer.
🚀 How to Use It
1. Connect the MCP server:
As a connector (Claude.ai, Claude Mobile, ChatGPT):
- Settings → Connectors → Add custom connector
- URL:
https://mcp.y0.exchange/mcp?key=YOUR_API_KEY
As an npm package (Claude Code, Cursor):
npx @y0exchange/mcp
2. Install the skill:
- Download the skill folder
- Zip it → Claude.ai → Settings → Capabilities → Skills → Upload
3. Test it: Ask Claude: "Check my crypto portfolio" — it should call
get_portfolio, show a clear breakdown, and flag concentration risks.
Read-only tools work without an API key. Get your key at app.y0.exchange to unlock swaps and transfers.
🔮 What's Next
More chains. The shared package already defines Avalanche, Optimism, zkSync, Linea, Scroll, Blast, and Solana. We'll enable them as we add RPC endpoints and token lists.
Bridge workflow. The skill has a placeholder for cross-chain bridging. Once the MCP server adds a
bridge tool, the skill will orchestrate the full flow: compare bridge costs, check destination gas, execute with confirmation.
Skill distribution. Right now users download a zip and upload it. Anthropic is working on tighter MCP + Skills integration. When skills can ship alongside MCP servers, we'll bundle them.
The MCP server is open source under MIT license. The skill is in the same repo. Use it, fork it, improve it.
Building MCP integrations or AI-powered DeFi workflows? More guides on AI infrastructure, developer tools, and Web3 at esso.dev. Follow CTO Blog on Telegram for build logs and updates.


Comments
Loading comments...