> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leokit.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Integration

> Use LeoKit with Claude Desktop and AI assistants via Model Context Protocol

The LeoKit MCP Server enables AI assistants like Claude to interact with DeFi protocols for quoting and executing cross-chain swaps across 30+ blockchains.

## What is MCP?

[Model Context Protocol (MCP)](https://modelcontextprotocol.io) is an open standard that allows AI assistants to securely connect to external tools and data sources. The LeoKit MCP server exposes swap functionality as tools that Claude can use directly.

## Features

* **Multi-protocol quotes** - Get swap quotes from THORChain, MAYAChain, Chainflip, Relay, and NEAR
* **Cross-chain swaps** - Generate unsigned transactions for 30+ blockchains
* **Transaction tracking** - Monitor swap status across protocols
* **Asset discovery** - List all supported tokens with current prices
* **Balance queries** - Check wallet balances across multiple chains

## Installation

```bash theme={null}
cd apps/leokit-mcp
npm install
npm run build
```

## Configuration

### Environment Variables

```bash theme={null}
# Required: LeoKit API key
export LEOKIT_API_KEY="your-api-key"

# Optional: Custom API URL (defaults to https://api.leokit.dev)
export LEOKIT_API_URL="https://api.leokit.dev"
```

Get your API key from [LeoKit Dashboard](https://dash.leokit.dev).

### Claude Desktop Setup

Add to your Claude Desktop configuration file:

<Tabs>
  <Tab title="macOS / Linux">
    Edit `~/.config/claude/claude_desktop_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "leokit": {
          "command": "node",
          "args": ["/path/to/apps/leokit-mcp/dist/index.js"],
          "env": {
            "LEOKIT_API_KEY": "your-api-key"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="Windows">
    Edit `%APPDATA%\Claude\claude_desktop_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "leokit": {
          "command": "node",
          "args": ["C:\\path\\to\\apps\\leokit-mcp\\dist\\index.js"],
          "env": {
            "LEOKIT_API_KEY": "your-api-key"
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>

After saving the config, restart Claude Desktop for the changes to take effect.

## Available Tools

### `leokit_get_quote`

Get swap quotes from multiple DEX protocols.

**Parameters:**

| Parameter     | Required | Description                                  |
| ------------- | -------- | -------------------------------------------- |
| `from_asset`  | Yes      | Source asset (e.g., `ETH.ETH`, `BTC.BTC`)    |
| `to_asset`    | Yes      | Destination asset                            |
| `amount`      | Yes      | Amount to swap (human-readable, e.g., `1.5`) |
| `origin`      | Yes      | Sender wallet address                        |
| `destination` | Yes      | Recipient wallet address                     |
| `api_key`     | No       | Override default API key                     |

**Example prompt:**

```
Get a quote for swapping 1 ETH to BTC
- from_asset: ETH.ETH
- to_asset: BTC.BTC
- amount: 1
- origin: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
- destination: bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh
```

***

### `leokit_create_deposit`

Generate unsigned transactions for executing a swap.

**Parameters:**

| Parameter  | Required | Description                                                              |
| ---------- | -------- | ------------------------------------------------------------------------ |
| `quote_id` | Yes      | Quote ID from `leokit_get_quote`                                         |
| `protocol` | Yes      | Protocol to use (`thorchain`, `mayachain`, `chainflip`, `relay`, `near`) |
| `api_key`  | No       | Override default API key                                                 |

<Note>
  The returned transaction is unsigned and must be signed by the user's wallet before broadcasting.
</Note>

***

### `leokit_check_status`

Check the status of a swap transaction.

**Parameters:**

| Parameter  | Required | Description                      |
| ---------- | -------- | -------------------------------- |
| `quote_id` | Yes      | Original quote ID                |
| `tx_id`    | Yes      | Transaction hash on source chain |
| `protocol` | No       | Protocol hint for faster lookup  |
| `api_key`  | No       | Override default API key         |

***

### `leokit_get_assets`

List supported tokens across blockchains.

**Parameters:**

| Parameter | Required | Description                                                             |
| --------- | -------- | ----------------------------------------------------------------------- |
| `chain`   | No       | Filter by chain (`ETH`, `BTC`, `ARB`, `BSC`, `POLYGON`, `AVAX`, `NEAR`) |
| `api_key` | No       | Override default API key                                                |

***

### `leokit_get_balances`

Get wallet balances across multiple chains.

**Parameters:**

| Parameter | Required | Description                           |
| --------- | -------- | ------------------------------------- |
| `wallets` | Yes      | Array of `{ address, chain }` objects |
| `api_key` | No       | Override default API key              |

**Example:**

```json theme={null}
{
  "wallets": [
    { "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", "chain": "ETH" },
    { "address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh", "chain": "BTC" }
  ]
}
```

## Example Workflow

Here's how Claude might help you execute a swap:

<Steps>
  <Step title="Get a Quote">
    Ask Claude: "I want to swap 0.5 ETH for USDC on Arbitrum"

    Claude uses `leokit_get_quote` to fetch quotes from multiple protocols and presents the best options.
  </Step>

  <Step title="Review Options">
    Claude shows you quotes from THORChain, Chainflip, and Relay with expected output amounts and fees.
  </Step>

  <Step title="Generate Transaction">
    You select THORChain. Claude uses `leokit_create_deposit` to generate the unsigned transaction.
  </Step>

  <Step title="Sign & Broadcast">
    You sign the transaction with your wallet and broadcast it to the network.
  </Step>

  <Step title="Track Status">
    Ask Claude: "What's the status of my swap?"

    Claude uses `leokit_check_status` to monitor progress until completion.
  </Step>
</Steps>

## Asset Format

LeoKit uses a standardized asset format: `CHAIN.SYMBOL-ADDRESS`

**Native assets:**

* `BTC.BTC` - Bitcoin
* `ETH.ETH` - Ethereum
* `NEAR.NEAR` - NEAR Protocol

**Tokens:**

* `ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48` - USDC on Ethereum
* `ARB.USDC-0xaf88d065e77c8cC2239327C5EDb3A432268e5831` - USDC on Arbitrum

See the [Asset Format Reference](/reference/asset-format) for full details.

## Development

```bash theme={null}
# Watch mode
npm run dev

# Test with MCP inspector
npm run inspect

# Build for production
npm run build
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Claude doesn't see LeoKit tools">
    **Cause:** Config file not loaded or path incorrect

    **Solution:**

    1. Verify the path to `dist/index.js` is absolute and correct
    2. Ensure you ran `npm run build` in `apps/leokit-mcp`
    3. Restart Claude Desktop after editing config
  </Accordion>

  <Accordion title="API key errors">
    **Cause:** Missing or invalid API key

    **Solution:** Verify `LEOKIT_API_KEY` is set correctly in the config's `env` section
  </Accordion>

  <Accordion title="No quotes returned">
    **Cause:** Unsupported swap route or insufficient liquidity

    **Solution:** Check that both assets are supported using `leokit_get_assets`
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols="2">
  <Card title="Complete Swap Flow" icon="arrow-right-arrow-left" href="/guides/complete-swap-flow">
    Detailed guide on executing swaps end-to-end
  </Card>

  <Card title="Supported Chains" icon="link" href="/reference/supported-chains">
    Full list of 30+ supported blockchains
  </Card>
</CardGroup>
