Model Context Protocol (MCP) server for gasless DEX swapping powered by OKX DEX API + Biconomy MEE
npm install okx-mcp-server> Revolutionary gasless DEX swapping powered by OKX DEX API + Biconomy MEE - Swap without holding ETH for gas fees!
> š Note: Swapping occurs only for OKX supported networks and tokens.
---
---
ā
Gasless Swaps: No ETH needed for gas fees
ā
Multi-Chain: Ethereum, Base, Optimism, xLayer
ā
Best Prices: OKX DEX aggregates 50+ DEX sources
ā
Natural Language: "Swap 10 USDC to WETH on Base"
ā
Real-time Quotes: Get current market prices
ā
Portfolio Management: Check balances across chains
---
Impact: 95% reduction in user steps, 100% elimination of native gas requirements, zero learning curve with natural language commands.
---
Here are some screenshots and visuals from the project in action:

Claude MCP Success

MCP Liquidity Tool

MEE Success Transaction

Price OKX Fetch
---
1. Check ETH balance for gas ā
2. Approve token spending ā³
3. Wait for confirmation ā³
4. Execute swap transaction ā³
5. Wait for confirmation ā³
6. Pay gas in native ETH ā
`$3
`
1. "Swap 10 USDC to WETH on Base" ā
2. Single signature ā
3. MEE handles everything ā
4. Gas paid from USDC ā
5. Done! š
`---
---
š MEE vs ERC-4337: Why We Chose Superior Technology
$3
| Feature | ERC-4337 | Biconomy MEE | Our Implementation |
|---------|----------|--------------|-------------------|
| Dynamic Execution | ā Static batching only | ā
Runtime conditional logic | ā
Approval ā Swap ā Transfer in one flow |
| Cross-Transaction Data | ā Cannot use previous results | ā
Each step uses prior outputs | ā
Dynamic amount calculations |
| Conditional Logic | ā All steps must execute | ā
Conditional execution paths | ā
Smart slippage handling |$3
| Feature | ERC-4337 | Biconomy MEE | Our Implementation |
|---------|----------|--------------|-------------------|
| Multi-Chain Support | ā Single chain per transaction | ā
Native cross-chain flows | ā
Ethereum, Base, Optimism, xLayer |
| Unified Gas Payment | ā Separate gas per chain | ā
Pay from any chain | ā
Use USDC on Base to swap on Optimism |
| Atomic Operations | ā Multiple signatures needed | ā
Single signature for all chains | ā
One signature, multi-chain execution |$3
| Feature | ERC-4337 | Biconomy MEE | Our Implementation |
|---------|----------|--------------|-------------------|
| Gas Token Flexibility | ā ļø Limited token support | ā
Any token, any chain | ā
Pay gas with your swap token |
| Cross-Chain Gas | ā Chain-specific gas management | ā
Universal gas abstraction | ā
USDC on any chain pays for everything |
| Gas Optimization | ā ļø Basic bundling | ā
Intelligent routing | ā
MEE optimizes across 50+ DEX sources |$3
| Feature | ERC-4337 | Biconomy MEE | Our Implementation |
|---------|----------|--------------|-------------------|
| Scheduled Execution | ā No native scheduling | ā
Built-in automation | š Coming: Limit orders via Gelato |
| Recurring Transactions | ā Manual repetition | ā
Automated patterns | š Coming: DCA strategies |
| Conditional Triggers | ā No trigger support | ā
Event-based execution | š Coming: Price-based swaps |---
š Available MCP Tools
Once deployed, you'll have access to these tools in Claude:
1.
get_supported_networks_okx - List supported networks
2. get_supported_tokens_okx - Get tokens for a network
3. get_account_balance_evm - Check wallet balances
4. get_token_swap_quote_okx - Get swap quotes/prices
5. swap_tokens_okx_mee - Execute gasless token swaps (using Biconomy MEE)
6. transfer_tokens_evm - Transfer tokens
7. get_transaction_evm - Check transaction status---
š How to Deploy This MCP Server
$3
- Node.js 18+ or Bun installed
- Claude Desktop app (for mcp test)
- OKX DEX API credentials
- Private key for wallet operations$3
`bash
git clone https://github.com/Nith567/okx-dex-mcp.git
cd okx-dex-mcp
bun install
`$3
Create a .env file in the project root:
`bash
OKX DEX API Configuration
OKX_API_KEY=your_okx_api_key_here
OKX_SECRET_KEY=your_okx_secret_key_here
OKX_PASSPHRASE=your_okx_passphrase_hereWallet Configuration
PRIVATE_KEY=0x_your_private_key_here
`$3
`bash
bun run build
`$3
`bash
Test a token swap(checkout serveral test scripts out there )
bun run test:swapStart server locally
bun run start
`$3
`bash
which bun
Example output: /opt/homebrew/bin/bun
`$3
Edit your Claude Desktop config file:macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json`json
{
"mcpServers": {
"okx-dex": {
"command": "/opt/homebrew/bin/bun",
"args": [
"run",
"/Users/your-username/path/to/okx-mcp/build/index.js"
],
"env": {
"OKX_API_KEY": "your_okx_api_key_here",
"OKX_SECRET_KEY": "your_okx_secret_key_here",
"OKX_PASSPHRASE": "your_okx_passphrase_here",
"PRIVATE_KEY": "0x_your_private_key_here"
}
}
}
}
`Important:
- Replace
/opt/homebrew/bin/bun with your actual bun path from Step 5
- Replace /Users/your-username/path/to/okx-mcp with your actual project path
- Replace the environment variables with your actual credentials$3
Close and reopen Claude Desktop for the configuration to take effect.$3
Try this in Claude Desktop:
`
Can you check what tokens are supported on Optimism network?
`or
`
Swap 10 USDC to USDT on optimism network
`---
š§ Architecture & Implementation
$3
#### Step-by-Step Execution:
1. Network Validation: Resolve network name to chain ID
2. Token Discovery: Get supported tokens for the network via OKX API
3. Token Validation: Ensure both source and destination tokens are supported
4. Amount Calculation: Convert human-readable amount to token decimals
5. Wallet Setup: Create EOA from private key and get wallet address
6. Approval Transaction:
- Call OKX
/api/v5/dex/aggregator/approve-transaction
- Decode transaction data to get DEX contract address and amount
7. Swap Transaction:
- Call OKX /api/v5/dex/aggregator/swap
- Decode transaction data to get function name and arguments
8. MEE Integration:
- Create multichain nexus account with supported chains
- Build approval composable transaction
- Build swap composable transaction
- Create trigger with source token details
9. Execution:
- Get fusion quote from MEE client
- Execute the fusion quote
- Return transaction hash and MEE scan link
- Wait for transaction receipt$3
- Ethereum: Chain ID 1
- Base: Chain ID 8453
- Optimism: Chain ID 10
- xLayer: Chain ID 196$3
- OKX API Integration: HMAC-SHA256 authentication for secure API calls
- Transaction Decoding: ERC20 and DEX router ABI for transaction parsing
- Biconomy MEE: Multichain nexus account with composable transactions
- Error Handling: Comprehensive validation and error management
- Type Safety: Full TypeScript implementation
---
šø Referral & Fee Revenue Support
This MCP server supports referral-based revenue generation by allowing you to specify a referrer wallet address and a small percentage fee on each swap. This is similar to how Phantom and other wallets have generated significant revenue by taking a small cut of each transaction.
How it works:
- When building the swap request to OKX DEX Aggregator, you can include the following parameters:
`js
const params = {
chainIndex: chainId,
amount,
toTokenAddress,
fromTokenAddress,
slippage: SLIPPAGE,
userWalletAddress,
fromTokenReferrerWalletAddress: "0xYourReferralAddress", // Your address to receive referral fees
feePercent: "0.25" // Example: 0.35% fee for revenue
};
`- The
fromTokenReferrerWalletAddress receives the referral fee, and feePercent sets the percentage (e.g., 0.25 for 0.25%).
- This enables you to earn a small profit on every swap routed through your MCP server.
- Many wallets (like Phantom) have made millions in revenue using this approach.
- We are expanding this by providing MCP as a service, so you can also benefit from referral fees.---
$3
`typescript
// Example: Swap 0.4 USDC to USDT on Optimism
const result = await executeTokenSwap({
network: 'optimism',
amount: '0.4',
fromTokenSymbol: 'USDC',
toTokenSymbol: 'USDT'
});// Returns:
{
success: true,
hash: "0x...",
explorerLink: "https://..",
meeScanLink: "https://...",
receipt: {...}
}
`---
$3
`bash
PRIVATE_KEY=your_private_key_here
OKX_API_KEY=your_okx_api_key
OKX_SECRET_KEY=your_okx_secret_key
OKX_PASSPHRASE=your_okx_passphrase
``