jayeshchowdary/lifi-mcp
If you are the rightful owner of lifi-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server for interacting with Li.FI cross-chain bridge and swap aggregator.
LiFi MCP Server (Python)
A Model Context Protocol (MCP) server for interacting with Li.FI cross-chain bridge and swap aggregator.
Built with FastMCP framework for robust MCP protocol implementation.
๐ Table of Contents
- Quick Start
- Tool Categories
- Testing Without Credentials
- Setting Up Wallet Tools
- Complete Testing Guide
- Usage Examples
- Troubleshooting
๐ Quick Start
Prerequisites
- Python 3.10 or higher
uv
package manager (install with:curl -LsSf https://astral.sh/uv/install.sh | sh
)
Installation
# 1. Navigate to project directory
cd lifi-mcp-python
# 2. Install dependencies
uv sync
# 3. Start Inspector (easiest way to test)
./run-inspector-fast.sh
Browser opens automatically with working MCP server! โ
๐ ๏ธ Tool Categories
โ Read-Only Tools (NO Credentials Needed)
These 12 tools work immediately without any wallet or credentials:
Tool | What It Does | Pagination | Example Use Case |
---|---|---|---|
get_chains | Lists all supported blockchains | โ Yes | "Which chains does Li.FI support?" |
get_tokens | Lists all available tokens | โ Yes | "What tokens can I swap?" |
get_token | Get specific token info | โ No | "Tell me about USDC on Ethereum" |
get_quote | Get swap/bridge quote | โ No | "How much ETH will I get for 100 USDC?" |
get_status | Check transaction status | โ No | "Is my bridge transaction complete?" |
get_connections | List chain connections | โ Yes | "Can I bridge from Ethereum to Polygon?" |
get_tools_list | List bridges and DEXs | โ Yes | "Which bridges are available?" |
get_chain_by_id | Get chain by ID | โ No | "What is chain ID 1?" |
get_chain_by_name | Get chain by name | โ No | "Tell me about Polygon" |
get_native_token_balance | Check ETH/MATIC/etc balance | โ No | "What's Vitalik's ETH balance?" |
get_token_balance | Check ERC20 token balance | โ No | "What's my USDC balance?" |
get_allowance | Check token spending approval | โ No | "How much USDC can this contract spend?" |
โจ You can test all of these immediately!
๐ Pagination Support: Tools marked with โ support pagination to handle large result sets efficiently.
๐ Wallet Tools (Credentials REQUIRED)
These 5 tools require an Ethereum wallet keystore:
Tool | What It Does | Risk Level |
---|---|---|
get_wallet_address | Shows your wallet address | ๐ข Safe |
execute_quote | Executes a swap/bridge | ๐ด Spends funds |
approve_token | Approve token spending | ๐ก Moderate |
transfer_token | Transfer ERC20 tokens | ๐ด Spends funds |
transfer_native | Transfer ETH/MATIC/etc | ๐ด Spends funds |
โ ๏ธ Warning: Wallet tools can spend your cryptocurrency. Always test on testnets first!
๐ Using Pagination
Some tools return large amounts of data. These tools support pagination to make results more manageable:
Paginated Tools
get_chains
- Lists 50+ blockchain chainsget_tokens
- Can list thousands of tokensget_connections
- Can return hundreds of chain connectionsget_tools_list
- Lists all bridges and DEXs
Pagination Parameters
Parameter | Type | Default | Range | Description |
---|---|---|---|---|
page | integer | 1 | 1-โ | Page number to retrieve |
page_size | integer | 50 | 1-500 | Items per page |
Example: Paginated get_chains
{
"page": 1,
"page_size": 10
}
Response:
{
"chains": [
{ "id": 1, "name": "Ethereum", ... },
{ "id": 10, "name": "Optimism", ... },
...10 items total...
],
"pagination": {
"page": 1,
"page_size": 10,
"total_items": 57,
"total_pages": 6,
"has_next": true,
"has_prev": false
}
}
Example: Get Next Page
{
"page": 2,
"page_size": 10
}
Example: Larger Page Size
{
"page": 1,
"page_size": 100
}
Pagination Response Fields
Field | Description |
---|---|
page | Current page number |
page_size | Items per page |
total_items | Total number of items across all pages |
total_pages | Total number of pages available |
has_next | Boolean indicating if more pages exist |
has_prev | Boolean indicating if previous pages exist |
๐งช Testing Without Credentials (Read-Only Mode)
Step 1: Start Inspector
cd lifi-mcp-python
./run-inspector-fast.sh
What happens:
- Terminal shows:
โ Setup verified!
- Browser opens automatically
- Inspector shows: "Server: Connected"
- Tools dropdown shows 12+ tools
Step 2: Test Your First Tool
In the browser Inspector:
- Select tool:
get_chains
- Arguments:
{}
- Click: "Call Tool"
- Result: JSON with 57+ blockchain chains โ
Step 3: More Test Examples
Example 1: Get Ethereum Chain Info
Tool: get_chain_by_name
Arguments: {
"name": "ethereum"
}
Result:
{
"id": 1,
"name": "Ethereum",
"key": "eth",
"chainType": "EVM",
"nativeToken": {
"symbol": "ETH",
"decimals": 18,
"address": "0x0000000000000000000000000000000000000000"
}
}
Example 2: Check Vitalik's ETH Balance
Tool: get_native_token_balance
Arguments: {
"rpcUrl": "https://eth.llamarpc.com",
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
}
Result:
{
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"balance": "1234.56",
"symbol": "ETH",
"decimals": 18
}
Example 3: Get USDC Token Info
Tool: get_token
Arguments: {
"chain": "1",
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
}
Result:
{
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"chainId": 1,
"logoURI": "https://..."
}
Example 4: Get Swap Quote (No Execution)
Tool: get_quote
Arguments: {
"fromChain": "1",
"toChain": "137",
"fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"toToken": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"fromAddress": "0xYourAddress",
"fromAmount": "1000000"
}
Result: Complete quote with estimated output, fees, and transaction data (but doesn't execute)
๐ Setting Up Wallet Tools (Requires Credentials)
What You Need
To use wallet tools, you need an Ethereum keystore file. This is an encrypted JSON file containing your private key.
Option 1: Create a Test Wallet (RECOMMENDED for Testing)
Step 1: Create Keystore with MetaMask
- Install MetaMask: https://metamask.io/
- Create new wallet or use existing
- Export private key:
- MetaMask โ Account Details โ Export Private Key
- Enter password
- Copy private key (starts with
0x...
)
Step 2: Convert to Keystore Format
Use Python to create encrypted keystore:
from eth_account import Account
import json
import getpass
# Your private key from MetaMask
private_key = "0x..." # Paste here
# Create account
account = Account.from_key(private_key)
# Get password for encryption
password = getpass.getpass("Enter password for keystore: ")
# Create keystore
keystore = account.encrypt(password)
# Save to file
keystore_path = f"~/.lifi-mcp/keystore/{account.address}.json"
import os
os.makedirs(os.path.dirname(os.path.expanduser(keystore_path)), exist_ok=True)
with open(os.path.expanduser(keystore_path), 'w') as f:
json.dump(keystore, f)
print(f"โ
Keystore saved to: {keystore_path}")
print(f"๐ Address: {account.address}")
Step 3: Fund Your Test Wallet
For Testing (Use Testnet!):
-
Get Testnet ETH:
- Sepolia Faucet: https://sepoliafaucet.com/
- Paste your address
- Receive free test ETH
-
Get Testnet Tokens:
- Bridge testnet ETH to other chains
- Use testnet DEXs to get tokens
โ ๏ธ NEVER USE MAINNET FOR TESTING! Always start with testnets.
Option 2: Use Existing Keystore
If you already have a keystore file (e.g., from Geth, MyEtherWallet):
-
Copy keystore to standard location:
mkdir -p ~/.lifi-mcp/keystore cp your-keystore.json ~/.lifi-mcp/keystore/
-
Note the filename (e.g.,
UTC--2024-...--0xabcd1234
)
Option 3: Hardware Wallet (Advanced)
Hardware wallets (Ledger, Trezor) are more secure but require additional setup. See for instructions.
๐ Using Wallet Tools
Method 1: Start Inspector with Keystore
cd lifi-mcp-python
# Replace with your keystore filename and password
npx @modelcontextprotocol/inspector \
"$(pwd)/.venv/bin/python" \
-m lifi_mcp_python.main_fastmcp \
--keystore "UTC--2024-...--0xabcd1234.json" \
--password "YourPassword"
What happens:
- Server loads your wallet
- All 17 tools are now available (12 read-only + 5 wallet)
- Your address is loaded and ready
Method 2: Run Server Directly
cd lifi-mcp-python
# Start server with wallet
.venv/bin/python -m lifi_mcp_python.main_fastmcp \
--keystore "UTC--2024-...--0xabcd1234.json" \
--password "YourPassword"
Keystore Location
The server looks for keystores in:
~/.lifi-mcp/keystore/
Or you can provide the full path:
--keystore "/full/path/to/keystore.json"
๐งช Complete Testing Guide
Phase 1: Read-Only Testing (5 minutes)
No credentials needed!
# 1. Start Inspector
./run-inspector-fast.sh
# 2. Test these tools in order:
- get_chains โ
{}
- get_chain_by_name โ
{"name": "ethereum"}
- get_tokens โ
{"chains": "1"}
- get_native_token_balance โ
{"rpcUrl": "https://eth.llamarpc.com", "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"}
Phase 2: Quote Testing (10 minutes)
Still no credentials needed!
# Get a quote for swapping USDC on Ethereum to USDC on Polygon
Tool: get_quote
Arguments: {
"fromChain": "1",
"toChain": "137",
"fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"toToken": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"fromAddress": "0xYourAddress",
"fromAmount": "1000000"
}
What you get:
- Estimated output amount
- Gas fees
- Route (which bridges/DEXs used)
- Transaction data (for execution)
Phase 3: Wallet Testing (WITH Credentials)
โ ๏ธ Use Testnet Only!
# 1. Create test wallet (see above)
# 2. Fund with testnet ETH
# 3. Start Inspector with keystore
npx @modelcontextprotocol/inspector \
"$(pwd)/.venv/bin/python" \
-m lifi_mcp_python.main_fastmcp \
--keystore "your-keystore.json" \
--password "YourPassword"
Test wallet tools:
-
get_wallet_address โ
{}
- Should show your address
-
get_native_token_balance โ
{"rpcUrl": "https://rpc.sepolia.org", "address": "YOUR_ADDRESS"}
- Check your testnet balance
-
approve_token (if needed) โ See examples below
-
transfer_token โ See examples below
Phase 4: Execute Swap (ADVANCED - Testnet Only)
# Step 1: Get quote
Tool: get_quote
Arguments: {...} # See Phase 2
# Step 2: From quote response, copy the "transactionRequest" object
# Step 3: Execute
Tool: execute_quote
Arguments: {
"rpcUrl": "https://rpc.sepolia.org",
"transactionRequest": {...} # Paste from quote
}
๐ Usage Examples
Example 1: Check Token Balance
No credentials needed!
Tool: get_token_balance
Arguments: {
"rpcUrl": "https://eth.llamarpc.com",
"tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"walletAddress": "0xYourAddress"
}
Example 2: Check Token Allowance
No credentials needed!
Tool: get_allowance
Arguments: {
"rpcUrl": "https://eth.llamarpc.com",
"tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"ownerAddress": "0xYourAddress",
"spenderAddress": "0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE"
}
Example 3: Approve Token (Requires Keystore)
Tool: approve_token
Arguments: {
"rpcUrl": "https://rpc.sepolia.org",
"tokenAddress": "0xTokenAddress",
"spenderAddress": "0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE",
"amount": "1000000"
}
Example 4: Transfer Tokens (Requires Keystore)
Tool: transfer_token
Arguments: {
"rpcUrl": "https://rpc.sepolia.org",
"tokenAddress": "0xTokenAddress",
"to": "0xRecipientAddress",
"amount": "1000000"
}
Example 5: Transfer Native Token (Requires Keystore)
Tool: transfer_native
Arguments: {
"rpcUrl": "https://rpc.sepolia.org",
"to": "0xRecipientAddress",
"amount": "1000000000000000"
}
๐ Finding RPC URLs
Free Public RPCs
Chain | RPC URL |
---|---|
Ethereum Mainnet | https://eth.llamarpc.com |
Ethereum Sepolia (testnet) | https://rpc.sepolia.org |
Polygon | https://polygon-rpc.com |
Polygon Mumbai (testnet) | https://rpc-mumbai.maticvigil.com |
Arbitrum | https://arb1.arbitrum.io/rpc |
Optimism | https://mainnet.optimism.io |
Binance Smart Chain | https://bsc-dataseed.binance.org |
Dedicated RPC Services (Better Performance)
-
Infura: https://infura.io/
- Free tier: 100K requests/day
- Sign up โ Create project โ Copy endpoint
-
Alchemy: https://www.alchemy.com/
- Free tier: 300M compute units/month
- Sign up โ Create app โ Copy HTTPS endpoint
-
Ankr: https://www.ankr.com/
- Free tier available
- No signup needed for public endpoints
๐งฐ Use in Claude Desktop
Configuration
Add to claude_desktop_config.json
:
Read-Only Mode (No Wallet):
{
"mcpServers": {
"lifi": {
"command": "/Users/jayeshkumarchowdary/Downloads/lifi-mcp-main/lifi-mcp-python/.venv/bin/python",
"args": ["-m", "lifi_mcp_python.main_fastmcp"]
}
}
}
With Wallet (Testnet Only!):
{
"mcpServers": {
"lifi": {
"command": "/Users/jayeshkumarchowdary/Downloads/lifi-mcp-main/lifi-mcp-python/.venv/bin/python",
"args": [
"-m",
"lifi_mcp_python.main_fastmcp",
"--keystore",
"your-keystore.json",
"--password",
"YourPassword"
]
}
}
}
โ ๏ธ Security Note: Storing passwords in config files is NOT secure. Use environment variables or prompt-based authentication for production.
๐ Troubleshooting
"Module not found"
cd lifi-mcp-python
uv sync
"No tools showing in Inspector"
- Refresh browser (F5)
- Wait 5 seconds
- Check terminal for errors
- Try:
./run-inspector-fast.sh
again
"Keystore not found"
# Check keystore location
ls -la ~/.lifi-mcp/keystore/
# Or provide full path
--keystore "/full/path/to/keystore.json"
"Insufficient funds"
- Check you have enough ETH for gas
- Check token balance: Use
get_token_balance
tool - For testnets: Get more from faucets
"Transaction failed"
- Check gas price (might be too low)
- Check token allowance: Use
get_allowance
tool - Check RPC URL is correct
- Try different RPC endpoint
๐ Additional Resources
- Li.FI API Documentation: https://docs.li.fi/
- Li.FI Supported Chains: https://li.fi/chains
- Model Context Protocol: https://modelcontextprotocol.io/
- FastMCP Framework: https://github.com/jlowin/fastmcp
- Ethereum Testnet Faucets: https://faucetlink.to/
๐ Security Best Practices
DO โ
- Test on testnets first
- Use dedicated test wallets
- Keep keystores secure
- Never share private keys
- Verify transaction details
- Use hardware wallets for large amounts
DON'T โ
- Use mainnet for testing
- Store passwords in plaintext
- Commit keystores to git
- Share keystores with anyone
- Skip transaction verification
- Use production wallets for testing
๐ Configuration Files
This project includes two configuration files for MCP client integration:
lifi_mcp_config.json
MCP client configuration for launching and connecting to the server. Use this with MCP clients like Claude Desktop or Inspector.
{
"mcpServers": {
"lifi-mcp": {
"command": "bash",
"args": ["-c", "cd /path/to/lifi-mcp-python && .venv/bin/python -m lifi_mcp_python.main_fastmcp"],
"type": "stdio"
}
}
}
lifi_mcp_metadata.json
Comprehensive metadata describing:
- All 17 tools with detailed parameters
- Supported blockchain networks (50+)
- Security model and best practices
- Installation and usage information
- API provider details
See for detailed documentation about these configuration files.
๐ Additional Resources
- Li.FI Documentation - Official Li.FI API docs
- MCP Documentation - Model Context Protocol specs
- FastMCP Documentation - FastMCP framework docs
๐ License
MIT License - See file for details.
๐ Getting Help
- Quick Reference: See for a one-page guide
- Configuration Files: See for integration details
- Issues or Questions: Refer to the troubleshooting section above
- Bugs or Feature Requests: Open an issue on GitHub
๐ Ready to start? Run ./run-inspector-fast.sh
now!