Bybit Exchange API

by dlwjdtn535

7 stars
165 downloads
Not rated
GitHub

About

Provides a bridge to the Bybit cryptocurrency exchange API for market data retrieval, account management, and order execution across spot and futures markets

Details

Author
dlwjdtn535
Repository
dlwjdtn535/mcp-bybit-server
GitHub stars
7
Downloads
165
License
MIT License
Categories
Cloud Service, Infrastructure, Design, Developer Tools, AI, API
Tags
#integration

- Fetches real-time market data (orderbook, kline, tickers, etc.)
- Manages account balances, positions, and order history
- Places, amends, and cancels orders with safety caps
- Provides pre-flight order validation before execution
- Supports testnet for safe experimentation
- Hard‑blocks all mutating tools when READONLY_MODE=true
- Caps single order notional value to 100 USDT by default
- Offers a composite market_snapshot tool for quick overview

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Bybit Exchange API
    Command (node, npx, python, etc.) uv
    Arguments
    • Argument 1 run
    • Argument 2 --directory
    • Argument 3 /absolute/path/to/mcp-bybit-server
    • Argument 4 mcp-bybit-server
    Environment
    • TESTNET true
    • ACCESS_KEY YOUR_BYBIT_API_KEY
    • SECRET_KEY YOUR_BYBIT_SECRET_KEY
    • TRADING_ENABLED false

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Requires Python 3.12+. This project uses uv.

git clone https://github.com/dlwjdtn535/mcp-bybit-server.git
cd mcp-bybit-server
uv sync
uv run mcp-bybit-server   # runs the MCP server over stdio

After install, the mcp-bybit-server command is the entry point used by the MCP client configs below.

To install this Bybit API Interface server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @dlwjdtn535/mcp-bybit-server --client claude

Add one of the following to your MCP settings file (e.g. claude_desktop_config.json / mcp_settings.json).

Using uv (run from a cloned repo):

{
  "mcpServers": {
    "bybit": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/mcp-bybit-server",
        "mcp-bybit-server"
      ],
      "env": {
        "ACCESS_KEY": "YOUR_BYBIT_API_KEY",
        "SECRET_KEY": "YOUR_BYBIT_SECRET_KEY",
        "TESTNET": "true",
        "TRADING_ENABLED": "false"
      }
    }
  }
}

On Windows, use an absolute path with double backslashes (e.g. C:\\Users\\YOUR_USERNAME\\mcp-bybit-server).

Using Docker:

First pull the image: docker pull dlwjdtn535/mcp-bybit-server:latest

{
  "mcpServers": {
    "bybit-server-docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--init",
        "-e", "ACCESS_KEY=YOUR_BYBIT_API_KEY",
        "-e", "SECRET_KEY=YOUR_BYBIT_SECRET_KEY",
        "-e", "TESTNET=true",
        "-e", "TRADING_ENABLED=false",
        "-e", "MAX_ORDER_SIZE_USDT=100",
        "dlwjdtn535/mcp-bybit-server:latest"
      ]
    }
  }
}

> Note: Always use @latest or a specific version tag for both NPX and Docker to ensure you are using the intended version.

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| ACCESS_KEY | Yes | – | Bybit API key. |
| SECRET_KEY | Yes | – | Bybit API secret. |
| MEMBER_ID | No | – | Bybit member ID (optional). |
| TESTNET | No | false | Use the Bybit testnet when true. |
| TRADING_ENABLED | No | false | Must be true to allow any mutating/trading tool. |
| READONLY_MODE | No | false | When true, blocks every mutating tool (takes precedence over TRADING_ENABLED). |
| MAX_ORDER_SIZE_USDT | No | 100 | Caps the estimated notional value (USDT) of a single order. |
| RESPONSE_VERBOSITY | No | normal | minimal trims get_tickers/get_positions responses to core fields to save tokens; normal/full return the full payload. |

To use this Bybit API interface, create an API key from Bybit:

