Skip to main content
Glama
harshitdynamite

DhanHQ MCP Server

get_fund_limit

Retrieve account fund limits including available balance, margins, collateral, and withdrawable amounts for trading operations on DhanHQ.

Instructions

Retrieves account fund limit information including available balance, margins, collateral, and withdrawable balance. Requires authentication.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the get_fund_limit tool logic by calling the Dhan API to retrieve account fund limits using the current access token.
    export async function getFundLimit(): Promise<FundLimit> {
      try {
        const accessToken = getAccessToken();
        if (!accessToken) {
          throw new Error('No valid access token. Please authenticate first.');
        }
    
        log('Fetching fund limit...');
    
        const response = await axios.get<FundLimit>(
          'https://api.dhan.co/v2/fundlimit',
          {
            headers: {
              'Content-Type': 'application/json',
              'access-token': accessToken,
            },
          }
        );
    
        log(`✓ Fund limit retrieved for client ${response.data.dhanClientId}`);
        log(`Available Balance: ${response.data.availabelBalance}`);
    
        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 fund limit: ${errorMessage}`);
        throw new Error(`Failed to get fund limit: ${errorMessage}`);
      }
    }
  • MCP tool schema registration defining the name, description, and input schema (no parameters required) for the get_fund_limit tool.
      name: 'get_fund_limit',
      description:
        'Retrieves account fund limit information including available balance, margins, collateral, and withdrawable balance. Requires authentication.',
      inputSchema: {
        type: 'object' as const,
        properties: {},
        required: [],
      },
    },
  • src/index.ts:491-502 (registration)
    Tool dispatch/registration in the MCP callTool handler switch statement, which invokes the getFundLimit function and formats the response.
    case 'get_fund_limit': {
      console.error('[Tool] Executing: get_fund_limit');
      const fundLimit = await getFundLimit();
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(fundLimit, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining the structure of the FundLimit response object used by the getFundLimit handler.
    export interface FundLimit {
      dhanClientId: string;
      availabelBalance: number;
      sodLimit: number;
      collateralAmount: number;
      receiveableAmount: number;
      utilizedAmount: number;
      blockedPayoutAmount: number;
      withdrawableBalance: number;
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by explicitly stating 'Requires authentication' - a crucial behavioral constraint. It also implies read-only behavior through 'Retrieves' and specifies the scope of returned financial data. However, it doesn't mention potential rate limits, error conditions, or data freshness.

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?

Two sentences with zero waste - the first sentence clearly states purpose and return data, the second adds the critical authentication requirement. Every word earns its place, and the most important information (what it retrieves) is front-loaded.

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?

For a 0-parameter tool with no output schema, the description adequately covers what data is returned and authentication needs. However, it doesn't specify the return format/structure or potential error scenarios, which would be helpful given the financial nature of the data. The absence of annotations means the description should ideally cover more behavioral aspects.

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 tool has 0 parameters with 100% schema coverage, so the baseline is 4. The description appropriately doesn't waste space discussing non-existent parameters and focuses on what the tool returns instead.

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 verb ('Retrieves') and resource ('account fund limit information'), and specifies the exact data fields returned ('available balance, margins, collateral, and withdrawable balance'). It distinguishes itself from siblings like get_order_book or get_trade_book by focusing on financial limits rather than order/trade data.

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 no guidance on when to use this tool versus alternatives. While it mentions 'Requires authentication,' it doesn't specify prerequisites like checking auth_status first or differentiate from other financial data tools. No explicit when/when-not scenarios or sibling tool comparisons are included.

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