Skip to main content
Glama
mbarinov

OKX MCP Server

by mbarinov

get_open_orders

Read-onlyIdempotent

Retrieve all currently open orders from your OKX trading account to monitor active trades and manage your portfolio effectively.

Instructions

Get all currently open orders

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_open_orders' tool. It calls the OKX API client to fetch open orders and returns them as formatted JSON or an error message.
    export default async function get_open_orders({}: InferSchema<typeof schema>) {
      try {
        const openOrders = await okxApiClient.getOpenOrders();
        return {
          content: [{ type: 'text', text: JSON.stringify(openOrders, null, 2) }],
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : 'An unknown error occurred';
        return {
          content: [{ type: 'text', text: JSON.stringify({ error: message }, null, 2) }],
        };
      }
    }
  • The input schema for the tool, which is empty indicating no input parameters are required.
    export const schema = {};
  • Metadata object that registers the tool with MCP, including name, description, and annotations.
    export const metadata = {
      name: 'get_open_orders',
      description: 'Get all currently open orders',
      annotations: {
        title: 'Get Open Orders',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
      },
    };
  • Supporting helper method in the OKX API client class that retrieves the list of open orders from the OKX exchange.
    async getOpenOrders() {
      try {
        const response = await client.getOrderList();
        return response.map((order) => ({
          orderId: order.ordId,
          symbol: order.instId,
          type: order.ordType,
          price: parseFloat(order.px),
          amount: parseFloat(order.sz),
          side: order.side,
          status: order.state,
        }));
      } catch (error) {
        console.error("Error fetching open orders:", error);
        throw error;
      }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare this as read-only, idempotent, and non-destructive, so the description adds minimal behavioral context beyond stating it retrieves data. It doesn't disclose additional traits like response format, pagination, rate limits, or authentication needs. With annotations covering safety, a baseline 3 is appropriate as the description adds little value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place by specifying 'all currently open orders' to clarify scope.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters, rich annotations (readOnlyHint, idempotentHint, destructiveHint), and no output schema, the description is adequate but minimal. It states what the tool does but doesn't explain return values or usage context. For a simple retrieval tool with good annotations, this is the minimum viable description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, and schema description coverage is 100% (though empty). The description doesn't need to explain parameters, so it meets expectations. A score of 4 reflects that the description appropriately focuses on purpose rather than parameter details for a parameterless tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('open orders'), making the purpose immediately understandable. It distinguishes from siblings like 'get_order_history' by specifying 'currently open' rather than historical data. However, it doesn't explicitly contrast with other siblings like 'get_positions' or 'get_account_summary', preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, timing considerations, or compare it to sibling tools like 'get_positions' or 'get_order_history'. The agent must infer usage context solely from the tool name and description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mbarinov/okx-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server