Skip to content

KyberNetwork/kyberswap-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KyberSwap MCP Server

An MCP (Model Context Protocol) server that exposes KyberSwap trading, liquidity, and limit-order flows as 13 tools for LLM agents and developer workflows.

The server is read-only and calldata-building: it never holds private keys or signs transactions. It returns reviewable calldata or EIP-712 typed data, and you sign and broadcast with your own wallet (Foundry, viem, ethers, MetaMask, hardware wallet, etc.).

The server includes:

  • Read-only market and portfolio tools
  • Swap and zap calldata builders
  • On-chain simulation and transaction status verifiers
  • Gasless limit-order build/submit and cancel/submit flows

Tool Overview

Read-only tools

Tool Description
get-quote Quote a swap with route details, gas, price impact, and trade economics
token-info Resolve token metadata, USD price, verification status, and honeypot/FOT checks
get-pool-info Inspect pools by address or token pair, with TVL, APR, volume, and fee data
order-manager Query open, filled, cancelled, or expired limit orders for a wallet
position-manager Query concentrated-liquidity positions, value, fees, and APR for a wallet

Build tools (calldata only — no broadcast)

Tool Description
swap-build Build calldata (to, data, value) for a swap. Requires sender.
zap Build calldata for zap in or zap out. Requires sender.

Verify tools (no wallet, no gas)

Tool Description
swap-simulate Dry-run swap calldata via eth_call. Returns success or decoded revert reason.
swap-status Check receipt status of a submitted tx. Decodes revert reason on failure.

Limit-order tools (build → sign externally → submit)

Tool Description
limit-order-build Build a gasless limit order. Returns EIP-712 typed data to sign.
limit-order-submit Submit a signed limit order. Returns the order ID.
limit-order-cancel-build Build a gasless cancel for one or more orders. Returns EIP-712 typed data.
limit-order-cancel-submit Submit a signed cancel. Gasless window is ~90 seconds from order creation.

Supported Chains

The chain registry currently includes 18 EVM chains:

  • ethereum
  • bsc
  • arbitrum
  • polygon
  • optimism
  • base
  • avalanche
  • linea
  • mantle
  • sonic
  • berachain
  • ronin
  • unichain
  • hyperevm
  • plasma
  • etherlink
  • monad
  • megaeth

Installation

Requirements

  • Node.js 18+
  • npm

Install and build

npm install
npm run build

Run locally

npm run dev

Or run the built server:

npm start

Configuration

The server does not require any wallet secrets. There are no PRIVATE_KEY, KEYSTORE_PATH, or similar environment variables — the server never signs transactions.

Optional: override the default public RPC for any chain by setting RPC_URL_<CHAIN_SLUG_UPPER>, e.g.

export RPC_URL_ETHEREUM=https://eth.your-rpc.example
export RPC_URL_BASE=https://base.your-rpc.example

These are only used by swap-simulate and swap-status for eth_call and receipt lookups.

Usage

Claude Desktop

{
  "mcpServers": {
    "kyberswap": {
      "command": "node",
      "args": ["/path/to/kyberswap-mcp-server/dist/index.js"]
    }
  }
}

No secrets in the config — the server is read/build only.

Typical Workflow

Swap

  1. get-quote — inspect the route and economics.
  2. swap-build — pass sender (your wallet address) to get to, data, value.
  3. swap-simulate — dry-run the calldata with eth_call. Confirm status: success.
  4. Sign and broadcast the tx with your own wallet (cast send, viem, ethers, etc.).
  5. swap-status — verify inclusion by passing the resulting txHash.

Routes expire in ~30 seconds. If swap-simulate returns reverted with an expired-route reason, call swap-build again for a fresh route.

Limit order

  1. limit-order-build — returns the approval target and EIP-712 typed data to sign.
  2. Ensure the maker has approved the approval target for the maker asset.
  3. Sign the typed data with your wallet (eth_signTypedData_v4).
  4. limit-order-submit — pass the signature and order params to post the order.
  5. Monitor with order-manager.

Cancel a limit order

  1. limit-order-cancel-build — returns EIP-712 typed data for a gasless cancel.
  2. Sign the typed data with your wallet.
  3. limit-order-cancel-submit — post the signed cancel.

The gasless cancellation window is ~90 seconds from order creation. After that, an on-chain hard-cancel transaction is required (not provided by this server — use the KyberSwap UI or call the limit-order contract directly).

Key Tool Notes

get-pool-info

Useful for discovery before zapping.

  • Supports poolAddress
  • Supports pair search with tokenIn/tokenOut or token0/token1
  • Supports dex
  • Supports sorting by tvl, volume, apr, or earnFee

Informational only — always confirm the exact pool with the user before calling zap.

swap-build

  • Requires sender (the address that will sign and broadcast)
  • Resolves token symbols or addresses
  • Applies token safety checks (honeypot, FOT)
  • Uses smart slippage defaults when omitted
  • Returns reviewable to/data/value — does not broadcast

zap

Supports both directions through action:

  • action: "in" for adding liquidity
  • action: "out" for removing liquidity from an existing position into a chosen token

For zap in, common inputs are:

  • sender
  • tokenIn
  • amountIn
  • pool
  • one range mode: tickLower/tickUpper, fullRange, priceLower/priceUpper, or positionId

For zap out, common inputs are:

  • sender
  • positionId
  • pool
  • tokenOut
  • optional liquidityOut
  • optional burnNft

Returns reviewable calldata. Does not execute on-chain.

swap-simulate

Calls eth_call against the swap calldata — no gas, no wallet, no signature. Use after swap-build and before broadcasting. On revert, the tool decodes the reason and lists likely causes.

swap-status

Pass a tx hash after broadcasting. For a successful tx, returns block number and gas used. For a failed tx, replays the call at the same block to decode the revert reason.

Limit orders

  • limit-order-build blocks native ETH as maker asset — use WETH (or the wrapped native equivalent).
  • The approval target is the KyberSwap DSLO protocol contract; make sure the maker has approved it for the maker asset before submitting.
  • Orders are EIP-712 typed data; sign with eth_signTypedData_v4.

Common Examples

Quote a swap

Get me a quote on Ethereum to swap 1 ETH to USDC.

Build a swap

Build a swap on Arbitrum from 0.1 ETH to USDC for sender 0xYourWallet...

Simulate before broadcasting

Simulate the last swap calldata on Arbitrum before I sign it.

Check a tx after broadcasting

Check the status of tx 0xabc... on Base.

Inspect pools before zapping

Show me the top USDT/WBNB pools on BSC sorted by TVL.

Build a zap-in

Build a zap-in on Ethereum using 1000 USDC into pool 0x... with full range for sender 0xYourWallet...

Build a zap-out

Build a zap-out on BSC for position 12345 in pool 0x..., withdraw everything into USDT for sender 0xYourWallet...

Create a limit order

Build a limit order on Ethereum to sell 1000 USDC for 0.5 WETH at price $4000 for maker 0xYourWallet...

Query positions

Show my liquidity positions on Ethereum for wallet 0xYourWallet...

Development Notes

  • The runtime entrypoint is dist/index.js.
  • npm run build compiles TypeScript to dist/.
  • npm run dev runs the server directly from src/index.ts via tsx.
  • The repo is type: "module" and uses Node ESM.
  • API requests time out after 15 seconds.

About

MCP for interacting with the KyberSwap Aggregator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors