Skip to main content
Glama
mbarinov

OKX MCP Server

by mbarinov

get_open_orders

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; }

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