Skip to main content
Glama
harshitdynamite

DhanHQ MCP Server

modify_super_order

Modify pending or partially traded super orders by updating specific legs like entry, target, or stop loss with new parameters such as price, quantity, or order type.

Instructions

Modifies any leg of a pending or part-traded super order. Requires authentication.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orderIdYesSuper order ID to modify
dhanClientIdYesYour Dhan client ID
legNameYesWhich leg to modify
orderTypeYes
quantityNoNew quantity
priceNoNew price
targetPriceNoNew target price (for entry leg)
stopLossPriceNoNew stop loss price
trailingJumpNoNew trailing jump amount

Implementation Reference

  • The core handler function implementing the logic to modify a specific leg of a super order by sending a PUT request to the DhanHQ API endpoint.
    export async function modifySuperOrder(
      orderId: string,
      legName: string,
      request: Record<string, unknown>
    ): Promise<OrderResponse> {
      try {
        log(`Modifying super order: ${orderId}, leg: ${legName}`);
    
        const payload = {
          ...request,
          legName,
        };
    
        const response = await axios.put<OrderResponse>(
          `https://api.dhan.co/v2/super/orders/${orderId}`,
          payload,
          {
            headers: getApiHeaders(),
          }
        );
    
        log(
          `✓ Super order modified 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 modify super order: ${errorMessage}`);
        throw new Error(`Failed to modify super order: ${errorMessage}`);
      }
    }
  • Input schema defining the parameters, types, enums, descriptions, and required fields for the modify_super_order tool.
    inputSchema: {
      type: 'object' as const,
      properties: {
        orderId: { type: 'string', description: 'Super order ID to modify' },
        dhanClientId: { type: 'string', description: 'Your Dhan client ID' },
        legName: {
          type: 'string',
          enum: ['ENTRY_LEG', 'TARGET_LEG', 'STOP_LOSS_LEG'],
          description: 'Which leg to modify',
        },
        orderType: {
          type: 'string',
          enum: ['MARKET', 'LIMIT', 'STOP', 'STOP_LIMIT'],
        },
        quantity: { type: 'number', description: 'New quantity' },
        price: { type: 'number', description: 'New price' },
        targetPrice: { type: 'number', description: 'New target price (for entry leg)' },
        stopLossPrice: { type: 'number', description: 'New stop loss price' },
        trailingJump: { type: 'number', description: 'New trailing jump amount' },
      },
      required: ['orderId', 'dhanClientId', 'legName', 'orderType'],
    },
  • src/index.ts:302-328 (registration)
    The tool registration object that defines the name, description, and references the input schema; included in the tools list returned by ListTools.
    {
      name: 'modify_super_order',
      description:
        'Modifies any leg of a pending or part-traded super order. Requires authentication.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          orderId: { type: 'string', description: 'Super order ID to modify' },
          dhanClientId: { type: 'string', description: 'Your Dhan client ID' },
          legName: {
            type: 'string',
            enum: ['ENTRY_LEG', 'TARGET_LEG', 'STOP_LOSS_LEG'],
            description: 'Which leg to modify',
          },
          orderType: {
            type: 'string',
            enum: ['MARKET', 'LIMIT', 'STOP', 'STOP_LIMIT'],
          },
          quantity: { type: 'number', description: 'New quantity' },
          price: { type: 'number', description: 'New price' },
          targetPrice: { type: 'number', description: 'New target price (for entry leg)' },
          stopLossPrice: { type: 'number', description: 'New stop loss price' },
          trailingJump: { type: 'number', description: 'New trailing jump amount' },
        },
        required: ['orderId', 'dhanClientId', 'legName', 'orderType'],
      },
    },
  • src/index.ts:668-684 (registration)
    Registration of the tool execution handler within the MCP CallTool request switch statement, which parses arguments and invokes the core modifySuperOrder function.
    case 'modify_super_order': {
      console.error('[Tool] Executing: modify_super_order');
      const modSOArgs = args as Record<string, unknown>;
      const result = await modifySuperOrder(
        modSOArgs.orderId as string,
        modSOArgs.legName as string,
        modSOArgs
      );
      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 full burden. It mentions authentication requirement but lacks critical behavioral details: whether this is a destructive/mutative operation (implied by 'Modifies'), what happens on failure, rate limits, or response format. The description is too sparse for a tool with 9 parameters and no output schema.

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 brief (two sentences) and front-loaded with the core purpose. No wasted words, though it could be more structured (e.g., separating authentication note). It efficiently communicates the essential action but lacks depth.

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?

Given the complexity (9 parameters, mutation operation, no annotations, no output schema), the description is incomplete. It doesn't cover behavioral traits, error handling, or output expectations. For a tool that modifies financial orders, more context on safety and results is needed.

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?

Schema description coverage is high (89%), so the baseline is 3. The description doesn't add meaningful parameter semantics beyond what's in the schema—it doesn't explain relationships between parameters (e.g., 'price' relevance per 'orderType') or usage constraints. However, it doesn't need to compensate heavily given the comprehensive schema.

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 action ('Modifies'), the target resource ('any leg of a pending or part-traded super order'), and scope ('leg of a super order'). It distinguishes from sibling tools like 'modify_order' by specifying 'super order' context. However, it doesn't explicitly differentiate from 'cancel_super_order_leg' which handles a different modification type.

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 guidance: it mentions 'Requires authentication' but doesn't specify when to use this tool versus alternatives like 'modify_order' or 'cancel_super_order_leg'. No context about prerequisites beyond authentication, nor explicit when-not scenarios are provided.

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