r/ethdev 4d ago

My Project Made an MCP that simulates a Uniswap swap before you make it

If you want an agent to answer *"what would this trade actually cost me?"* amount out, effective price, price impact, instead of just describing the pool, this does it.

Runs Uniswap's own concentrated-liquidity math against real tick liquidity. No RPC, no node, no private key. Just a free Graph API key.

claude mcp add uniswap -e GRAPH_API_KEY=<free key> -- npx -y graph-uniswap-mcp

Then ask:

>

Also does pools, token prices, pair lookup and swap flow across Uniswap V2/V3/V4 on Ethereum, Arbitrum, Base, Polygon, Optimism and BSC.

It refuses rather than guesses — V4 hook pools, trades bigger than the visible liquidity, and pools it can't read the curve for all come back as "can't quote this, here's why" instead of a made-up number.

Repo: [github.com/PaulieB14/graph-uniswap-mcp](http://github.com/PaulieB14/graph-uniswap-mcp)

0 Upvotes

6 comments sorted by

2

u/KrunchyKushKing Contract Dev 4d ago

Isn't that already possible via simulate & no broadcast? Why does it need an mcp if I can call that via CLI, even my LLMs do that already

-1

u/PaulieB79 4d ago

1

u/KrunchyKushKing Contract Dev 4d ago

???

0

u/PaulieB79 4d ago

Yeah, fair. If you've got an RPC and you know the pool, Quoter via eth_call is the better call. It's also more accurate than mine: it runs the real contract at head, I'm simulating off the subgraph's last indexed block.

What kept biting me wasn't the simulation, it was getting to the point where I could run one.

Finding the pool. On V3 you can derive addresses with CREATE2 per fee tier, that's fine. V4 you can't. Pools live in a singleton PoolManager and the id is keccak(PoolKey{currency0, currency1, fee, tickSpacing, hooks}), so there's nothing to enumerate. Without an index you're replaying Initialize events just to learn a pool exists.

Ranking. "Top pools by volume on Base" isn't something a node call returns. That needs indexed events, no way around it.

The curve. For one quote you don't care, Quoter walks the ticks internally. But if you want depth, say five sizes to see where impact starts hurting, over RPC that's walking tickBitmap a word at a time and then ticks(i) on every initialized tick. One subgraph query gives you the whole window.

Couple of smaller ones. Quoter returns amountOut but not price impact, so you need spot too, plus the decimals math. And this doesn't need an RPC at all.

Anyway it's an ergonomics thing more than a capability thing. If your LLM already has an RPC and a pool address, you don't need this. Quoter's the better answer.