Skip to main content
Glama
bybit-funding-rate

bybit-funding-rate

by tordagaz-ops
README.md
# Bybit Funding Rate — MCP server

[![MCP](https://img.shields.io/badge/MCP-compatible-4B32C3)](https://modelcontextprotocol.io)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

An MCP server that gives any AI agent **Bybit perpetual funding rates**: the live
rate for one symbol, the annualised yield it implies, a market-wide scan for the
most crowded positions, and side-by-side comparison of a shortlist.

Public API only. No API key, no account, no registration.

> **Why it is useful.** Funding rate is the cost of holding a perpetual position
> and the cleanest public proxy for positioning. A rate of `0.0001` per 8 hours
> is `10.95%` annualised — the number traders actually compare. LLMs do not have
> this in their training data and cannot compute it reliably from memory, so a
> tool call is the only correct answer.

---

## Tools

| Tool | What it does | Arguments |
|---|---|---|
| `get_funding_rate` | Current funding rate for one Bybit perpetual: raw rate, % per interval, annualised %, next settlement in UTC, seconds remaining, mark/last price, open interest | `symbol` (default `BTCUSDT`) |
| `get_top_funding_rates` | Scans **every** Bybit perpetual and returns the symbols with the largest absolute funding rate | `limit` 1–50 (default `10`), `min_abs_annualized_pct` (optional filter) |
| `compare_funding_rates` | Ranks up to 10 symbols by annualised rate; lists unknown symbols instead of failing | `symbols_csv` (default `BTCUSDT,ETHUSDT,SOLUSDT`) |

All three are read-only (`readOnlyHint: true`) and work with any symbol format:
`BTCUSDT`, `btc/usdt`, `BTC-USDT`.

### Example

```jsonc
// get_funding_rate {"symbol": "BTCUSDT"}
{
  "symbol": "BTCUSDT",
  "funding_rate": 0.0001,
  "funding_rate_pct": 0.01,
  "annualized_pct": 10.95,
  "funding_interval_hours": 8.0,
  "next_funding_time_utc": "2026-11-26T08:00:00Z",
  "seconds_to_funding": 3648,
  "mark_price": 60550.44,
  "last_price": 60548.4,
  "open_interest_usd": 4293114417.99,
  "turnover_24h_usd": 7404907076.89,
  "warning": null,
  "source": "bybit"
}
```

```jsonc
// get_top_funding_rates {"limit": 3}
{
  "as_of": "2026-11-26T06:59:11Z",
  "universe": 913,
  "returned": 3,
  "filter": {"min_abs_annualized_pct": null},
  "rates": [
    {"symbol": "MOVEUSDT", "funding_rate": -0.02,       "funding_rate_pct": -2.0,       "annualized_pct": -17520.0, "funding_interval_hours": 1.0, "warning": "extreme_rate"},
    {"symbol": "CTCUSDT",  "funding_rate": -0.02,       "funding_rate_pct": -2.0,       "annualized_pct": -4380.0,  "funding_interval_hours": 4.0, "warning": "extreme_rate"},
    {"symbol": "BABYUSDT", "funding_rate": -0.01057819, "funding_rate_pct": -1.057819,  "annualized_pct": -2316.624, "funding_interval_hours": 4.0, "warning": "extreme_rate"}
  ],
  "source": "bybit"
}
```

Entries whose annualised rate exceeds 1000% carry `warning: "extreme_rate"` plus a
localised `warning_message`: those rates sit at the exchange cap or on symbols that
settle hourly, so the annualised figure is a stress signal rather than a holdable yield.

Errors never crash a conversation. They come back as structured data instead:

```jsonc
// get_funding_rate {"symbol": "BTCUSDTT"}
{
  "error": "symbol_not_found",
  "message": "Symbol 'BTCUSDTT' is not a Bybit perpetual. Check the ticker spelling. Did you mean: BTCUSDT?",
  "symbol": "BTCUSDTT",
  "suggestions": ["BTCUSDT"]
}
```

Error codes: `empty_symbol`, `invalid_symbol`, `symbol_not_found`,
`no_symbols`, `too_many_symbols`, `no_data`, `timeout`, `network_error`,
`upstream_unavailable`, `upstream_rejected`, `bad_payload`.

---

## Install

### Smithery (hosted, nothing to install)

Publish or use the hosted instance, then point your client at it:

```bash
npx -y @smithery/cli@latest install bybit-funding-rate --client claude
```

### `uvx` (one command, no clone)

```bash
uvx --from git+https://github.com/<tordagaz-ops>/bybit-funding-rate mcp-bybit-funding-rate
```

### pip

```bash
pip install git+https://github.com/<tordagaz-ops>/bybit-funding-rate
bybit-funding-rate
```

### Docker

```bash
docker build -t bybit-funding-rate .
docker run -i --rm bybit-funding-rate                              # stdio
docker run -p 8000:8000 -e MCP_TRANSPORT=http bybit-funding-rate   # HTTP
```

---

## Connect your client

**Claude Desktop** — `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "bybit-funding-rate": {
      "command": "bybit-funding-rate",
      "env": { "MCP_LOCALE": "en" }
    }
  }
}
```

**Claude Code**:

```bash
claude mcp add bybit-funding-rate -- bybit-funding-rate
```

**Any stdio client** — command `python`, args `["-m", "mcp_bybit_funding"]` after
installing the package.

**Streamable HTTP**:

```bash
MCP_TRANSPORT=http MCP_PORT=8000 bybit-funding-rate
# endpoint: http://localhost:8000/mcp
```

---

## Configuration

| Variable | Default | Description |
|---|---|---|
| `MCP_LOCALE` | `en` | Language of tool titles, descriptions and messages: `en`, `es`, `ru` |
| `MCP_TRANSPORT` | `stdio` | `stdio` or `http` (streamable HTTP) |
| `MCP_HOST` | `0.0.0.0` | Bind address, HTTP transport only |
| `MCP_PORT` | `8000` | Port, HTTP transport only |
| `MCP_HTTP_USER_AGENT` | `mcp-tools/1.0` | Override the outbound User-Agent |

Nothing else to configure. There is no API key, and in-process caching (30 s for
the market scan, 5 s for single symbols) keeps a tool cluster well inside Bybit's
public rate limits.

---

## Try it

Once connected, ask your agent:

- *"What is the funding rate on BTCUSDT and when is the next settlement?"*
- *"Which Bybit perpetuals have the most extreme funding right now?"*
- *"Compare funding on BTC, ETH, SOL and TON — which is the most expensive to long?"*

---

## Development

```bash
python -m venv .venv
.venv/Scripts/activate          # Windows;  source .venv/bin/activate on macOS/Linux
pip install -e ".[dev]"
pytest                            # unit + live + end-to-end
pytest -m "not live"              # offline only
```

The suite has three layers:

1. **unit** — pure logic and HTTP retries with a mocked transport, no network;
2. **live** — the real Bybit endpoint must answer and return the documented shape;
3. **e2e** — spawns `python -m mcp_bybit_funding`, performs the MCP handshake over
   stdio, lists tools and calls them, including the Spanish and Russian locales.

Layer 3 is what proves the package works when Smithery or MCPize launches it.

---

## Data source and limitations

- Source: Bybit v5 public REST, `/v5/market/tickers` (`category=linear`).
- `annualized_pct` is the naive projection of the current rate over a year
  (`rate × intervals_per_year × 100`). It is not a prediction: funding is
  re-computed every interval and rates mean-revert.
- The settlement interval is read from Bybit (`fundingIntervalHour`) and falls
  back to 8 h, because some symbols settle every 4 h — a few even hourly, which
  is why rates above 1000% annualised are flagged with `warning: extreme_rate`.
- Spot, inverse contracts and options are out of scope: linear perpetuals only.
- Market data is informational, not investment advice.

## License

MIT — see [LICENSE](LICENSE).

---

**Other languages:** [Русский](README.ru.md) · [Español](README.es.md)

TDQS

A3.9/5.0

Scored across 3 tools

Disambiguation4/5

Each tool has a distinct scope: a single-symbol lookup, a market-wide top-N scan, and a bounded multi-symbol comparison. The only mild overlap is between get_funding_rate and compare_funding_rates for multi-symbol reads, but the ranking and non-listed-symbol handling make the boundary clear.

Naming Consistency5/5

All three names use snake_case with a verb-led pattern (get_/compare_ + resource), and the 'funding_rate(s)' noun is used uniformly. Consistent and predictable.

Tool Count4/5

Three tools is lean but fits a narrow, read-only funding-rate domain where each tool answers a different question (single, market scan, comparison). No filler tools, though the surface is at the low end.

Completeness3/5

The real-time surface is coherent, but there is no historical funding-rate tool (past intervals, funding history over time) and no flat 'all symbols' bulk fetch, which are common needs for a funding-rate server. Agents must work around these gaps.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues