Skip to content

Connect Orderly to Claude: Track market trends and account performance

Learn how to connect Orderly to Claude using a managed MCP server. Execute trades, monitor margin ratios, and analyze market trends using natural language.

Nidhi KN Nidhi KN · · 8 min read
Connect Orderly to Claude: Track market trends and account performance

If your team needs to connect Orderly to Claude to automate market analysis, track account collateral, or execute complex algorithmic trades, you need a Model Context Protocol (MCP) server. This server acts as the translation layer between Claude's tool calls and Orderly's omnichain trading infrastructure. You can either build and maintain this translation layer yourself, or use a managed integration platform like Truto to dynamically generate a secure, authenticated MCP server URL. If your team uses ChatGPT, check out our guide on /connect-orderly-to-chatgpt-execute-trades-and-manage-margin-settings/ or explore our broader architectural overview on /connect-orderly-to-ai-agents-automate-trading-and-asset-transfers/.

Giving a Large Language Model (LLM) read and write access to a decentralized trading environment like Orderly is an engineering challenge. Orderly relies on cryptographic signatures, strict margin rules, and complex nested order types. Every time an endpoint shifts or a new asset is listed, your AI agent needs to understand the updated schema immediately.

This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for Orderly, connect it natively to Claude, and execute complex trading and monitoring workflows using natural language.

The Engineering Reality of the Orderly API

A custom MCP server is a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, the reality of implementing it against a specialized financial infrastructure like Orderly is difficult. You are not just building basic CRUD operations - you are interfacing with high-frequency trading constraints, liquidity pools, and margin systems.

If you decide to build a custom Orderly MCP server, here are the specific integration challenges you will face:

EIP-712 Signatures and Nonce Management Orderly is built on decentralized infrastructure. While standard trading operations use typical API authentication, sensitive operations like withdrawing funds (create_a_orderly_withdrawal) or settling unrealized PnL (orderly_pnl_settlement_request) require Ethereum EIP-712 wallet-signed messages. You cannot simply instruct an LLM to "withdraw funds." The LLM must first fetch a cryptographic nonce, structure a precise payload, and rely on a secure execution environment to sign it. Building an MCP server means you have to map these multi-step cryptographic requirements into discrete tools that an LLM can understand without hallucinating the signature structure.

Nested Schemas for Algorithmic Orders Submitting a basic market order is straightforward. However, Orderly supports advanced algorithmic trading through the create_a_orderly_algo_order endpoint. This endpoint expects heavily nested JSON arrays to define bracket orders, take-profit/stop-loss (TP_SL) pairs, and positional boundaries. If an LLM is not provided with an exact, strict JSON Schema detailing which fields are mutually exclusive, it will routinely generate malformed payloads that Orderly's risk engine will reject.

Strict Egress and Rate Limit Handling Financial APIs aggressively rate-limit requests to maintain matching engine performance. When Orderly issues an HTTP 429 Too Many Requests response, Truto does not retry, throttle, or apply automatic backoff. Instead, Truto passes the 429 error directly back to the caller (your MCP client) while normalizing the upstream rate limit information into standard IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your client application or agent framework is entirely responsible for reading these headers and executing the appropriate retry or backoff logic.

Generating the Managed MCP Server

Instead of writing custom JSON-RPC handlers and maintaining Orderly's schema definitions, you can use Truto to generate a managed MCP server. Truto dynamically reads Orderly's API documentation and your connected account credentials to expose a secure toolset.

You can generate the MCP server URL in two ways.

Method 1: Via the Truto UI

For teams managing integrations visually, the Truto dashboard provides a one-click deployment path:

  1. Navigate to the Integrated Accounts page and select your connected Orderly account.
  2. Click the MCP Servers tab.
  3. Click Create MCP Server.
  4. Select your desired configuration. You can filter the available tools by method (e.g., read-only operations) or by tags (e.g., only exposing market_data endpoints).
  5. Copy the generated MCP server URL (e.g., https://api.truto.one/mcp/abc123xyz...).

Method 2: Via the Truto API

For development teams programmatically provisioning AI access, you can create the MCP server via a REST call. This allows you to dynamically spin up scoped servers for specific agent sessions.

Endpoint: POST /integrated-account/:id/mcp

// Example: Provisioning a read-only Orderly MCP server for market analysis
const response = await fetch('https://api.truto.one/integrated-account/YOUR_ACCOUNT_ID/mcp', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TRUTO_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: "Orderly Market Analyst Agent",
    config: {
      methods: ["read"] // Restrict to GET and LIST operations
    },
    expires_at: "2026-12-31T23:59:59Z" // Optional TTL for the server
  })
});
 
