Skip to main content
Glama
harshitdynamite

DhanHQ MCP Server

get_login_instructions

Retrieve browser-based login URL and instructions for DhanHQ trading API authentication. Complete the OAuth login manually by opening the provided URL.

Instructions

Gets the login instructions and URL for Step 2 (browser-based login). You must complete this step manually by opening the URL in your browser.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
consentAppIdNoThe consentAppId from Step 1 (start_authentication). If not provided, the latest one from the current session will be used.

Implementation Reference

  • MCP CallToolRequest handler case that implements the get_login_instructions tool. Handles input arguments, retrieves consentAppId from state if not provided, calls the helper function, and formats the response.
    case 'get_login_instructions': {
      console.error('[Tool] Executing: get_login_instructions');
      const authState = getAuthState();
      const consentAppId =
        (args as Record<string, unknown>).consentAppId ||
        authState.consentAppId;
    
      if (!consentAppId) {
        throw new Error(
          'No consentAppId available. Please run start_authentication first.'
        );
      }
    
      const instructions = getStep2Instructions(consentAppId as string);
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(instructions, null, 2),
          },
        ],
      };
    }
  • Tool metadata including name, description, and input schema definition used for tool discovery and validation.
    {
      name: 'get_login_instructions',
      description:
        'Gets the login instructions and URL for Step 2 (browser-based login). You must complete this step manually by opening the URL in your browser.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          consentAppId: {
            type: 'string' as const,
            description:
              'The consentAppId from Step 1 (start_authentication). If not provided, the latest one from the current session will be used.',
          },
        },
        required: [],
      },
    },
  • src/index.ts:359-361 (registration)
    Registers the tool list (including get_login_instructions) with the MCP server via ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools,
    }));
  • Helper function that constructs the login URL and multi-step instructions for browser-based authentication step 2.
    export function getStep2Instructions(
      consentAppId: string
    ): { loginUrl: string; instruction: string } {
      const loginUrl = `${AUTH_BASE_URL}/login/consentApp-login?consentAppId=${consentAppId}`;
    
      return {
        loginUrl,
        instruction: `1. Open this URL in your browser: ${loginUrl}
    2. Log in with your Dhan credentials
    3. Complete 2FA verification (OTP/PIN/Password)
    4. You will be redirected to: ${dhanConfig.redirectUrl}?tokenId=<TOKEN_ID>
    5. Copy the tokenId from the URL and use it in the 'consumeConsent' tool`,
      };
    }
Behavior4/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 effectively describes key behavioral traits: this is a read operation ('Gets'), it requires manual user action ('complete this step manually'), and it's part of a multi-step authentication flow. However, it doesn't mention potential errors, rate limits, or session dependencies beyond the optional parameter.

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

Conciseness5/5

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

The description is perfectly concise and front-loaded: the first sentence states the core purpose, and the second sentence provides essential usage guidance. Every word earns its place with no redundancy or unnecessary elaboration.

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

Completeness4/5

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

Given the tool's moderate complexity (part of an authentication flow with manual steps) and lack of annotations/output schema, the description is mostly complete. It covers purpose, usage context, and behavioral expectations well, but could benefit from mentioning what happens if the consentAppId is invalid or if no session exists.

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?

With 100% schema description coverage for the single parameter, the baseline is 3. The description adds value by contextualizing the parameter's role in the authentication flow ('Step 2') and implying its relationship to 'Step 1 (start_authentication),' though it doesn't explicitly name the parameter or provide additional syntax details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 with specific verbs ('Gets the login instructions and URL') and resource ('for Step 2 (browser-based login)'), distinguishing it from sibling tools like 'start_authentication' or 'complete_authentication' by focusing on the intermediate login step.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool ('for Step 2') and provides crucial usage context: 'You must complete this step manually by opening the URL in your browser,' which clearly differentiates it from automated authentication tools and sets user expectations.

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