TypeScriptADK-TS

MCP Odos

Find optimal token swap routes and execute trades across DeFi protocols using Odos.

Overview

The Odos MCP server gives your agent access to Odos's smart order routing for DeFi swaps. It can quote multi-path token swaps across dozens of protocols, assemble optimized swap transactions, and submit them on-chain — all across multiple EVM-compatible networks.

Private Key Security

This server signs and submits swap transactions using your wallet private key. Never commit your private key to source control. Always load it from a secure environment variable.

Getting Started

Install the package:

pnpm add @iqai/mcp-odos

Use the server in your agent:

import { McpOdos } from "@iqai/adk";

const toolset = McpOdos({
  env: {
    WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
  },
});

const tools = await toolset.getTools();
import { McpToolset } from "@iqai/adk";

const toolset = new McpToolset({
  name: "ODOS MCP Client",
  description: "Client for Odos smart order routing and swaps",
  transport: {
    mode: "stdio",
    command: "npx",
    args: ["-y", "@iqai/mcp-odos"],
    env: {
      WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
      PATH: process.env.PATH || "",
    },
  },
});

const tools = await toolset.getTools();
{
  "mcpServers": {
    "odos-mcp-server": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-odos"],
      "env": {
        "WALLET_PRIVATE_KEY": "your_wallet_private_key_here"
      }
    }
  }
}

Environment Variables

VariableRequiredDescription
WALLET_PRIVATE_KEYYesPrivate key of the wallet used to sign and submit swap transactions

Available Tools

ODOS_GET_QUOTE
chain:stringfromToken:stringtoToken:stringamount:stringprettyFormat:boolean

Description

Get a quote for a swap or exchange operation

ODOS_SWAP
chain:stringfromToken:stringtoToken:stringamount:stringprettyFormat:boolean

Description

Execute a swap transaction

ODOS_GET_CHAIN_ID
chain:string

Description

Get the chain ID for a given chain name

Integration Example

import { AgentBuilder, McpOdos } from "@iqai/adk";
import * as dotenv from "dotenv";

dotenv.config();

async function main() {
  // Initialize McpOdos toolset
  const toolset = McpOdos({
    env: {
      WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
    },
  });

  // Get available McpOdos tools
  const odosTools = await toolset.getTools();

  // Create agent with McpOdos tools
  const { runner } = await AgentBuilder.create("odos_agent")
    .withModel("gemini-2.5-flash")
    .withDescription(
      "A DeFi agent that finds and executes optimal token swaps via Odos",
    )
    .withTools(...odosTools)
    .build();

  const response = await runner.ask(
    "Find the best route to swap 1 ETH for USDC on Ethereum and show me the expected output",
  );

  console.log(response);
}

main().catch(console.error);

Further Resources