dYdX Agent Gateway
One MCP server that gives any AI agent analytics access to dYdX v4: market data, funding analytics, verified trader PnL, leaderboards, anomaly detection. Read-only and keyless — the gateway holds no keys and cannot move funds.
Install
Claude Code:
claude mcp add dydx -- uvx --from git+https://github.com/alekskram/dydx-agent-gateway dydx-agent-gateway
Cursor / any mcp.json:
{"mcpServers": {"dydx": {
"command": "uvx",
"args": ["--from", "git+https://github.com/alekskram/dydx-agent-gateway", "dydx-agent-gateway"]}}}
Codex (~/.codex/config.toml):
[mcp_servers.dydx]
command = "uvx"
args = ["--from", "git+https://github.com/alekskram/dydx-agent-gateway", "dydx-agent-gateway"]
ZCode — register the MCP server and copy the agent skill (all copy-paste):
# 1) start the gateway (keep it running)
uvx --from git+https://github.com/alekskram/dydx-agent-gateway dydx-agent-gateway --http --port 8901 &
# 2) register it (merges into ~/.zcode/cli/config.json; workspace .zcode/config.json works too)
python3 - <<'PY'
import json, os
p = os.path.expanduser("~/.zcode/cli/config.json")
os.makedirs(os.path.dirname(p), exist_ok=True)
cfg = json.load(open(p)) if os.path.exists(p) else {}
cfg.setdefault("mcp", {}).setdefault("servers", {})["dydx"] = {
"type": "http", "url": "http://127.0.0.1:8901/mcp"}
json.dump(cfg, open(p, "w"), indent=2)
print("dydx MCP server registered:", p)
PY
# 3) copy the agent skill (tool guide + data gotchas)
git clone -q --depth 1 https://github.com/alekskram/dydx-agent-gateway /tmp/dag
cp -r /tmp/dag/.agents/skills/dydx-gateway ~/.zcode/skills/ && rm -rf /tmp/dag
echo "ZCode setup done — restart your session and call any dydx tool"
Plain Python:
pip install git+https://github.com/alekskram/dydx-agent-gateway
python -c "from dydx_mcp import server; import json; print(json.dumps(server.market_digest(), default=str)[:400])"
Hosted (streamable HTTP): dydx-agent-gateway --http --port 8901, then any client:
{"mcpServers": {"dydx": {"type": "http", "url": "http://host:8901/mcp"}}}
Requires Python ≥ 3.11. Deps (fastmcp, pycryptodome, ecdsa) install automatically. See examples/ for ready-made configs and a working autonomous agent script.
Tools (22 — read-only, keyless)
| Group | Tools |
|---|---|
| Market data | list_markets, market_detail, candles, recent_trades, height, historical_funding |
| Analytics | funding_heatmap, market_ta, suggest_stops, cvd, correlation |
| Traders | trader_profile, trader_pnl_stats, fills_review, raw_fills |
| Discovery | discover_traders, leaderboard, list_traders, registry_stats |
| Signals | latest_events (funding extremes, OI spikes, liquidation cascades, equity jumps) |
| Briefing | market_digest — one call: events + funding + leaderboard top. Start here. |
Real outputs of every tool: examples/tool-output.md.
What makes it different
- Verified trader PnL.
trader_pnl_statsreconciles the identityequity-Δ = Δpnl + ΣnetTransferson every account — residual ≠ 0 means the numbers lie. Live-checked on real accounts to $0.0000 (seereports/qa-logic.md). Deposit-adjusted maxDD, day-winrate, sharpe-like. - Anomaly detectors, not dashboards. Funding extremes, OI spikes without price, equity jumps, and a liquidation-cascade signature (|Δprice|↑ + OI↓) — the patterns that matter before they're charts. Live catches in
reports/. - Analyst pack. Funding-rate history, CVD, cross-market correlation, raw fills for execution analysis; TA enrichments MACD/VWAP/realized vol; sortino-like downside risk.
- Data-quality discipline. Five documented indexer API gotchas (
.agents/skills/dydx-gateway/references/data-gotchas.md) that silently corrupt naive analytics. 129 tests, CI on 3.11/3.13.
Data notes
Indicators are computed over the current candle window and change with every new bar. nextFundingRate is the exchange's live preview and is recomputed continuously; volume24H is a rolling window. Two calls moments apart legitimately differ.
Safety model
All tools are read-only and keyless. The gateway signs nothing and holds no credentials. An offline-tested EIP-712 signer remains in dydx_mcp/signer.py as a library for anyone building their own execution layer — it is wired to no MCP tool.
FAQ
- Does it trade? No. Analytics only, by design.
- API keys? None. Everything runs on public indexer endpoints.
- Rate limits? Public endpoints, no auth; a 60s markets cache keeps you polite.
- How do I verify a trader before copying them?
trader_profile→trader_pnl_stats→fills_review— check the identity residual and maker/taker mix first.
License
MIT. Not affiliated with dYdX Trading Inc.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dydx_agent_gateway-0.3.0.tar.gz.
File metadata
- Download URL: dydx_agent_gateway-0.3.0.tar.gz
- Upload date:
- Size: 89.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d068cdc162183db1398976796f7f5f35bda8623c6a8d59f8a9fe8cd3dfcf1497
|
|
| MD5 |
055e68a0d0fe359955f1cf924321d860
|
|
| BLAKE2b-256 |
ae822f779f6e3eb9d820037a2cf78b9a435815c3f523c1635ad1d506f3206416
|
Provenance
The following attestation bundles were made for dydx_agent_gateway-0.3.0.tar.gz:
Publisher:
release.yml on alekskram/dydx-agent-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dydx_agent_gateway-0.3.0.tar.gz -
Subject digest:
d068cdc162183db1398976796f7f5f35bda8623c6a8d59f8a9fe8cd3dfcf1497 - Sigstore transparency entry: 2701432080
- Sigstore integration time:
-
Permalink:
alekskram/dydx-agent-gateway@8dcaa8e033b3ee3bf313c3f7fd4d8c3e8cb8efa3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/alekskram
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8dcaa8e033b3ee3bf313c3f7fd4d8c3e8cb8efa3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dydx_agent_gateway-0.3.0-py3-none-any.whl.
File metadata
- Download URL: dydx_agent_gateway-0.3.0-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
068dcaca1f85f37227df761efd57e6eff7411c73bfba389fc407afc08a82bf4e
|
|
| MD5 |
f65711087af67966494c2396151b05b4
|
|
| BLAKE2b-256 |
901495475bd9cadb87c24c8d25d9fefadf67c60afd51b2fc37da2d2b8fa8c5a4
|
Provenance
The following attestation bundles were made for dydx_agent_gateway-0.3.0-py3-none-any.whl:
Publisher:
release.yml on alekskram/dydx-agent-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dydx_agent_gateway-0.3.0-py3-none-any.whl -
Subject digest:
068dcaca1f85f37227df761efd57e6eff7411c73bfba389fc407afc08a82bf4e - Sigstore transparency entry: 2701432274
- Sigstore integration time:
-
Permalink:
alekskram/dydx-agent-gateway@8dcaa8e033b3ee3bf313c3f7fd4d8c3e8cb8efa3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/alekskram
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8dcaa8e033b3ee3bf313c3f7fd4d8c3e8cb8efa3 -
Trigger Event:
push
-
Statement type: