Skip to main content
Glama

get_order_book

Retrieve all orders placed during the day with their current status. This tool provides real-time order tracking and management for DhanHQ trading operations.

Instructions

Retrieves all orders placed during the day with their current status. Requires authentication.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "required": [], "type": "object" }

Implementation Reference

  • MCP tool handler case that executes get_order_book by calling the getOrderBook helper function and returns the orders as JSON text content.
    case 'get_order_book': { console.error('[Tool] Executing: get_order_book'); const orders = await getOrderBook(); return { content: [ { type: 'text' as const, text: JSON.stringify(orders, null, 2), }, ], }; }
  • Core helper function that performs the actual API call to retrieve the order book from Dhan API using axios GET request with authentication headers.
    export async function getOrderBook(): Promise<OrderBook[]> { try { log('Fetching order book...'); const response = await axios.get<OrderBook[]>( 'https://api.dhan.co/v2/orders', { headers: getApiHeaders(), } ); log(`✓ Order book retrieved. Total orders: ${response.data.length}`); return response.data; } catch (error) { const errorMessage = error instanceof axios.AxiosError ? `API Error: ${error.response?.status} - ${JSON.stringify(error.response?.data)}` : error instanceof Error ? error.message : 'Unknown error'; log(`✗ Failed to get order book: ${errorMessage}`); throw new Error(`Failed to get order book: ${errorMessage}`); }
  • src/index.ts:200-209 (registration)
    Tool registration object in the tools array used by ListToolsRequestHandler, defining name, description, and empty input schema.
    { name: 'get_order_book', description: 'Retrieves all orders placed during the day with their current status. Requires authentication.', inputSchema: { type: 'object' as const, properties: {}, required: [], }, },
  • TypeScript interface defining the structure of OrderBook objects returned by the getOrderBook function.
    export interface OrderBook { dhanClientId: string; orderId: string; correlationId: string; orderStatus: string; transactionType: string; exchangeSegment: string; productType: string; orderType: string; validity: string; securityId: string; quantity: number; price: number; triggerPrice?: number; disclosedQuantity?: number; createTime: string; algoId?: string; remainingQuantity: number; filledQty: number; updateTime?: string; }

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/harshitdynamite/DhanMCP'

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