mangrovemarkets — Python SDK
The mangrovemarkets package is the official Python client for the MangroveMarkets MCP Server. It covers DEX aggregation (1inch, XPMarket, etc.), wallet management, and portfolio analytics, with client-side signing — the SDK never touches your private keys.
Install
1.0.2 (PyPI).
Setup
MANGROVE_API_KEY / MANGROVE_BASE_URL from the environment:
base_url="http://localhost:8080".
Hello world
Service modules
| Module | Purpose |
|---|---|
client.dex | Quote, approve, prepare, broadcast, and tx-status for DEX swaps across 1inch, XPMarket, and other supported venues |
client.wallet | Chain info, balances, transactions, multi-chain wallet ops |
client.portfolio | USD-denominated portfolio value, P&L, token holdings |
client.marketplace | Agent marketplace operations (list, search, offer, accept, deliver, rate) |
client.cex | CEX read-side: tickers, orderbooks (where licensed) |
Full swap flow
A DEX swap goes through six steps: quote, approve, prepare, sign locally, broadcast, and confirm.Configuration
| Parameter | Env var | Default | Description |
|---|---|---|---|
base_url | MANGROVE_BASE_URL | the prod MCP server | MCP server URL (use http://localhost:8080 for local) |
api_key | MANGROVE_API_KEY | None | API key for authenticated endpoints |
timeout | — | 30.0 | Request timeout in seconds |
max_retries | — | 3 | Max retries on 429 / 5xx |
auto_retry | — | True | Enable automatic retry with backoff |
Security
The SDK never stores or transmits private keys. All signing happens locally in your application. Theprepare_swap and approve_token methods return unsigned transaction payloads that you sign with your own wallet / signer before broadcasting through broadcast.
Examples
The repo’sexamples/ directory has runnable scripts:
quickstart.py— chain info and DEX venuesswap_flow.py— full swap lifecycleportfolio_check.py— portfolio value, P&L, token holdingse2e_swap.py— a real0.10 USDC -> ETHswap on Base mainnet (requiresweb3and a funded wallet; install withpip install mangrovemarkets[e2e])
TypeScript equivalent
Same surface in TypeScript / Node: see@mangrove-ai/sdk.
Source
- PyPI:
mangrovemarkets(v1.0.2) - GitHub: MangroveMarkets / packages/python-sdk
- Underlying server: MangroveMarkets MCP server (56 tools)
- License: MIT