Metadata-Version: 2.4
Name: obol-mcp
Version: 0.2.0
Summary: Read-only MCP server for the public Obol API: DV cluster troubleshooting and monitoring
Author-email: Obol Network <support@obol.tech>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/ObolNetwork/obol-mcp
Project-URL: Repository, https://github.com/ObolNetwork/obol-mcp
Project-URL: Documentation, https://github.com/ObolNetwork/obol-mcp#readme
Project-URL: Issues, https://github.com/ObolNetwork/obol-mcp/issues
Keywords: mcp,obol,dvt,ethereum,staking,distributed-validators,fastmcp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastmcp<3.3.0,>=3.2.4
Requires-Dist: httpx<0.29.0,>=0.28.1
Requires-Dist: certifi>=2026.10.19
Provides-Extra: dev
Requires-Dist: pytest<10,>=9.0; extra == "dev"
Requires-Dist: pytest-asyncio<2,>=1.0; extra == "dev"
Requires-Dist: pytest-cov<8,>=7.0; extra == "dev"
Dynamic: license-file

# Obol MCP

[![PyPI version](https://badge.fury.io/py/obol-mcp.svg)](https://badge.fury.io/py/obol-mcp)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)

A read-only [MCP](https://modelcontextprotocol.io) server, built on [FastMCP](https://gofastmcp.com), that lets an LLM look up Distributed Validator (DV) clusters, validators, exit coordination status and operators through the public [Obol API](https://docs.obol.org/api/what-is-this-api) (`https://api.obol.tech`).

It exposes 21 tools. None of them can change anything: the server only sends GET requests, plus one POST to the read-only positions lookup.

## Tools

| Tool | What it returns | Obol API endpoint |
|------|-----------------|-------------------|
| `obol_api_health` | API, database and beacon node health | `GET /v1/_health` |
| `obol_cluster_lock_by_hash` | Cluster lock: definition (name, operators, threshold) and distributed validators | `GET /v1/lock/{lockHash}` |
| `obol_lock_by_config_hash` | Latest lock created from a definition | `GET /v1/lock/configHash/{configHash}` |
| `obol_locks_by_network` | Page of locks on a network (hashes only unless `details=true`) | `GET /v1/lock/network/{network}` |
| `obol_cluster_search` | Locks matching part of a lock hash or cluster name | `GET /v1/lock/search/{network}` |
| `obol_network_summary` | Total clusters, operators and ETH staked (mainnet only) | `GET /v1/lock/network/summary/{network}` |
| `obol_cluster_effectiveness` | Per-validator effectiveness (`{pubkey: {"all": 0-1}}`) | `GET /v1/effectiveness/{lockHash}` |
| `obol_cluster_validator_states` | Per-validator beacon state, status and balance (ETH) | `GET /v1/state/{lockHash}` |
| `obol_operator_clusters` | Locks where an address is an operator | `GET /v1/lock/operator/{address}` |
| `obol_operator_info` | Page of operators on a network | `GET /v1/address/network/{network}` |
| `obol_search_operators` | Operators matching part of an address | `GET /v1/address/search/{network}` |
| `obol_operator_badges` | Badges (Lido, Genesis Dappnode, ...) and whether each is earned | `GET /v1/address/badges/{address}` |
| `obol_operator_techne` | Techne credentials held (base, bronze, silver, gold) | `GET /v1/address/techne/{address}` |
| `obol_operator_incentives` | Claimable Obol incentives | `GET /v1/address/incentives/{network}/{address}` |
| `obol_cluster_exit_status_summary` | Signed exits per operator and validators ready to exit | `GET /v1/exp/exit/status/summary/{lockHash}` |
| `obol_cluster_exit_status` | Per-validator exit signature status (1-indexed pages) | `GET /v1/exp/exit/status/{lockHash}` |
| `obol_cluster_definition` | Pre-DKG cluster definition | `GET /v1/definition/{configHash}` |
| `obol_operator_definitions` | Definitions that include an operator | `GET /v1/definition/operator/{address}` |
| `obol_positions` | Clusters where an address is withdrawal address or fee recipient | `POST /v1/positions/{network}/{address}` (read-only lookup) |
| `obol_owr_tranches` | OWR contract recipients and threshold | `GET /v1/owr/{network}/{address}` |
| `obol_terms_signed_status` | Whether an address signed the latest terms | `GET /v1/termsAndConditions/{address}` |

Supported networks: `mainnet`, `hoodi`, `sepolia`, `gnosis`. Holesky has been retired by the API and is rejected.

### Input rules

Every value that goes into a URL is validated before any request is made:

- `lock_hash`, `config_hash`: `0x` + 64 hex characters
- addresses: `0x` + 40 hex characters
- validator pubkeys: `0x` + 96 hex characters
- `network`: one of the supported networks
- `sortBy`, `sortOrder`, `pool`: fixed lists (see each tool's description)
- page sizes are capped (50 for most lists, 5 for `obol_locks_by_network` with `details=true`, 100 for exit status); larger values are reduced to the cap

## Guardrails

The server is meant for answering questions about specific clusters, not for bulk data collection.

- **Identifies itself**: every request carries `User-Agent: obol-mcp/<version>`, plus `(<OBOL_MCP_CLIENT_ID>)` if set.
- **Rate limited**: by default 30 upstream requests per minute (burst of 10). Past that, tools return an error telling the model to slow down instead of queueing.
- **No retries**: upstream errors, including 5xx, are reported once and not retried.
- **Short cache**: identical lookups within 30 seconds are served from memory.
- **Size limits**: responses over 20 MiB are not downloaded. Results bigger than about 40 KB have long lists cut down (nested lists of up to 32 items, such as a cluster's operators, are kept whole), with a `_obol_mcp_truncated` field giving the full lengths.
- **Short errors**: tool errors carry the HTTP status and, for 4xx, the API's one-line message. Upstream bodies, stack traces and internal exception text are never passed through.
- **No redirects** are followed, and the API host is allowlisted.

## Installation

```bash
pip install obol-mcp      # or: uvx obol-mcp
```

### Claude Code

The [`obol` plugin](https://github.com/ObolNetwork/skills) bundles this server along with the `distributed-validators` skill, which tells Claude when and how to use the tools:

```bash
claude plugin marketplace add ObolNetwork/skills
claude plugin install obol@obol
```

To add only the server: `claude mcp add obol -- uvx obol-mcp`.

### Claude Desktop

Config file: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows).

```json
{
  "mcpServers": {
    "Obol MCP": {
      "command": "uvx",
      "args": ["obol-mcp"]
    }
  }
}
```

Without `uvx`, use `"command": "python", "args": ["-m", "obol_mcp"]` with `obol-mcp` installed in that Python.

### Cursor

Settings → MCP → "Add new global MCP server", with the same `mcpServers` entry as above.

### Docker (HTTP)

```bash
docker run -p 8000:8000 -e OBOL_MCP_AUTH_TOKEN="$(openssl rand -hex 32)" ghcr.io/obolnetwork/obol-mcp
```

The image serves Streamable HTTP at `/mcp` on port 8000, runs as an unprivileged user, and installs exactly the hash-pinned dependencies in `uv.lock`. Clients send `Authorization: Bearer <token>`.

## Configuration

All settings are environment variables, validated at startup; an invalid value stops the server with an error.

| Variable | Default | Meaning |
|----------|---------|---------|
| `OBOL_MCP_API_BASE_URL` | `https://api.obol.tech` | API origin. Must be https and one of `api.obol.tech`, `obol-api-nonprod-dev.dev.obol.tech`, `obol-api-nonprod-qa.dev.obol.tech`. A trailing `/v1` is accepted. |
| `OBOL_MCP_ALLOW_CUSTOM_API_URL` | `false` | Allow any https host, or plain http on localhost (for a local obol-api). |
| `OBOL_MCP_CLIENT_ID` | unset | Appended to the User-Agent, e.g. `obol-mcp/0.2.0 (slack-bot)`, so API operators can tell deployments apart. `[A-Za-z0-9._-]`, up to 64 characters. |
| `OBOL_MCP_TRANSPORT` | `stdio` | `stdio` or `http` (Streamable HTTP). |
| `OBOL_MCP_HOST` | `127.0.0.1` | HTTP bind address. The Docker image sets `0.0.0.0`. |
| `OBOL_MCP_PORT` | `8000` | HTTP port. |
| `OBOL_MCP_AUTH_TOKEN` | unset | If set (at least 32 characters), HTTP requests must send `Authorization: Bearer <token>`. Strongly recommended whenever the HTTP port is reachable by anything other than a trusted client. |
| `OBOL_MCP_TIMEOUT_SECONDS` | `15` | Per-request timeout (1–60). |
| `OBOL_MCP_RATE_LIMIT_PER_MINUTE` | `30` | Upstream requests per minute (1–600). |
| `OBOL_MCP_RATE_LIMIT_BURST` | `10` | Requests allowed back to back (1–100). |
| `OBOL_MCP_MAX_CONCURRENCY` | `4` | Concurrent upstream requests (1–16). |
| `OBOL_MCP_CACHE_TTL_SECONDS` | `30` | Cache lifetime for successful lookups; `0` disables (0–600). |
| `OBOL_MCP_MAX_RESPONSE_BYTES` | `20971520` | Largest upstream response that will be downloaded. |
| `OBOL_MCP_MAX_OUTPUT_BYTES` | `40000` | Budget for a tool result before lists are truncated. Sized to stay under Claude Code's default 25,000-token MCP output limit (hex-heavy JSON is about 2 bytes per token). |

No API keys are needed: every endpoint used is public.

## Example

```python
import asyncio
from fastmcp import Client

async def main():
    async with Client("server.py") as client:
        print(await client.call_tool("obol_api_health"))
        print(await client.call_tool("obol_network_summary", {"network": "mainnet"}))
        print(await client.call_tool("obol_cluster_exit_status_summary", {"lock_hash": "0x<64 hex chars>"}))

asyncio.run(main())
```

Typical flows:

- **Cluster health**: `obol_cluster_lock_by_hash` → `obol_cluster_effectiveness` → `obol_cluster_validator_states`.
- **Voluntary exit progress**: `obol_cluster_exit_status_summary`, then `obol_cluster_exit_status` filtered by `operatorAddress` (validators that operator has not signed yet) or `validatorPubkey`.
- **Operator background**: `obol_operator_clusters`, `obol_operator_techne`, `obol_operator_badges`, `obol_terms_signed_status`.

## Development

```bash
git clone https://github.com/ObolNetwork/obol-mcp.git
cd obol-mcp
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"

pytest                     # unit tests, no network access needed
fastmcp dev server.py      # MCP Inspector UI
python -m obol_mcp         # run over stdio
```

Code lives in `obol_mcp/`: `config.py` (environment settings), `validation.py` (input checks), `client.py` (the single HTTP client and its guardrails) and `server.py` (tool definitions). The root `server.py` is a shim for `fastmcp dev` and `fastmcp.json`.

Dependencies are locked in `uv.lock`. After changing `pyproject.toml`, run `uv lock`; CI fails if the lock is out of date.

### Security checks

```bash
uv export --frozen --no-dev --no-emit-project -o /tmp/req.txt
uvx pip-audit --disable-pip -r /tmp/req.txt
```

CI runs the same audit on every push and pull request and weekly. Report vulnerabilities to security@obol.tech (see [SECURITY.md](SECURITY.md)).

## License

Apache License 2.0. See [LICENSE](LICENSE).
