npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@swapapi/mcp

v0.1.0

Published

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

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

npm install -g @swapapi/mcp

Or use directly with npx:

npx @swapapi/mcp

Client Configuration

Claude Desktop

Add to your Claude Desktop config:

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

Or with a local install:

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

Cursor

Add to your Cursor settings (Settings → MCP):

{
  "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:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | chainId | number | Yes | Chain ID (1=Ethereum, 8453=Base, 42161=Arbitrum, etc.) | | tokenIn | string | Yes | Input token address. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token (ETH, MATIC, etc.) | | tokenOut | string | Yes | Output token address | | amountIn | string | Yes | Amount in smallest unit (wei for 18-decimal tokens, micro-units for 6-decimal tokens) | | sender | string | Yes | Wallet address that will sign and send the transaction | | maxSlippage | number | No | Max slippage tolerance 0-1 (default: 0.005 = 0.5%) |

Returns:

{
  "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

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

Swap USDC to ETH on Arbitrum with 1% slippage

{
  "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

cd mcp
npm install
npm start

Testing

Run the test suite:

npm test

Or use the MCP Inspector:

npx @modelcontextprotocol/inspector tsx mcp-server.ts

License

MIT