Skip to main content
Glama
harshitdynamite

DhanHQ MCP Server

place_super_order

Execute a smart trading order with entry, target, and stop-loss legs in one action. Supports trailing stop loss for automated risk management.

Instructions

Places a smart super order combining entry, target, and stop-loss legs. Supports trailing stop loss. Requires authentication.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dhanClientIdYesYour Dhan client ID
correlationIdYesUnique correlation ID for order tracking
transactionTypeYes
exchangeSegmentYese.g., NSE_EQ, BSE_EQ
productTypeYes
orderTypeYes
securityIdYesSecurity ID for the instrument
quantityYesQuantity for entry leg
priceYesEntry price
targetPriceYesTarget price for profit booking
stopLossPriceYesStop loss price
trailingJumpNoTrailing stop loss jump amount (optional)

Implementation Reference

  • The handler function that implements the core logic for placing a super order via the Dhan API. It makes a POST request to the super orders endpoint with the provided request parameters.
    export async function placeSuperOrder(
      request: PlaceSuperOrderRequest
    ): Promise<OrderResponse> {
      try {
        log(
          `Placing super order: ${request.transactionType} ${request.quantity} shares with target ${request.targetPrice} and SL ${request.stopLossPrice}`
        );
    
        const response = await axios.post<OrderResponse>(
          'https://api.dhan.co/v2/super/orders',
          request,
          {
            headers: getApiHeaders(),
          }
        );
    
        log(
          `✓ Super order placed successfully. 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 place super order: ${errorMessage}`);
        throw new Error(`Failed to place super order: ${errorMessage}`);
      }
    }
  • Interface defining the input parameters and types for the placeSuperOrder handler, used for type safety and validation.
    export interface PlaceSuperOrderRequest {
      dhanClientId: string;
      correlationId: string;
      transactionType: 'BUY' | 'SELL';
      exchangeSegment: string;
      productType: 'CNC' | 'INTRADAY' | 'MARGIN' | 'MTF' | 'CO' | 'BO';
      orderType: 'LIMIT' | 'MARKET' | 'STOP_LOSS' | 'STOP_LOSS_MARKET';
      securityId: string;
      quantity: number;
      price: number;
      targetPrice: number;
      stopLossPrice: number;
      trailingJump?: number;
    }
  • src/index.ts:258-301 (registration)
    MCP tool registration including name, description, and input schema for listTools response.
    {
      name: 'place_super_order',
      description:
        'Places a smart super order combining entry, target, and stop-loss legs. Supports trailing stop loss. Requires authentication.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          dhanClientId: { type: 'string', description: 'Your Dhan client ID' },
          correlationId: { type: 'string', description: 'Unique correlation ID for order tracking' },
          transactionType: { type: 'string', enum: ['BUY', 'SELL'] },
          exchangeSegment: { type: 'string', description: 'e.g., NSE_EQ, BSE_EQ' },
          productType: {
            type: 'string',
            enum: ['CNC', 'INTRADAY', 'MARGIN', 'MTF', 'CO', 'BO'],
          },
          orderType: {
            type: 'string',
            enum: ['MARKET', 'LIMIT', 'STOP_LOSS', 'STOP_LOSS_MARKET'],
          },
          securityId: { type: 'string', description: 'Security ID for the instrument' },
          quantity: { type: 'number', description: 'Quantity for entry leg' },
          price: { type: 'number', description: 'Entry price' },
          targetPrice: { type: 'number', description: 'Target price for profit booking' },
          stopLossPrice: { type: 'number', description: 'Stop loss price' },
          trailingJump: {
            type: 'number',
            description: 'Trailing stop loss jump amount (optional)',
          },
        },
        required: [
          'dhanClientId',
          'correlationId',
          'transactionType',
          'exchangeSegment',
          'productType',
          'orderType',
          'securityId',
          'quantity',
          'price',
          'targetPrice',
          'stopLossPrice',
        ],
      },
    },
  • src/index.ts:641-666 (registration)
    Dispatcher case in CallToolRequest handler that maps 'place_super_order' tool calls to the placeSuperOrder function.
    case 'place_super_order': {
      console.error('[Tool] Executing: place_super_order');
      const soArgs = args as Record<string, unknown>;
      const result = await placeSuperOrder({
        dhanClientId: soArgs.dhanClientId as string,
        correlationId: soArgs.correlationId as string,
        transactionType: soArgs.transactionType as 'BUY' | 'SELL',
        exchangeSegment: soArgs.exchangeSegment as string,
        productType: soArgs.productType as 'CNC' | 'INTRADAY' | 'MARGIN' | 'MTF' | 'CO' | 'BO',
        orderType: soArgs.orderType as 'LIMIT' | 'MARKET' | 'STOP_LOSS' | 'STOP_LOSS_MARKET',
        securityId: soArgs.securityId as string,
        quantity: soArgs.quantity as number,
        price: soArgs.price as number,
        targetPrice: soArgs.targetPrice as number,
        stopLossPrice: soArgs.stopLossPrice as number,
        trailingJump: soArgs.trailingJump as number | undefined,
      });
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
Behavior2/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 mentions authentication requirements and the multi-leg nature of the order, but fails to describe critical behavioral aspects: whether this is a read-only or destructive operation, potential side effects, error handling, rate limits, or what happens when the order executes. For a complex trading tool with 12 parameters, this represents a significant transparency gap.

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 appropriately concise at two sentences. The first sentence efficiently states the core functionality, while the second adds the authentication requirement. There's no wasted verbiage, and the information is front-loaded with the primary purpose. The structure could be slightly improved by explicitly mentioning it's for trading/financial orders, but overall it's well-structured.

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

Completeness2/5

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

For a complex trading tool with 12 parameters, no annotations, and no output schema, the description is insufficiently complete. It lacks information about return values, error conditions, order execution behavior, confirmation mechanisms, and how the multi-leg order actually functions. The agent would struggle to use this tool effectively without additional context about what happens after placement and how to interpret results.

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

Parameters3/5

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

The description adds minimal parameter semantics beyond what the schema provides. It mentions 'combining entry, target, and stop-loss legs' and 'Supports trailing stop loss', which helps contextualize parameters like 'targetPrice', 'stopLossPrice', and 'trailingJump'. However, with 75% schema description coverage already documenting most parameters, the description doesn't significantly enhance understanding of individual parameters or their interactions.

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 tool's purpose: 'Places a smart super order combining entry, target, and stop-loss legs. Supports trailing stop loss.' It specifies the verb ('places'), resource ('smart super order'), and key functionality (multi-leg order with trailing stop). However, it doesn't explicitly differentiate from sibling tools like 'place_order' or 'modify_super_order', 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 provides minimal usage guidance. It states 'Requires authentication' as a prerequisite, but offers no explicit guidance on when to use this tool versus alternatives like 'place_order' or 'modify_super_order'. There's no mention of specific scenarios, constraints, or comparison with sibling tools, leaving the agent with insufficient context for proper tool selection.

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