lighter-mcp

lighter-mcp

A portable MCP server that exposes Lighter trading to any MCP-capable agent with safety-first features like mode-based gating, two-step confirmations, and audit logging.

Category
访问服务器

README

Lighter MCP Toolkit

CI PyPI 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 (readonly → paper → live → funds): 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

<details> <summary><b>uvx (zero install, ephemeral)</b></summary>

uvx lighter-mcp init

uvx runs the published wheel from a cached venv. Good for one-off exploration; for steady-state use prefer pipx install so the agent config can point at a stable executable path.

</details>

<details> <summary><b>Docker (GHCR)</b></summary>

docker pull ghcr.io/iamgoatedaf/lighter-mcp:0.1.0
docker run --rm -it -v ~/.lighter:/data \
    ghcr.io/iamgoatedaf/lighter-mcp:0.1.0 \
    lighter-mcp init --no-scaffolds

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

</details>

<details> <summary><b>From source (development)</b></summary>

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

</details>

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 Auto-install
Cursor ✅ rule (.mdc) ✅ ✅ ✅ lighter-mcp init --agents cursor
Claude Code ✅ SKILL.md ✅ ✅ ✅ lighter-mcp init --agents claude-code
Claude Desktop ✅ SKILL paste ❌ ❌ ❌ lighter-mcp init --agents claude-desktop
Codex ✅ SKILL.md ✅ ✅ ✅ lighter-mcp init --agents codex
OpenClaw / Telegram ✅ mapping doc bot-side ❌ bot-side manual — see adapters/openclaw/
Generic MCP ✅ by hand — — — see adapters/generic/

lighter-mcp init (no --agents) detects all installed agents at once. Per-platform READMEs explain exactly which UI surfaces exist for that agent and which require workarounds.

Examples

End-to-end walkthroughs in examples/:

  • paper-demo.md — first paper trade, step-by-step.
  • guarded-live-order.md — full two-step confirm flow on lighter_live_market_order.
  • funding-scan.md — read-only scan of funding rates across symbols.
  • live-pnl-watcher/ — two-pane terminal workflow: a WebSocket-driven PnL view that hot-reloads on paper-state.json changes, plus a trade.sh CLI wrapper for long/short/status while the watcher is running.

Hosted documentation site — website/ 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选