swap-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
swap-mcp
OAuth-protected Uniswap swap service on Cloudflare Workers, exposing an MCP server and a mirrored REST API.
Status: Code-complete and fully tested (203 tests), not yet deployed.
Trust model: Single-operator custodial. The Worker holds one funded private key and signs swaps on your behalf. Anyone who mints a token can spend from that key, bounded only by the swap safety rails. Run it for yourself, not as a shared service.
Before you deploy: split the Durable Object migration tags into
v1/v2/v3and setCANONICAL_MCP_URIto your real Worker origin. Both steps are covered in the deploy how-to.
What it is
An AI agent (over the Model Context Protocol) or any HTTP client (over REST)
requests price quotes and executes ETH↔USDC swaps through the Uniswap Trading
API. A single OAuth 2.1 access token authorizes both surfaces; the /mcp and
/api handlers are mirrors of the same four operations.
Every swap is persisted in D1 and serialized through a Durable Object coordinator that enforces one in-flight swap at a time and applies drift, slippage, and balance safety rails before signing. Failed or interrupted swaps leave a durable row you can reconcile against the chain.
Related MCP server: Uniswap Trader MCP
Architecture at a glance
Surface | Path | Auth |
MCP server |
| Bearer token, |
REST mirror |
| Same token, same scopes |
OAuth 2.1 + consent |
| Passphrase-gated consent |
The entry point (src/index.ts) is a @cloudflare/workers-oauth-provider
instance wrapping the MCP and REST handlers. It binds:
Binding | Type | Purpose |
| KV | OAuth grant + consent state |
| D1 | The |
| Durable Object | Serializes swap execution |
| Durable Object | Per-session MCP agent |
| Durable Object | Passphrase-attempt budgets |
Surfaces
Each MCP tool has a REST mirror and a required scope:
MCP tool | REST mirror | Scope |
|
|
|
|
|
|
|
|
|
|
|
|
For request/response schemas, the swaps data model, and the 11-code error
allowlist, see the API and data-model reference.
Quick start
pnpm install # install dependencies
pnpm dev # run the Worker locally with hot reload
pnpm test # run the full suite (203 tests, zero network)The suite mocks all chain and Trading API I/O, so it needs no secrets. For the full local walkthrough (mint an operator token through the OAuth dance and run a mocked quote), follow the getting-started tutorial.
Documentation
The docs/ tree follows the Diátaxis framework:
Tutorial
Getting started: stand up locally, mint a token, run a mocked quote.
How-to guides
Configure secrets and deploy: set the four secrets, replace binding ids, apply migration tags, deploy.
Run the one-time USDC approval: clear an
approval_requiredfailure on USDC→ETH swaps.Reconcile a stranded submitted swap: resolve a swap stuck in
submitted.
Reference
API and data model: MCP tools, REST endpoints,
swapsschema, error allowlist.
Explanation
Architecture decisions: why OAuthProvider + McpAgent, the coordinator, the safety rails, and the custodial trade-offs.
Commands
Command | What it does |
| Local dev server ( |
| Deploy to Cloudflare ( |
| Run the vitest suite |
| Type-check with |
| Check formatting ( |
| Apply formatting ( |
| Regenerate the |
| Generate a drizzle migration from the schema |
| Manual real-chain smoke script: hits a deployed env; never run by the suite |
Tech stack
Cloudflare Workers (Hono, Durable Objects, D1, KV), @cloudflare/workers-oauth-provider,
@modelcontextprotocol/sdk, the agents SDK, drizzle-orm, viem, and zod. Tested
with vitest and @cloudflare/vitest-pool-workers.
License
No license file yet.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Multi-aggregator swap router for AI agents on Base. 10 bps fee. MCP-native, non-custodial.
MCP marketplace: AI agents buy services from other agents per call in USDC, plus a bank cash-out
Warden MCP lets AI agents find tokens, quote swaps and trade onchain on Base, BNB Chain, Robinhood Chain, Arc and Solana, within limits you set. Market tools need no credential: list_chains, search_tokens, trending_tokens, price_history, quote_swap and swap_status. Search by name, ticker or contract address, read USD price candles, and price a swap before committing to it, including cross-chain swaps. Wallet tools act for the wallet whose owner connected the agent, by OAuth sign-in or a wk_ key. agent_permissions shows what the agent may do and its daily limits. prepare_swap builds a trade and hands the owner a review link to sign. With request_session the owner turns on hands-free trading in one tap, and execute_swap then trades within the limits they set. swap_status tracks gasless and cross-chain trades. get_wallet shows holdings on every chain. Gasless trading is available on Base, BNB Chain and Robinhood Chain. Built by Warden Protocol, the team behind Warden Token Terminal.
Token swaps and honeypot/rug checks for AI agents on 8 chains, paid per-call in USDC via x402.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server for AI agents to automate token swaps on Uniswap DEX across multiple blockchains.40MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to automate token swaps on Uniswap DEX across multiple blockchains including Ethereum, Optimism, Polygon, Arbitrum, and more, with real-time price quotes, swap execution, and multi-hop route optimization.MIT

paean-dex-mcpofficial
AlicenseNot gradedqualityDmaintenanceDEX trading MCP server enabling autonomous token swaps on Base (Uniswap v3) and Solana (Jupiter) for AI agents, with privacy-first design and read-only mode.5MIT- FlicenseNot gradedqualityDmaintenanceExposes Uniswap V2 and V3 on-chain data and swap execution as MCP tools, resources, and prompts, enabling AI agents to query prices, inspect pools, get quotes, and execute trades.-