Skip to main content

Safety-first MCP server exposing Lighter perpetual-DEX trading to AI agents (Cursor, Claude, Codex, Claude Desktop, OpenClaw).

Project description

Lighter MCP Toolkit

CI Python License: MIT MCP

Read this first: live orders and withdrawals on Lighter are irreversible. Read DISCLAIMER.md before flipping mode = "live" or mode = "funds".

A portable Model Context Protocol server that exposes Lighter trading to any MCP-capable agent — Cursor, Claude Code, Claude Desktop, Codex, OpenClaw, and generic MCP clients — with safety as a first-class concern, not an afterthought.

The server wraps the official lighter-agent-kit Python scripts via subprocess and adds:

  • Typed Pydantic input schemas with regex-validated symbols and asset codes (no command-line argument injection).
  • Mode-based safety gates (readonlypaperlivefunds): the tool catalog grows monotonically; live and funds tools physically do not exist in the catalog until you opt in.
  • Two-step confirmations for every fund-loss path: first call returns a preview + single-use token, second call with the token executes. Tokens are bound to tool name + argument digest and TTL-limited.
  • Atomic, UTC-keyed daily-notional ledger that fail-safes to cap exhausted if its file is corrupt — never silently resets to 0.
  • Append-only audit log with sanitized argv/result, intra-process lock + POSIX flock, and soft-fail on disk errors.
  • Streamable-HTTP transport that refuses to bind non-loopback hosts unless --allow-remote is passed (the server has no built-in auth).

Why not just use the kit directly?

The kit is a CLI for a human. This server is the safety harness for a non-human caller. Every call is schema-validated, gate-checked, audited, and (for write paths) preview-confirmed before any subprocess runs against the exchange. The agent literally cannot reach the kit without going through these layers.

Quick start

One command, end to end:

pipx install lighter-mcp && lighter-mcp init

lighter-mcp init clones the upstream lighter-agent-kit into ~/.lighter/lighter-agent-kit, writes a default readonly config to ~/.lighter/lighter-mcp/config.toml, and auto-wires every MCP-capable agent it finds locally — Cursor, Claude Code, Claude Desktop, Codex — including slash-commands, the lighter-trader sub-agent, and the post-trade hook. Restart your agent and try:

/lighter-status

That's it. Live trading stays OFF until you flip it on in the config and re-run lighter-mcp doctor.

Other ways to install

uvx (zero install, ephemeral)
uvx lighter-mcp init
Homebrew (macOS / Linux)
brew install iamgoatedaf/tap/lighter-mcp
lighter-mcp init
Docker
docker run --rm -it -v ~/.lighter:/data \
    ghcr.io/iamgoatedaf/lighter-mcp \
    lighter-mcp init --no-scaffolds

The image ships with the kit pre-cloned and runs lighter-mcp serve on :8791 by default.

Smithery (auto-wires Claude Desktop / Cursor / Continue / Cline)
npx -y @smithery/cli install @iamgoatedaf/lighter-mcp --client claude
From source (development)
git clone https://github.com/iamgoatedaf/lighter-mcp
cd lighter-mcp
python3 -m venv .venv && .venv/bin/pip install -e ".[dev,http]"
.venv/bin/lighter-mcp init

After any path above, lighter-mcp doctor should print a green health envelope.

Modes and tools

Mode Reads Paper trading Live trading Transfers / Withdrawals Tools
readonly 18
paper 29
live gated 37
funds gated gated 39

live and funds additionally require explicit [live] / [funds] config blocks with allowlists, notional caps, leverage caps, and confirmation flags. See docs/configuration.md.

Slash commands and sub-agent (Cursor / Claude Code / Codex)

The adapters ship a pre-built UI layer driven by the same MCP tools:

Command What it does
/lighter-status Active mode, daily-notional remaining, equity, open orders.
/lighter-positions Positions with entry / mark / PnL / liq distance.
/lighter-kill Panic close: cancel_all + close_all, two-step confirm with the literal word confirm.
/lighter-paper Switch active mode to paper. Prompts before editing config.
/lighter-audit Tail the audit log with filters (last N hours, only failures, by tool).

Plus a dedicated lighter-trader sub-agent with a narrow lighter_*-only tool budget that cannot edit source files and refuses to chain a kill without an explicit confirmation word.

The single source of truth for these prompts lives in adapters/_shared/. Per-platform folders are symlinks back into it.

Agent adapters

Platform MCP tools SKILL / system prompt Slash commands Sub-agent Hook Install
Cursor rule (.mdc) bash install.sh --adapter cursor
Claude Code SKILL.md bash install.sh --adapter claude
Codex SKILL.md bash install.sh --adapter codex
Claude Desktop SKILL paste manual — see adapters/claude-desktop/
OpenClaw / Telegram mapping doc bot-side bot-side manual — see adapters/openclaw/
Generic MCP by hand see adapters/generic/

Per-platform READMEs explain exactly which UI surfaces exist for that agent and which require workarounds.

Examples

End-to-end walkthroughs in examples/:

Hosted documentation sitewebsite/ is a Mintlify project. Push to GitHub and Mintlify auto-deploys the site at https://lighter-mcp.mintlify.app (or your custom domain). Local preview: cd website && npm run dev.

Markdown deep-dives in docs/ (legacy / source material for the site):

Development

python3.11 -m venv .venv
.venv/bin/pip install -e ".[dev,http]"
.venv/bin/ruff check .
.venv/bin/pytest -q   # 53 tests, fully hermetic by default

Tests that need a real lighter-agent-kit checkout are auto-skipped unless LIGHTER_KIT_PATH is set. See CONTRIBUTING.md for the contribution workflow and the bar for changes that touch safety.py, confirmations.py, or any lighter_live_* / lighter_funds_* tool.

Compatibility notes

  • Tested against lighter-agent-kit as of April 2026. The wrapper relies on the kit's query.py / trade.py / paper.py script entry points and their JSON stdout contracts — pin to a known-good kit commit if you fork.
  • Python ≥ 3.10. Built and tested on macOS and Ubuntu; Windows works for the server itself, but the per-platform adapters use symlinks — run adapters/_shared/sync.sh to materialize them as real files.

Project status

Alpha (0.1.0). Tool surface is stable enough to use, but expect schema-level breaking changes between minor versions until 1.0. See CHANGELOG.md.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lighter_mcp-0.1.0.tar.gz (84.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lighter_mcp-0.1.0-py3-none-any.whl (98.2 kB view details)

Uploaded Python 3

File details

Details for the file lighter_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: lighter_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 84.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lighter_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b92b2edee83a38b8c551649d3185a16107d96a0964ac8997d358c0c477f1033b
MD5 f23ca876cd1e48c9da8c2d2f58d19515
BLAKE2b-256 1c70872b5d06ae35d48b51365843c5d4a0459e3f62088bb3cd1f2f3a0945213a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lighter_mcp-0.1.0.tar.gz:

Publisher: release.yml on iamgoatedaf/lighter-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lighter_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lighter_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 98.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lighter_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e74a43b2d5c5f8c50d1bf2908e0839954ec3ef96fbeb7553bcf385be1920a6c
MD5 097f31a9b835ea1d93a3b960275e5e9e
BLAKE2b-256 9dfca78a8d5e040b73e8f2b4f6ec3d23cfb7a89fa2852ff4ef7669cea6c61d75

See more details on using hashes here.

Provenance

The following attestation bundles were made for lighter_mcp-0.1.0-py3-none-any.whl:

Publisher: release.yml on iamgoatedaf/lighter-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page