Skip to main content
Glama
simple-vwap-slippage

simple-vwap-slippage

by tordagaz-ops

simple-vwap-slippage

An MCP server that prices a market order against the live Bybit spot order book and tells you what it will really cost.

Ask for "buy 250 000 USDT of BTC" and you get the volume-weighted average price, the slippage in basis points against the best ask, how many book levels it eats, whether the book is deep enough, and the limit price that would fill it. Ask for several sizes at once and you get a slippage curve measured against a single snapshot, so the numbers are actually comparable.

No API key. No account. No order is ever placed — every tool is read-only.

get_order_book           the ladder, the spread and the resting depth
quote_market_order       VWAP and slippage for one market order
get_slippage_curve       the same order at several sizes, one snapshot
check_order_constraints  the pair's published trading rules, applied
search_symbols           find a listed pair and its rules

Other languages: Español · Русский


Why this exists

The spread is not the cost of a trade, it is only the cost of the first fraction of it. A model that says "BTC costs 60 785.7" is wrong the moment you want to buy more than one level's worth, and there is no way to know how wrong without walking the book.

This server walks it. For the snapshot below (BTC/USDT on Bybit spot, 200 levels a side):

Order size

VWAP

Slippage vs the touch

Levels consumed

1 000 USDT

60 785.700000

0.0000 bps

1

100 000 USDT

60 786.548708

0.1396 bps

7

1 000 000 USDT

60 798.018536

2.0266 bps

61

Three orders of magnitude of size, still under two and a half basis points — because BTC/USDT is one of the deepest books in crypto. Try the same table on a small-cap altcoin and the third row will be tens of basis points. That is exactly the number worth knowing before a trade, and exactly the number you cannot read off a ticker.

Related MCP server: ProofGate

Install

The server speaks the Model Context Protocol over stdio, so it runs alongside any MCP client.

pip install mcp-simple-vwap-slippage

Or from a clone:

git clone https://github.com/tordagaz-ops/simple-vwap-slippage
cd simple-vwap-slippage
python -m venv .venv
.venv/Scripts/activate      # Windows
pip install -e ".[dev]"

Requires Python 3.10 or newer. Two dependencies: mcp and httpx.

Connect it to a client

Any client that can start a stdio server works. The console script and the module entry point are equivalent — use whichever you prefer.

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "vwap-slippage": {
      "command": "python",
      "args": ["-m", "mcp_vwap_slippage"],
      "env": { "MCP_LOCALE": "en" }
    }
  }
}

Cursor, VS Code, Windsurf and the rest take the same command / args / env triple in their own config file. If you installed with pip, simple-vwap-slippage also works as the command with no arguments.

Prefer a hosted endpoint? Run it over HTTP instead (see Self-hosting).

The tools

All five are read-only (readOnlyHint: true) and reach the open internet (openWorldHint: true). Sizes are in base coins, prices in the quote currency, unless stated otherwise.

get_order_book

The current book for one pair: best bid and ask, spread, both ladders and the total resting size per side.

Argument

Type

Default

symbol

string

—

Pair in Bybit notation, BTCUSDT, ETHUSDC. Case does not matter.

depth

int

20

Levels per side, 1–1000. Bybit only serves 1, 5, 25, 50, 100, 200, 500 and 1000, so the value is rounded up to the nearest of those.

{
  "symbol": "BTCUSDT",
  "base_coin": "BTC",
  "quote_coin": "USDT",
  "tick_size": "0.1",
  "timestamp": "2026-11-26T09:26:15Z",
  "best_bid": 60785.6,
  "best_ask": 60785.7,
  "mid": 60785.65,
  "spread": 0.1,
  "spread_bps": 0.0165,
  "levels": { "requested": 5, "bids": 5, "asks": 5 },
  "bids": [{ "price": 60785.6, "size": 0.381057, "notional": 23162.7783792 }, "…"],
  "asks": [{ "price": 60785.7, "size": 0.993751, "notional": 60405.8501607 }, "…"],
  "depth": {
    "bids": { "levels": 5, "base": 1.27824, "quote": 77696.7122514 },
    "asks": { "levels": 5, "base": 1.032233, "quote": 62745.0208669 },
    "imbalance": 0.55323094
  }
}

imbalance is the share of resting quote value sitting on the bid. Above 0.5 means buyers are queued and sellers get the easier fill.

quote_market_order

Price one market order and say what it costs.

Argument

Type

Default

symbol

string

—

Pair in Bybit notation.

side

string

—

buy consumes the asks, sell consumes the bids.

amount

number

—

Size, in USDT for a buy by default and in coins for a sell by default.

amount_unit

string

side-dependent

quote (USDT) or base (coins). Overrides the default above.

max_levels

int

200

How deep to walk, 1–1000. Raise it for very large orders.