const mcpServer = await response.json();
console.log(mcpServer.url); 
// Output: https://api.truto.one/mcp/secure_token_string

Connecting the MCP Server to Claude

Once you have your Truto MCP URL, you need to connect it to Claude. The MCP protocol handles the discovery phase, meaning Claude will automatically read the schemas and descriptions of the Orderly tools as soon as it connects.

Method 1: Via the Claude UI

If you are using Claude's web or desktop interfaces that support direct connector additions:

  1. Open Claude and navigate to Settings -> Integrations (or Connectors).
  2. Click Add MCP Server or Add custom connector.
  3. Paste your Truto MCP URL and click Add.
  4. Claude will immediately handshake with the URL and list the available Orderly tools.

(Note: If your team uses ChatGPT, the process is similar: Settings -> Apps -> Advanced settings -> Enable Developer mode -> Add Custom Connector).

Method 2: Via the Claude Desktop Config File

For developer environments and local testing with Claude Desktop, you can configure the connection manually using the claude_desktop_config.json file. Because Truto provides an SSE (Server-Sent Events) endpoint, you will use the official @modelcontextprotocol/server-sse package as the transport.

Open your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the Truto server configuration:

{
  "mcpServers": {
    "orderly_truto": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "https://api.truto.one/mcp/YOUR_TRUTO_TOKEN"
      ]
    }
  }
}

Restart Claude Desktop. The Orderly tools will now appear under the available integrations.

Hero Tools for Orderly

Truto automatically translates Orderly's endpoints into strictly typed MCP tools. Here are some of the highest-leverage tools your agent can use to track markets and execute trades.

1. orderly_markets_get_info

Retrieves detailed futures market data for a single symbol, including index prices, mark prices, open interest, and real-time funding rates.

"What is the current estimated funding rate, open interest, and 24-hour volume for PERP_ETH_USDC on Orderly?"

2. orderly_prices_list_historical

Fetches historical price chart data (OHLC) for trading symbols. This is essential for agents tasked with technical analysis or moving average calculations.

"Pull the historical 1-hour price chart data for PERP_BTC_USDC over the last 24 hours so we can identify short-term trends."

3. orderly_account_get_overview_info

Retrieves a comprehensive snapshot of the account's health, including total collateral value, free collateral, and maintenance margin ratios.

"Check my Orderly account overview. What is my current margin ratio, and how much free collateral do I have available for new positions?"

4. list_all_orderly_positions

Lists all open positions across the account, detailing position size, average open price, unsettled PnL, and the estimated liquidation price for each asset.

"List all my open positions. Are there any positions where the current mark price is within 5% of the estimated liquidation price?"

5. create_a_orderly_order

Executes a spot or perpetual contract order. The agent must specify the symbol, order type (e.g., LIMIT, MARKET), and side (BUY, SELL).

"The funding rate on PERP_SOL_USDC is heavily skewed. Open a market SELL order for 50 SOL to hedge our existing exposure."

6. orderly_funding_rate_get_predicted

Retrieves the predicted funding rate for a single market, allowing agents to execute arbitrage strategies before the next funding cycle settles.

"What is the predicted funding rate for PERP_AVAX_USDC for the next funding period?"

To view the complete inventory of available Orderly endpoints, required parameters, and JSON schemas, visit the Orderly integration page on Truto.

Workflows in Action

Giving Claude access to these tools enables complex, multi-step financial operations. Here are two real-world workflows demonstrating how an AI agent orchestrates Orderly tools.

Scenario 1: Market Analysis and Hedging (Quant Persona)

A quantitative analyst wants to monitor market conditions and deploy a hedge if funding rates become too expensive.

"Analyze the current funding rate and 24-hour trading volume for PERP_BTC_USDC. If the funding rate is heavily positive, check my account's free collateral. If I have more than $5,000 in free collateral, execute a short market order for 0.1 BTC to hedge."

