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 分