ekailabs/1inch_mcp_server
If you are the rightful owner of 1inch_mcp_server 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 enabling cross-chain token swaps using the 1inch Fusion+ protocol.
Cross-Chain Swap MCP Server
A Model Context Protocol (MCP) server that enables cross-chain token swaps using the 1inch Fusion+ protocol. This server provides tools for executing swaps between different blockchain networks and monitoring their status.
Features
- Cross-Chain Token Swaps: Execute swaps between Base and Arbitrum networks using 1inch Fusion+
- Portfolio Management: Query portfolio values, token details, and protocol information
- Order Monitoring: Automatic background monitoring of swap orders with daemon service
- Status Tracking: Real-time status updates for all swap orders
- MCP Integration: Full Model Context Protocol support for AI assistant integration
Prerequisites
- Node.js (v16 or higher)
- yarn
- 1inch API key (Dev Portal)
- Private key for wallet operations
Installation
- Clone the repository:
git clone https://github.com/ekailabs/1inch_mcp_server.git
cd 1inch_mcp_server
- Install dependencies:
yarn install
Usage
Starting the MCP Server
{
"mcpServers": {
"one-inch-mcp-server": {
"command": "node",
"args": [
"Path/mcpServer.js"
]
}
}
}
This will:
- Start the monitoring daemon in the background
- Launch the MCP server for tool interactions
Available Scripts
npm start
- Start the MCP server with monitoring daemonnpm run status
- Check status of all swap ordersnpm run monitor
- View monitoring service statusnpm run monitor:start
- Start the monitoring daemonnpm run monitor:stop
- Stop the monitoring daemon
MCP Tools
The server provides several tools accessible through MCP:
swap
Execute a cross-chain token swap.
Parameters:
srcChainId
(optional): Source chain ID (default: 8453 for Base)dstChainId
(optional): Destination chain ID (default: 42161 for Arbitrum)srcTokenAddress
(optional): Source token contract addressdstTokenAddress
(optional): Destination token contract addressamount
(optional): Amount to swap in base units (default: 1000000 = 1 USDC)invert
(optional): Reverse the swap direction
swap-status
Check the status of swap orders.
Parameters:
orderHash
(optional): Specific order hash to check (omit for all orders)
Portfolio Tools
portfolio-protocols-value
- Get current protocol valuesportfolio-tokens-details
- Get detailed token informationportfolio-general-value
- Get general portfolio valueportfolio-value-chart
- Get portfolio value chart data
Resources
swap-status
Access swap order status via URI: swaps://{orderHash}
Architecture
Core Components
index.js
- Main swap execution logic using 1inch Cross-Chain SDKmcpServer.js
- MCP server implementation with tools and resourcesmonitor-service.js
- Daemon service for background order monitoringmonitor-worker.js
- Worker processes for individual order monitoringstatus.js
- Utility for checking order status
Monitoring System
The project includes a sophisticated monitoring system:
- Daemon Process: Runs in the background, automatically detecting new orders
- Worker Processes: Individual processes monitor each swap order
- Status Persistence: Order status saved to
order-status.json
- Automatic Cleanup: Processes terminate when orders complete
Supported Networks
- Base (Chain ID: 8453)
- Arbitrum (Chain ID: 42161)
Default tokens:
- USDC on Base:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
- USDC on Arbitrum:
0xaf88d065e77c8cC2239327C5EDb3A432268e5831
Network Configuration
The project supports custom network configurations in index.js
:
const networkConfigs = {
8453: "https://rpc.ankr.com/base",
42161: "https://arb1.arbitrum.io/rpc"
};
Order Status Tracking
Orders are tracked through several states:
pending
- Order submitted, waiting for executionexecuted
- Order successfully completed- Custom states based on 1inch protocol responses
Status information includes:
- Order hash
- Secrets and secret hashes for order execution
- Start time and last update timestamps
- Monitoring process status