Tool Execution Sequence:

  1. orderly_markets_get_info: Claude fetches the market data for PERP_BTC_USDC to check the est_funding_rate and volume.
  2. orderly_account_get_overview_info: Seeing a high positive rate, Claude queries the account to retrieve the free_collateral value.
  3. create_a_orderly_order: Confirming sufficient collateral, Claude executes the hedge by submitting a SELL MARKET order for 0.1 BTC.

Result: The agent autonomously assesses market conditions, verifies account health to prevent margin rejection, and executes the trade - returning the order_id and execution price to the user.

Scenario 2: Liquidation Risk Monitoring (Risk Manager Persona)

During high volatility, a risk manager needs to ensure no positions are nearing forced liquidation.

"Check all my open perpetual positions. Compare the current mark price to the estimated liquidation price for each. If any position is within 10% of liquidation, tell me exactly how much free collateral I have available to deposit as margin."

Tool Execution Sequence:

  1. list_all_orderly_positions: Claude retrieves the array of open positions, extracting mark_price and est_liq_price for each asset.
  2. Internal Logic: Claude calculates the percentage difference between the two prices for every position in the array.
  3. orderly_account_get_overview_info: If a position violates the 10% threshold, Claude fetches the account overview to determine the free_collateral available for rescue.

Result: The user receives a concise risk report highlighting the endangered position (e.g., "Your PERP_ETH_USDC long is 8% away from liquidation. You currently have $12,400 in free collateral available to reduce your margin ratio.").

Security and Access Control

When connecting an LLM to a live trading account, security cannot be an afterthought. Truto provides several mechanisms to lock down the MCP server and prevent rogue agent behavior.

  • Method Filtering: You can restrict the MCP server to specific HTTP verbs. By passing methods: ["read"] during creation, you ensure Claude can only execute GET and LIST requests (like checking balances), preventing it from executing trades or withdrawals.
  • Tag Filtering: Limit the server to a specific domain of tools. Passing tags: ["market_data"] strips out all account management and order execution tools, giving the agent a purely analytical view of the market.
  • Dual-Layer Authentication (require_api_token_auth): By default, possessing the MCP URL grants access. By enabling this flag, the client must also pass a valid Truto API token in the Authorization header. This ensures that even if the MCP URL is leaked in a log file, it cannot be exploited by unauthenticated external parties.
  • Time-to-Live (expires_at): You can generate ephemeral MCP servers for temporary agent sessions. Once the ISO datetime is reached, the server is automatically destroyed and all associated KV records are purged.

Strategic Wrap-Up

Building AI agents that interact with decentralized exchanges and financial infrastructure requires absolute precision. A single malformed JSON payload or misunderstood margin parameter can result in rejected trades or unexpected liquidations.

By using Truto to manage your Orderly MCP server, you offload the burden of maintaining endpoint schemas, normalizing pagination, and translating documentation into prompt-friendly tool descriptions. Your engineering team can focus on refining the AI agent's trading logic and risk management, rather than constantly updating the integration layer to keep pace with Orderly's evolving API.

FAQ

Does Truto automatically retry rate-limited Orderly API requests?
No. When Orderly returns an HTTP 429 rate limit error, Truto passes that error directly back to the caller. Truto normalizes the upstream rate limit information into standardized IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset), leaving the retry and backoff logic to the caller.
How do I restrict the MCP server to read-only market data?
When creating the MCP server in Truto, you can pass a method filter such as config: { methods: ['read'] }. This ensures the server only exposes GET and LIST operations, preventing the LLM from executing trades or modifying account settings.
Can I connect the Orderly MCP server directly to Claude Desktop?
Yes. Truto generates a standard JSON-RPC 2.0 endpoint that can be added to Claude Desktop via the UI or the claude_desktop_config.json file using the @modelcontextprotocol/server-sse transport.
How does the MCP server handle complex nested algo orders?
Truto automatically maps Orderly's documentation and resource schemas into strictly typed MCP tool definitions. When Claude calls a tool like create_a_orderly_algo_order, it uses the provided JSON schema to structure the nested bracket and take-profit/stop-loss parameters correctly.

More from our Blog