1inch Cross-Chain Swap MCP server

Execute cross-chain token swaps using 1inch Fusion+
Back to servers
Setup instructions
Provider
Vaibhav Maheshwari
Release date
Apr 06, 2025
Language
TypeScript
Stats
1 star

This tool allows you to perform cross-chain token swaps between different blockchains using 1inch Fusion+ and Model Context Protocol (MCP). It provides a seamless way to exchange tokens across networks like Arbitrum, Base, and Polygon, with a built-in monitoring system to track your swap orders.

Installation

Dependencies must be installed using pnpm or yarn (not npm):

pnpm install
# or
yarn install

Configuration

This project must be set up as a CommonJS project as it won't work properly if imported as ESM.

Create a .env file in the root directory with the following variables:

DEV_PORTAL_KEY=replace_with_developer_portal_api_key
WALLET_ADDRESS=replace_with_wallet_address
WALLET_KEY=replace_with_wallet_private_key
RPC_URL_ETHEREUM=replace_with_ethereum_rpc_url
RPC_URL_BASE=replace_with_base_rpc_url
INCH_API_KEY=replace_with_1inch_api_key

Starting the MCP Server

Launch the Model Context Protocol server with:

npm start

This starts the server that provides tools for cross-chain swapping and portfolio management.

Using MCP Functions

The following functions can be used with Claude or other MCP-compatible assistants:

Cross-Chain Swap

swap

Initiates a cross-chain token swap:

Parameters:
- srcChainId: Source chain ID (default: 8453/Base)
- dstChainId: Destination chain ID (default: 42161/Arbitrum)
- srcTokenAddress: Source token address
- dstTokenAddress: Destination token address
- amount: Amount to swap (in base units or human-readable format)
- invert: Swap direction toggle (default: false)

Order Management

swap-status

Checks the status of swap orders:

Parameters:
- orderHash: (Optional) Specific order hash to check

Portfolio Management

portfolio-protocols-value

Gets the value of protocols in your portfolio:

Parameters:
- chainId: Blockchain ID (default: 1/Ethereum)

portfolio-tokens-details

Gets detailed information about tokens in your portfolio:

Parameters:
- chainId: Blockchain ID (default: 1/Ethereum)
- closed: Include closed positions (default: true)
- closedThreshold: Threshold for considering positions closed (default: 1)

portfolio-general-value

Gets the general value of your portfolio:

Parameters:
- chainId: Blockchain ID (default: 1/Ethereum)

portfolio-value-chart

Gets chart data for portfolio value over time:

Parameters:
- chainId: Blockchain ID (default: 1/Ethereum)

Monitoring Your Swaps

The application includes a background worker system to monitor and process swap orders:

# Start the monitor daemon
npm run monitor:start

# Check status of all orders
npm run status

# Check status of monitor daemon
npm run monitor:status

# Stop the monitor daemon
npm run monitor:stop

How Monitoring Works

  1. When you initiate a swap, order information is saved to order-status.json
  2. The monitor daemon continuously checks for new orders
  3. For each new order, a dedicated worker process is spawned
  4. The worker tracks order status and submits secrets when needed to complete the swap
  5. Once an order executes, the worker terminates and the status is updated

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "one-inch-cross-chain-swap" '{"command":"npm","args":["start"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "one-inch-cross-chain-swap": {
            "command": "npm",
            "args": [
                "start"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "one-inch-cross-chain-swap": {
            "command": "npm",
            "args": [
                "start"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later