{
  "symbol": "BTCUSDT",
  "side": "buy",
  "amount": 250000.0,
  "amount_unit": "quote",
  "filled": 250000.0,
  "complete": true,
  "base_qty": 4.1126067434,
  "quote_qty": 250000.0,
  "vwap": 60788.6957338199,
  "reference_price": 60785.7,
  "reference": "best_ask",
  "slippage": 4.928e-05,
  "slippage_percent": 0.004928,
  "slippage_bps": 0.4928,
  "levels_consumed": 20,
  "worst_price": 60791.9,
  "suggested_limit_price": 60791.9,
  "message": null,  "book": { "best_bid": 60785.6, "best_ask": 60785.7, "spread_bps": 0.0165, "levels": { "bids": 200, "asks": 200 } }
}

Two details that matter:

  • slippage is measured against the touch, not the mid. A buy is compared to the best ask, a sell to the best bid, and the sign is always positive when the fill is worse, so the same number means "cost" on both sides. Because of that, an order that fits inside the first level has zero slippage by definition — it still pays the half-spread. The book.mid is included so you can measure against the mid yourself: (vwap - mid) / mid.

  • suggested_limit_price is the worst price the order actually reaches, rounded to the pair's tick — up for a buy, down for a sell, so the number stays executable instead of landing just inside the touch. It is only present for a complete fill: a partial fill needs a deeper book, not a different price.

If the book cannot absorb the whole order, complete is false, filled is what was absorbable, and message explains it in the active language. That is a result, not an error.

get_slippage_curve

The same order at 2 to 12 sizes, all priced against one snapshot.

Argument

Type

Default

symbol

string

—

Pair in Bybit notation.

side

string

—

buy or sell.

amounts

number[]

—

2 to 12 sizes in the same unit.

amount_unit

string

side-dependent

quote or base.

max_levels

int

200

Depth to walk.

One snapshot is the point. Two separate quote_market_order calls fetch two different books a second apart, and the resulting table is not comparable — the small order and the large order can be priced against different markets and the curve stops being monotonic. Here, points[i] and points[j] are guaranteed to share reference_price, book.timestamp and every level in between.

{
  "symbol": "BTCUSDT",
  "side": "buy",
  "amount_unit": "quote",
  "reference_price": 60785.7,
  "spread_bps": 0.0165,
  "complete_points": 3,
  "points": [
    { "amount": 1000.0, "vwap": 60785.7, "slippage_bps": 0.0, "levels_consumed": 1, "complete": true },
    { "amount": 100000.0, "vwap": 60786.5487082021, "slippage_bps": 0.1396, "levels_consumed": 7, "complete": true },
    { "amount": 1000000.0, "vwap": 60798.0185364213, "slippage_bps": 2.0266, "levels_consumed": 61, "complete": true }
  ]
}

check_order_constraints

Before sending an order anywhere, check it against the rules Bybit publishes for that pair.

Argument

Type

Default

symbol

string

—

Pair in Bybit notation.

quantity

number

—

Size in base coins.

price

number

null

Optional limit price, checked against the tick size.

{
  "symbol": "BTCUSDT",
  "status": "Trading",
  "trading": true,
  "quantity": 1e-07,
  "price": 60785.7,
  "notional": 0.00607857,
  "valid": false,
  "issues": [
    {
      "code": "min_quantity",
      "value": 1e-07,
      "minimum": 1e-06,
      "message": "Quantity 0.0000001 is below the minimum order size of 0.000001."
    },
    {
      "code": "quantity_precision",
      "value": 1e-07,
      "decimals": 6,
      "message": "Quantity 0.0000001 has more decimals than the 6 the pair accepts."
    }
  ],
  "rules": {
    "min_order_qty": 1e-06,
    "max_order_qty": 230.0,
    "min_order_amt": 5.0,
    "max_order_amt": 8000000.0,
    "tick_size": "0.1",
    "quantity_step": "0.000001",
    "price_decimals": 1,
    "quantity_decimals": 6
  }
}

Every issue carries both a machine code and the numbers behind it, so a model can fix the order instead of guessing. rules is always present, valid or not, so the same call also answers "what is the minimum?".

The rules are kept as strings on purpose: tick_size is "0.1" and quantity_step is "0.000001", and a float round-trip would turn that into 1e-06 and destroy the one thing that tells you how many decimals you may send.

This validates the exchange's rules; it does not judge whether the price is sane. A limit price of 95 000 on a 60 785 market passes every rule for BTC/USDT.

search_symbols

Not sure that a pair exists, or which quote currency it uses? Search by symbol, base coin or quote coin.

Argument

Type

Default

query

string

""

Text to match, e.g. PEPE. Empty lists the most liquid pairs.

quote_coin

string

null

Filter by quote currency, e.g. USDC.

