Swap API

io.github.Swap-API由 GitHub 帳號 Swap-API 發布v0.1.0更新於 Oct 24, 2026

MCP server for SwapAPI - get executable token swap calldata for EVM chains

已驗證STDIO僅桌面金融開發者工具

概覽

AI 產生的概覽

本機 MCP 伺服器,透過 SwapAPI 為 EVM 鏈產生可執行的代幣兌換 calldata,僅提供一個 swap_tokens 工具。

可以做什麼
  • 取得指定 EVM 鏈上代幣兌換的可執行交易資料(路由合約位址、calldata、原生幣金額、gas 估算、滑點後最小輸出)
  • 指定鏈 ID、輸入與輸出代幣位址、以最小單位表示的數量、發送方錢包位址,以及選用的滑點容許度(預設 0.5%)
  • 使用原生代幣佔位位址處理 ETH、MATIC 等原生幣的兌換
  • 只回傳 calldata,簽章、授權與送出交易仍須由助理或使用者完成
適用情境
適合需要為以太坊、Base、Arbitrum 等 EVM 鏈準備代幣兌換並回傳可直接簽章交易資料的情境,例如交易或 DeFi 工作流程。若只需報價,或不打算送出鏈上交易,則不需要使用。
執行需求
以 stdio 方式在本機執行,透過 npm 套件 @swapapi/mcp 安裝(需要 Node.js/npx),並在 Claude Desktop、Cursor 等 MCP 用戶端中設定。未宣告任何環境變數、標頭或身分驗證;需能連線至 SwapAPI 服務的網路。
安裝前請注意
回傳的是涉及真實資金的即時交易資料:發送方錢包位址會傳送給 SwapAPI 服務,且 calldata 會過期,須儘快送出。README 的送出前檢查清單要求先確認 ERC-20 授權、餘額、gas 估算並進行模擬。滑點設定會影響保證的最低輸出。此伺服器本身不簽章也不送出交易。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Swap API,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

SwapAPI MCP Server

MCP (Model Context Protocol) server for SwapAPI. Enables AI agents to get executable token swap calldata for any EVM chain.

Installation

bash
npm install -g @swapapi/mcp

Or use directly with npx:

bash
npx @swapapi/mcp

Client Configuration

Claude Desktop

Add to your Claude Desktop config:

json
{  "mcpServers": {    "swapapi": {      "command": "npx",      "args": ["@swapapi/mcp"]    }  }}

Or with a local install:

json
{  "mcpServers": {    "swapapi": {      "command": "npx",      "args": ["tsx", "/path/to/swap-api/mcp/mcp-server.ts"]    }  }}

Cursor

Add to your Cursor settings (Settings → MCP):

json
{  "mcpServers": {    "swapapi": {      "command": "npx",      "args": ["@swapapi/mcp"]    }  }}

Other Clients

Any MCP-compatible client can use the same configuration format. Check your client's documentation for where to add MCP server settings.

Available Tools

swap_tokens

Get executable transaction data to swap tokens on EVM chains.

Parameters:

ParameterTypeRequiredDescription
chainIdnumberYesChain ID (1=Ethereum, 8453=Base, 42161=Arbitrum, etc.)
tokenInstringYesInput token address. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token (ETH, MATIC, etc.)
tokenOutstringYesOutput token address
amountInstringYesAmount in smallest unit (wei for 18-decimal tokens, micro-units for 6-decimal tokens)
senderstringYesWallet address that will sign and send the transaction
maxSlippagenumberNoMax slippage tolerance 0-1 (default: 0.005 = 0.5%)

Returns:

json
{  "to": "0x...",           // Router contract address to call  "data": "0x...",         // ABI-encoded swap calldata  "value": "1000000000000000000",  // Native token value (if swapping from native)  "gas": "150000",         // Estimated gas limit  "guaranteedOut": "..."   // Minimum output amount after slippage}

Examples

Swap 0.001 ETH to USDC on Base

json
{  "chainId": 8453,  "tokenIn": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",  "tokenOut": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",  "amountIn": "1000000000000000",  "sender": "0xYourAddress"}

Swap USDC to ETH on Arbitrum with 1% slippage

json
{  "chainId": 42161,  "tokenIn": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",  "tokenOut": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",  "amountIn": "10000000",  "sender": "0xYourAddress",  "maxSlippage": 0.01}

Pre-flight Checklist

Before submitting any swap transaction:

  1. ERC-20 Approval: If tokenIn is not native token, ensure sender has approved the router for at least amountIn
  2. Balance Check: Verify sender has sufficient balance for amountIn (plus value if native token)
  3. Gas Estimation: Call eth_estimateGas on the transaction and add 20% buffer
  4. Simulation: Run eth_call to verify the transaction won't revert
  5. Timing: Submit within 30 seconds of fetching the quote (calldata has expiry)

See the main README.md for full API documentation.

Development

bash
cd mcpnpm installnpm start

Testing

Run the test suite:

bash
npm test

Or use the MCP Inspector:

bash
npx @modelcontextprotocol/inspector tsx mcp-server.ts

License

MIT

來源:mcp/README.md,提交 bdfd033

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分