1. Log into your Bybit account.
2. Navigate to API Management.
3. Create a new API key.
4. Important security settings:
Enable IP restriction if possible, and add ONLY the IP address(es) the server runs from.
Never share your API keys or expose them in public repositories.
Recommended permissions:
Read (required)
Trade (required only if you enable order execution)
Wallet (required for balance checking)

get_orderbook

Fetches the order book for a given market. Parameters: category (string), symbol (string), limit (optional integer)

get_kline

Retrieves candlestick data for a specified market. Parameters: category (string), symbol (string), interval (string), start (optional string), end (optional string), limit (optional integer)

get_tickers

Gets ticker information for a specific market. Parameters: category (string), symbol (string)

get_public_trade_history

Returns recent public trades for a specified market. Parameters: category (string), symbol (string), limit (optional integer)

get_instruments_info

Fetches metadata and limits for a specific instrument. Parameters: category (string), symbol (string), status (optional string), baseCoin (optional string)

get_funding_rate_history

Obtains funding rate history for perpetual contracts. Parameters: category (string), symbol (string), startTime (optional string), endTime (optional string), limit (optional integer)

get_open_interest

Retrieves open interest over time for a specified market. Parameters: category (string), symbol (string), intervalTime (optional string)

get_fee_rate

Gets the maker/taker fee rates for a specified market. Parameters: category (string), symbol (optional string), baseCoin (optional string)

get_server_time

Fetches the current server time from Bybit.

market_snapshot

Retrieves a composite view of the market including order book, ticker, kline, instrument data, recent trades, funding rate, and open interest in a single call.

get_wallet_balance

Fetches wallet balances. Parameters: accountType (string), coin (optional string)

get_positions

Retrieves open positions for a specified market. Parameters: category (string), symbol (optional string)

get_order_history

Obtains historical order information.

get_open_orders

Fetches current open orders.

get_api_key_information

Retrieves details about the API key.

validate_order

Performs a pre-flight validation of an order without placing it.

place_order

Places a new order in the market. Supports dry_run parameter to validate without actually placing the order.

amend_order

Modifies an existing order that is already placed.

cancel_order

Cancels a specific order. Parameters: order ID (string)

cancel_all_orders

Cancels all open orders, with an optional scope.

set_trading_stop

Sets take profit, stop loss, or trailing stop for a position.

set_margin_mode

Sets the margin mode for a position (isolated or cross).

set_leverage

Sets the leverage for a specified futures symbol.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "bybit exchange api": {
            "env": {
                "TESTNET": "true",
                "ACCESS_KEY": "YOUR_BYBIT_API_KEY",
                "SECRET_KEY": "YOUR_BYBIT_SECRET_KEY",
                "TRADING_ENABLED": "false"
            },
            "args": [
                "run",
                "--directory",
                "/absolute/path/to/mcp-bybit-server",
                "mcp-bybit-server"
            ],
            "command": "uv"
        }
    }
}

Linux

{
    "env": {
        "TESTNET": "true",
        "ACCESS_KEY": "YOUR_BYBIT_API_KEY",
        "SECRET_KEY": "YOUR_BYBIT_SECRET_KEY",
        "TRADING_ENABLED": "false"
    },
    "args": [
        "run",
        "--directory",
        "/absolute/path/to/mcp-bybit-server",
        "mcp-bybit-server"
    ],
    "command": "uv"
}

Macos

{
    "env": {
        "TESTNET": "true",
        "ACCESS_KEY": "YOUR_BYBIT_API_KEY",
        "SECRET_KEY": "YOUR_BYBIT_SECRET_KEY",
        "TRADING_ENABLED": "false"
    },
    "args": [
        "run",
        "--directory",
        "/absolute/path/to/mcp-bybit-server",
        "mcp-bybit-server"
    ],
    "command": "uv"
}

Windows

