Bybit Crypto Exchange MCP server

Provides read-only access to Bybit's cryptocurrency exchange API for retrieving real-time market data, order book information, and account details.
Back to servers
Provider
Sam McLeod
Release date
Dec 26, 2024
Language
TypeScript
Stats
8 stars

This MCP server provides read-only access to Bybit's cryptocurrency exchange API through the Model Context Protocol (MCP). It allows AI models to retrieve real-time cryptocurrency data including prices, orderbooks, and market information from Bybit's exchange.

Installation Requirements

To install and run the Bybit MCP server, you'll need:

  • Node.js (v20 or newer)
  • pnpm package manager
  • Bybit API credentials (read-only)
  • Optionally, Ollama for the integrated client

Basic Installation

  1. Install pnpm if you don't have it already:
npm i -g pnpm
  1. Install dependencies:
pnpm i
  1. Copy the example environment file and configure it:
cp .env.example .env
  1. Edit the .env file with your Bybit API credentials:
BYBIT_API_KEY=your-api-key
BYBIT_API_SECRET=your-api-secret
BYBIT_USE_TESTNET=false
DEBUG=false

Important: Only ever use a read-only API key with this server for security!

Running the Server

MCP Server Only

To run just the MCP server:

pnpm serve

Integrated Server with Ollama Client

To run both the MCP server and the included Ollama client:

  1. Install client dependencies:
(cd client && pnpm i)
  1. Configure the client:
cp client/.env.example client/.env
  1. Edit the client .env file:
OLLAMA_HOST=http://localhost:11434
DEFAULT_MODEL=llama-3.2-11b-instruct:Q8_0
  1. Start the integrated server:
pnpm start

Client Integration

Claude Desktop Configuration

To use with Claude Desktop, add this server to your configuration file at ~/Library/Application\ Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "bybit": {
      "command": "node",
      "args": ["/path/to/bybit-mcp/build/index.js"],
      "env": {
        "BYBIT_API_KEY": "your-api-key",
        "BYBIT_API_SECRET": "your-api-secret",
        "BYBIT_USE_TESTNET": "false"
      }
    }
  }
}

gomcp Configuration

To use with gomcp, add this to ~/.config/gomcp/config.yaml:

mcp_servers:
  - name: "bybit"
    command: "cd /path/to/bybit-mcp && pnpm run serve"
    arguments: []
    env:
      BYBIT_API_KEY: ""      # Add your Bybit API READ ONLY key
      BYBIT_API_SECRET: ""   # Add your Bybit API READ ONLY secret
      BYBIT_USE_TESTNET: "true"  # Set to false for production
      DEBUG: "false"         # Optional: Set to true for debug logging

Available Tools

Get Ticker Information

Retrieves real-time price information for a trading pair:

{
  "name": "get_ticker",
  "arguments": {
    "symbol": "BTCUSDT",
    "category": "spot"
  }
}

Get Orderbook Data

Retrieves market depth information:

{
  "name": "get_orderbook",
  "arguments": {
    "symbol": "BTCUSDT",
    "category": "spot",
    "limit": 25
  }
}

Get Kline/Candlestick Data

Retrieves historical price data:

{
  "name": "get_kline",
  "arguments": {
    "symbol": "BTCUSDT",
    "category": "spot",
    "interval": "1",
    "limit": 200
  }
}

Get Market Information

Retrieves detailed market data:

{
  "name": "get_market_info",
  "arguments": {
    "category": "spot",
    "symbol": "BTCUSDT",
    "limit": 200
  }
}

Get Recent Trades

Retrieves recent execution data:

{
  "name": "get_trades",
  "arguments": {
    "symbol": "BTCUSDT",
    "category": "spot",
    "limit": 200
  }
}

Get Instrument Information

Retrieves detailed trading pair specifications:

{
  "name": "get_instrument_info",
  "arguments": {
    "symbol": "BTCUSDT",
    "category": "spot"
  }
}

Get Wallet Balance

Retrieves account balance information:

{
  "name": "get_wallet_balance",
  "arguments": {
    "accountType": "UNIFIED",
    "coin": "BTC"
  }
}

Get Positions

Retrieves current positions (for futures trading):

{
  "name": "get_positions",
  "arguments": {
    "category": "linear",
    "symbol": "BTCUSDT",
    "limit": 200
  }
}

Get Order History

Retrieves historical order information:

{
  "name": "get_order_history",
  "arguments": {
    "category": "spot",
    "symbol": "BTCUSDT",
    "limit": 200
  }
}

Supported Trading Categories

  • spot: Spot trading pairs
  • linear: Linear perpetual contracts (quoted in USDT/USDC)
  • inverse: Inverse perpetual contracts (quoted in the cryptocurrency)

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later