Skip to main content
Sepolia Testnet Only — All data is from Ethereum Sepolia. Token balances and positions have no real-world value.

Quick Connect

MCP endpoint: https://mcp.nilemarkets.com/api/mcp
  • Transport: Streamable HTTP (MCP spec 2025-03-26)
  • Auth: None (open access during M2 testnet)
  • Session: Stateless — no initialize handshake required
claude mcp add nile-markets --transport http https://mcp.nilemarkets.com/api/mcp
For additional platforms (Windsurf, JetBrains, Cline, Zed, Warp, and more), see the full connection guide at mcp.nilemarkets.com/skill.md.

Read Tools (14)

Pool and Protocol

ToolDescriptionInput
get_pool_stateLiquidity pool metrics: total assets, shares, share price, exposure, utilization, feesNone
get_protocol_modeOperating mode: NORMAL, DEGRADED, REDUCE_ONLY, or PAUSEDNone
get_pool_transactionsHistorical vault deposits and withdrawalsfirst?, skip?
get_daily_statsDaily volume, fees, position opens/closes, pool PnLdays? (default 7, max 365)

Positions

ToolDescriptionInput
get_positionsPositions for a specific accountaccount (required), status? (OPEN/CLOSED), first?, skip?
get_positionSingle position with real-time PnL via RPCpositionId (required)
search_positionsSearch all positions with filtersside? (0=LONG, 1=SHORT), tenor? (0=1D, 1=1W, 2=1M), status?, minNotional?, first?, skip?

Oracle and Pricing

ToolDescriptionInput
get_forward_priceForward price for a specific tenortenor (1D, 1W, or 1M), pairId?
get_oracle_stateFull oracle state: spot, all forward prices, validitypairId?

Accounts and Fees

ToolDescriptionInput
get_accountAccount margin: collateral, locked, available, position countaddress (required)
get_fee_eventsFee event breakdown (trading, liquidation, termination, oracle)first?, skip?

Token

ToolDescriptionInput
get_token_balanceERC-20 token balance for an address (defaults to USDC)address (required), token?
check_allowanceERC-20 allowance for an owner/spender pairowner (required), spender (contract name or address), token?

Simulation

ToolDescriptionInput
simulate_open_positionPreview margin, fee, and entry strike for a new positionside (LONG/SHORT), tenor (1D/1W/1M), notional (USDC string), margin?, from?

Write Tools (8)

Write tools return unsigned transaction calldata — they do not execute transactions. Your agent or wallet signs and broadcasts the returned calldata externally.

Trading

ToolDescriptionInput
open_positionCalldata to open a new FX forward positionside, tenor, notional, margin, pairId?, from?
close_positionCalldata to close a position via early terminationpositionId, from?

Margin

ToolDescriptionInput
deposit_marginCalldata to deposit USDC as margin collateral (requires prior approval)amount, from?
withdraw_marginCalldata to withdraw available USDC marginamount, from?

Vault (Liquidity Providers)

ToolDescriptionInput
vault_depositCalldata to deposit USDC into the pool vault (requires prior approval)amount, receiver, from?
vault_withdrawCalldata to withdraw USDC from the pool vaultamount, receiver, owner, from?

Token Approval and Testnet

ToolDescriptionInput
approve_tokenCalldata to approve a Nile contract to spend tokensspender (contract name or address), amount, token?, from?
mint_test_tokenCalldata to mint test tokens (testnet only)to, amount, from?
All amounts are strings in USDC smallest unit (6 decimals). "1000000000" = 1,000 USDC.

Response Format

Every tool response includes protocol metadata:
{
  "protocol": { "name": "Nile Markets", "version": "0.3.0" },
  "network": "sepolia",
  "source": "rpc",
  "blockNumber": "12345678",
  "data": { }
}
FieldTypeDescription
protocol{ name, version }Protocol identity and API version
networkstringTarget network ("sepolia")
sourcestringData source: "rpc", "subgraph", or "rpc+subgraph"
blockNumberstring?Last indexed block (subgraph-sourced responses only)
dataobjectTool-specific response payload
Write tools return TransactionCalldata in the data field:
{
  "to": "0x8d81E9f1D0F0d1BdAAc0a91AFc2976522429A0cd",
  "data": "0x...",
  "value": "0",
  "estimatedGas": "150000",
  "chainId": 11155111,
  "description": "Open LONG 1M position with 10000000000 notional"
}
The to address is always pre-filled with the correct contract. You do not need to look up contract addresses when using write tools.

Write Tool Flow

Write tools produce calldata, not transactions. The signing and broadcasting step happens outside the MCP server.
1

Pre-flight

Call get_protocol_mode to verify the protocol is in NORMAL mode. Call get_token_balance to confirm the wallet has sufficient USDC.
2

Simulate

For position opens, call simulate_open_position to preview the required margin, trading fee, and entry strike before committing.
3

Approve if needed

Call check_allowance for the target contract. If the allowance is insufficient, call approve_token to generate approval calldata, then sign and broadcast it.
4

Generate calldata

Call the write tool (open_position, deposit_margin, etc.). The response includes to, data, value, and chainId.
5

Sign and broadcast

Sign the transaction with any EVM wallet — Foundry cast, viem, ethers.js, MetaMask, OWS, or any signing MCP server. Broadcast to Sepolia.
For complete step-by-step workflows for every write operation, see mcp.nilemarkets.com/workflow.md.

Rate Limits

  • Limit: 100 requests/minute per IP
  • Exceeded: HTTP 429 with Retry-After header
  • No auth tokens: Rate limiting is IP-based during M2 testnet

Example Tool Calls

Check protocol status:
get_protocol_mode → { mode: "NORMAL", allowedOperations: [...] }
Query pool state:
get_pool_state → { totalAssets, totalShares, sharePrice, utilization, ... }
Get EUR/USD 1-month forward price:
get_forward_price { tenor: "1M" } → { strike, forwardPoints, annualizedBasis, ... }
Simulate opening a position:
simulate_open_position {
  side: "LONG",
  tenor: "1W",
  notional: "5000000000"
} → { requiredMargin, tradingFee, entryStrike, success: true }
Search for open short positions above 5,000 USDC notional:
search_positions {
  side: 1,
  status: "OPEN",
  minNotional: "5000000000"
} → { positions: [...], total: 3 }
Check USDC allowance before depositing margin:
check_allowance {
  owner: "0xYourAddress",
  spender: "marginAccounts"
} → { allowance: "0", sufficient: false }
Generate approval calldata:
approve_token {
  spender: "marginAccounts",
  amount: "50000000"
} → { to: "0x319...", data: "0x095ea7b3...", chainId: 11155111 }

Numeric Conventions

TypeDecimalsExample
USDC amounts6"1234567890" = 1,234.567890 USDC
Forward/spot prices18"1085000000000000000" = 1.085000
Utilization, feesBasis points"4500" = 45%

Pagination

Tools that return lists support two parameters:
ParameterDefaultMaxDescription
first251000Page size
skip0Offset from start

Debugging

Test the server directly with the MCP Inspector:
npx @modelcontextprotocol/inspector --transport http --server-url https://mcp.nilemarkets.com/api/mcp
This opens a web UI where you can browse available tools, call them interactively, and inspect raw responses.