{
    "env": {
        "TESTNET": "true",
        "ACCESS_KEY": "YOUR_BYBIT_API_KEY",
        "SECRET_KEY": "YOUR_BYBIT_SECRET_KEY",
        "TRADING_ENABLED": "false"
    },
    "args": [
        "run",
        "--directory",
        "C:\\absolute\\path\\to\\mcp-bybit-server",
        "mcp-bybit-server"
    ],
    "command": "uv"
}

MCP Bybit API Interface

smithery badge Buy Me A Coffee

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.

<a href="https://glama.ai/mcp/servers/@dlwjdtn535/mcp-bybit-server">
Bybit Server MCP server
</a>

⚠️ 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.

Installation

Requires Python 3.12+. This project uses uv.

git clone https://github.com/dlwjdtn535/mcp-bybit-server.git
cd mcp-bybit-server
uv sync
uv run mcp-bybit-server   # runs the MCP server over stdio

After install, the mcp-bybit-server command is the entry point used by the MCP client configs below.

Installing via Smithery

To install this Bybit API Interface server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @dlwjdtn535/mcp-bybit-server --client claude

Configuration (Claude Desktop, Cline, Roo Code, etc.)

Add one of the following to your MCP settings file (e.g. claude_desktop_config.json / mcp_settings.json).

Using uv (run from a cloned repo):

{
  "mcpServers": {
    "bybit": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/mcp-bybit-server",
        "mcp-bybit-server"
      ],
      "env": {
        "ACCESS_KEY": "YOUR_BYBIT_API_KEY",
        "SECRET_KEY": "YOUR_BYBIT_SECRET_KEY",
        "TESTNET": "true",
        "TRADING_ENABLED": "false"
      }
    }
  }
}

On Windows, use an absolute path with double backslashes (e.g. C:\\Users\\YOUR_USERNAME\\mcp-bybit-server).

Using Docker:

First pull the image: docker pull dlwjdtn535/mcp-bybit-server:latest

{
  "mcpServers": {
    "bybit-server-docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--init",
        "-e", "ACCESS_KEY=YOUR_BYBIT_API_KEY",
        "-e", "SECRET_KEY=YOUR_BYBIT_SECRET_KEY",
        "-e", "TESTNET=true",
        "-e", "TRADING_ENABLED=false",
        "-e", "MAX_ORDER_SIZE_USDT=100",
        "dlwjdtn535/mcp-bybit-server:latest"
      ]
    }
  }
}

> Note: Always use @latest or a specific version tag for both NPX and Docker to ensure you are using the intended version.

Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| ACCESS_KEY | Yes | – | Bybit API key. |
| SECRET_KEY | Yes | – | Bybit API secret. |
| MEMBER_ID | No | – | Bybit member ID (optional). |
| TESTNET | No | false | Use the Bybit testnet when true. |
| TRADING_ENABLED | No | false | Must be true to allow any mutating/trading tool. |
| READONLY_MODE | No | false | When true, blocks every mutating tool (takes precedence over TRADING_ENABLED). |
| MAX_ORDER_SIZE_USDT | No | 100 | Caps the estimated notional value (USDT) of a single order. |
| RESPONSE_VERBOSITY | No | normal | minimal 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.)_

API Key Setup

To use this Bybit API interface, create an API key from Bybit:

1. Log into your Bybit account.
2. Navigate to API Management.
3. Create a new API key.
4. Important security settings:
Enable IP restriction if possible, and add ONLY the IP address(es) the server runs from.
Never share your API keys or expose them in public repositories.
Recommended permissions:
Read (required)
Trade (required only if you enable order execution)
Wallet (required for balance checking)

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.

Sponsorship & Donations

If you find this project helpful and would like to support its development:

Buy Me a Coffee

"Buy Me A Coffee"

Referral Program

You can also support this project by signing up for Bybit using our referral link: - My Bybit Referral Link - Referral Code: J1O4JK

Your support helps maintain and improve this project. Thank you! 🙏

Contact & Support

For additional inquiries or support, please contact:
- Email: dlwjdtn5624@naver.com

We welcome your questions and feedback!

License

MIT License

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.