Skip to main content
Glama
harshitdynamite

DhanHQ MCP Server

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

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

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;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds value by specifying authentication requirements and clarifying the scope ('all orders placed during the day'), but lacks details on rate limits, pagination, or error handling. This is adequate but has clear gaps for a read operation.

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

Conciseness4/5

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

The description is two short sentences with zero waste, front-loading the core purpose. It could be slightly more structured by explicitly stating it has no parameters, but overall it's efficient and well-sized for the tool's complexity.

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 no annotations, no output schema, and 0 parameters, the description is minimally adequate. It covers authentication and scope, but for a tool retrieving 'all orders', it lacks details on return format, data limits, or how 'day' is defined (e.g., timezone), leaving room for improvement.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add param info, which is fine here, but it doesn't explicitly state 'no parameters required' to earn a perfect score, leaving minor ambiguity.

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 verb ('Retrieves') and resource ('all orders placed during the day with their current status'), making the purpose understandable. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_order_by_id' or 'get_super_order_book', which prevents 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 mentions 'Requires authentication', which provides some context for when to use it, but offers no guidance on when to choose this tool over alternatives like 'get_order_by_id' or 'get_super_order_book'. There are no explicit when/when-not instructions or named alternatives.

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

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