limit

int

20

Results to return, 1–100.

{
  "query": "ETH",
  "scanned": 499,
  "matches": 16,
  "returned": 3,
  "ranked_by": "24h turnover",
  "symbols": [
    {
      "symbol": "ETHUSDT", "base_coin": "ETH", "quote_coin": "USDT",
      "tick_size": "0.01", "min_order_qty": 1e-05, "min_order_amt": 5.0,
      "last_price": 1699.17, "change_24h": 0.0337, "change_24h_percent": 3.37,
      "turnover_24h": 274748958.1081299
    }
  ]
}

Ranking is exact symbol first, then base coin, then prefix, then substring; ties are broken by 24-hour turnover, which comes from one extra request that covers the whole market. If that request fails, search still works and says "ranked_by": "symbol name".

The same coin usually has several pairs — ETHUSDT, ETHUSDC, ETHEUR, ETHBTC — and they do not have the same depth. Picking the one with the most turnover is usually the cheapest trade, which is why the field is there.

How the arithmetic works

A VWAP quote is a walk down the ladder, not a formula:

  1. Take the levels on the side you are consuming — asks for a buy, bids for a sell.

  2. For each level, take the smaller of what is left to fill and what the level can absorb.

  3. Stop when the order is filled or the book runs out.

  4. vwap = quote spent / base received.

Rounding is deliberately absent from the model: no reference price, no tick snapping, no fee model. The only number derived afterwards is suggested_limit_price, and it exists because a limit order needs one.

Fees are not included. Bybit's taker fee is additional and depends on your tier; add it yourself if you are comparing against a maker strategy.

Configuration

Variable

Default

MCP_LOCALE

en

Tool titles, descriptions, parameter docs and error messages: en, es, ru. Falls back to LANGUAGE, then LANG, then English.

MCP_TRANSPORT

stdio

stdio, or http for a streamable HTTP endpoint.

MCP_HOST

0.0.0.0

Bind address for HTTP transport.

MCP_PORT

8000

Port for HTTP transport.

Market data is cached briefly so a burst of identical calls costs one upstream request: order books for 1.5 seconds, the instrument list for an hour, the 24-hour turnover table for a minute. Quotes are therefore at most 1.5 seconds stale, which is stated in book.timestamp on every payload.

Self-hosting

# stdio, the default
python -m mcp_vwap_slippage

# streamable HTTP on :8000
MCP_TRANSPORT=http MCP_PORT=8000 python -m mcp_vwap_slippage

Docker, if you prefer a sealed image:

docker build -t simple-vwap-slippage .
docker run -i --rm simple-vwap-slippage                          # stdio
docker run -p 8000:8000 -e MCP_TRANSPORT=http simple-vwap-slippage

smithery.yaml is included, so the repo can also be deployed as a hosted Smithery server from the Python runtime with no image at all.

Development

pip install -e ".[dev]"
pytest                      # everything the network allows
pytest -m "not live"        # offline only: 197 tests, no internet needed
pytest -m live              # 31 tests against the real Bybit API
pytest -m e2e               # spawns the server and speaks JSON-RPC to it

Four layers, each catching what the one below cannot:

  • Unit — the parsers and the VWAP walk, against payloads that reproduce Bybit's wire format exactly (prices and sizes as strings, errors as HTTP 200 with a non-zero retCode).

  • Tool level — the same tests again through a real in-memory MCP session, so the generated schemas, the annotations and the structured-content wrapping are covered.

  • Live — the real API, skipped rather than failed when there is no connection.

  • End-to-end — python -m mcp_vwap_slippage in a subprocess, raw JSON-RPC over stdio. No imports, so a packaging mistake or a stray print on stdout fails here.

Limitations

  • A snapshot, not a promise. The book moves between the quote and the fill. Slippage is measured on resting liquidity and ignores queued-but-undisplayed orders, icebergs and latency.

  • Spot only. Bybit perpetuals price differently and carry funding; category=linear is not used here.

  • One venue. No cross-exchange comparison, no routing.

  • No fees, no borrow costs, no tax lot tracking.

Data source

Public market data from the Bybit V5 API. This project is not affiliated with or endorsed by Bybit.

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      Enables cryptocurrency trading on Bybit exchange through comprehensive market data access, account management, and automated trading operations. Features smart position validation, trailing stop losses, and risk management tools with demo mode support for safe testing.
      21
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only analysis of Binance Spot markets through a single MCP tool that fetches live public market data and generates a Trade Readiness Passport with WATCH, RESEARCH_MORE, or NO_TRADE outcomes.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables validation of USDⓈ-M Futures trade intents by normalizing natural-language orders, fetching live Binance market and account state, applying deterministic risk rules, and producing tamper-evident preflight receipts before execution.
      MIT