Skip to main content
Glama

get_order_by_correlation_id

Retrieve order status in DhanHQ trading by entering the correlation ID used during order placement. This tool provides order tracking through the DhanHQ MCP Server.

Instructions

Retrieves order status using the user-specified correlation ID. Requires authentication.

Input Schema

NameRequiredDescriptionDefault
correlationIdYesCorrelation ID used when placing the order

Input Schema (JSON Schema)

{ "properties": { "correlationId": { "description": "Correlation ID used when placing the order", "type": "string" } }, "required": [ "correlationId" ], "type": "object" }

Implementation Reference

  • Core implementation of the tool handler that performs an API GET request to retrieve the order details using the correlation ID.
    export async function getOrderByCorrelationID( correlationId: string ): Promise<OrderBook> { try { log(`Fetching order by correlation ID: ${correlationId}`); const response = await axios.get<OrderBook>( `https://api.dhan.co/v2/orders/external/${correlationId}`, { headers: getApiHeaders(), } ); log(`✓ Order retrieved. Order ID: ${response.data.orderId}`); 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 by correlation ID: ${errorMessage}`); throw new Error( `Failed to get order by correlation ID: ${errorMessage}` ); } }
  • MCP tool schema defining the name, description, and input parameters (correlationId) for the get_order_by_correlation_id tool.
    { name: 'get_order_by_correlation_id', description: 'Retrieves order status using the user-specified correlation ID. Requires authentication.', inputSchema: { type: 'object' as const, properties: { correlationId: { type: 'string', description: 'Correlation ID used when placing the order' }, }, required: ['correlationId'], }, },
  • src/index.ts:599-611 (registration)
    Registration and dispatching logic in the MCP call tool handler that invokes the getOrderByCorrelationID function upon tool invocation.
    case 'get_order_by_correlation_id': { console.error('[Tool] Executing: get_order_by_correlation_id'); const { correlationId } = args as Record<string, unknown>; const order = await getOrderByCorrelationID(correlationId as string); return { content: [ { type: 'text' as const, text: JSON.stringify(order, null, 2), }, ], }; }
  • TypeScript interface defining the structure of the OrderBook response returned by the handler.
    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