Labsco
dlwjdtn535 logo

MCP Bybit API Interface

โ˜… 9

from dlwjdtn535

An interface for interacting with the Bybit cryptocurrency exchange API.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredNeeds API keys

MCP Bybit API Interface

smithery badge

Bybit MCP (Model Context Protocol) Server. Provides a convenient interface to interact with the Bybit V5 API using MCP tools. Allows fetching market data, managing account information, and placing/canceling orders via API calls wrapped as tools.

Bybit Server MCP server

โš ๏ธ Security & Safety

This server can place real trades with real money. Read this before configuring it:

  • Trading is disabled by default. Mutating tools (place_order, cancel_order, amend_order, cancel_all_orders, set_trading_stop, set_margin_mode, set_leverage) return an error unless you explicitly set TRADING_ENABLED=true.
  • Use the testnet first. Set TESTNET=true while you experiment. Combine with TRADING_ENABLED=false for a fully read-only setup, or set READONLY_MODE=true to hard-block every mutating tool regardless of other settings.
  • Order size is capped. MAX_ORDER_SIZE_USDT (default 100) limits the estimated notional value of an order to guard against accidental large trades.
  • API keys are never logged or exposed. No tool returns your keys; logs only report whether a key is present.
  • Never commit your API keys. Provide them through environment variables only.

Environment Variables

VariableRequiredDefaultDescription
ACCESS_KEYYesโ€“Bybit API key.
SECRET_KEYYesโ€“Bybit API secret.
MEMBER_IDNoโ€“Bybit member ID (optional).
TESTNETNofalseUse the Bybit testnet when true.
TRADING_ENABLEDNofalseMust be true to allow any mutating/trading tool.
READONLY_MODENofalseWhen true, blocks every mutating tool (takes precedence over TRADING_ENABLED).
MAX_ORDER_SIZE_USDTNo100Caps the estimated notional value (USDT) of a single order.
RESPONSE_VERBOSITYNonormalminimal trims get_tickers/get_positions responses to core fields to save tokens; normal/full return the full payload.

Tools ๐Ÿ› ๏ธ

Market data

  • get_orderbook โ€” order book (category, symbol, limit?).
  • get_kline โ€” candlesticks (category, symbol, interval, start?, end?, limit?).
  • get_tickers โ€” ticker info (category, symbol).
  • get_public_trade_history โ€” recent public trades (category, symbol, limit?).
  • get_instruments_info โ€” instrument metadata / limits (category, symbol, status?, baseCoin?).
  • get_funding_rate_history โ€” funding rate history for perps (category, symbol, startTime?, endTime?, limit?).
  • get_open_interest โ€” open interest over time (category, symbol, intervalTime?, ...).
  • get_fee_rate โ€” maker/taker fee rates (category, symbol?, baseCoin?).
  • get_server_time โ€” Bybit server time.
  • market_snapshot โ€” composite market view (orderbook + ticker + kline + instrument + recent trades, plus funding rate & open interest for futures) in a single call.

Account

  • get_wallet_balance โ€” balances (accountType, coin?).
  • get_positions โ€” open positions (category, symbol?).
  • get_order_history โ€” historical orders.
  • get_open_orders โ€” current open orders.
  • get_api_key_information โ€” API key details.

Trading (mutating โ€” requires TRADING_ENABLED=true)

  • validate_order โ€” pre-flight validation; never places an order. Not blocked by trading flags.
  • place_order โ€” place an order; supports dry_run=true to validate without placing.
  • amend_order โ€” modify an existing order in place.
  • cancel_order โ€” cancel a single order.
  • cancel_all_orders โ€” cancel all open orders (optionally scoped).
  • set_trading_stop โ€” set take profit / stop loss / trailing stop.
  • set_margin_mode โ€” set isolated/cross margin.
  • set_leverage โ€” set leverage for a futures symbol.

(Refer to the function docstrings in the code for detailed parameter descriptions and examples.)

Development

uv sync --group dev   # install dev dependencies (pytest, ruff)
uv run ruff check .   # lint
uv run pytest -q      # run the unit test suite (no live API calls)

CI (GitHub Actions) runs lint + tests on every push/PR; Docker images are built and published automatically on pushes to main.

Contact & Support

For additional inquiries or support, please contact:

We welcome your questions and feedback!