MCP trading assistant for the DhanHQ broker

MCP trading assistant for the DhanHQ broker

dhan-mcp-trades•bymayankthole

A set of MCP-run tools that let you place DhanHQ orders, manage portfolios, and check account details through natural language commands.

License: MIT License•Runtime: Awaiting documentation review•Category: finance crypto

WHAT IT DOES

  • •Places regular market and limit orders for buying and selling stocks by name.
  • •Supports super orders with target and stop-loss limits set as absolute values or percentages.
  • •Places after-market orders outside trading hours for execution on the next trading day.
  • •Retrieves holdings and positions and allows conversion between product types.

BEST FOR

  • •Traders who want to place DhanHQ buy and sell orders conversationally.
  • •Users who want to check holdings, positions, balance, and margin requirements.
  • •Traders placing orders with defined targets and stop-losses.

ABOUT DHAN-MCP-TRADES

MCP trading assistant for the DhanHQ broker is cataloged as an MCP server attributed to mayankthole. A set of MCP-run tools that let you place DhanHQ orders, manage portfolios, and check account details through natural language commands. It is categorized under finance crypto. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP trading assistant for the DhanHQ broker are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Can I place after-market orders?

Yes, after-market orders can be placed outside market hours to be executed on the next trading day.

Can the assistant convert between product types?

Yes, the holdings and positions tool allows conversion between product types.

What credentials are required to use it?

It requires a DhanHQ trading account along with DhanHQ API credentials, specifically a client ID and access token.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 844e2d061e8f · 采集于 2026-11-13 11:16:37 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

DhanHQ Trading Assistant

An AI-powered trading assistant for DhanHQ broker built with Model Context Protocol (MCP). This project enables natural language interaction with the DhanHQ trading platform, allowing you to place orders, check your portfolio, and manage your trading activities through simple conversational commands.

Features

Order Management

  • Regular orders (market/limit) via order_placement_tool.py
  • Super orders with target and stop-loss via super-order.py
  • After-market orders via after_market_order_tool.py
  • Access order book and trade history via order_book_tool.py

Portfolio Management

  • View holdings and positions via holdings_positions_tool.py
  • Convert positions (e.g., intraday to delivery)

Account Information

  • Check fund balance via fund_balance_tool.py
  • Calculate margin requirements via margin_calculator_tool.py

Setup and Installation

Prerequisites

  • Python 3.9 or higher
  • A DhanHQ trading account
  • DhanHQ API credentials (client ID and access token)

Installation

  1. Clone this repository

    git clone https://github.com/yourusername/dhan-broker-mcp-trades.git
    cd dhan-broker-mcp-trades
    
  2. Install required dependencies

    pip install -r requirements.txt
    
  3. Configure your credentials

    Edit the config.py file with your DhanHQ credentials:

    DHAN_CLIENT_ID = "your_client_id_here"
    DHAN_ACCESS_TOKEN = "your_access_token_here"
    DHAN_API_BASE_URL = "https://api.dhan.co/v2"
    
  4. Make sure your stocks.json file is populated with the stocks you want to trade

Running the Tools

Each tool can be run independently using the MCP CLI:

# To run the order placement tool
python -m mcp.server.cli dev order_placement_tool.py

# To run the portfolio server
python -m mcp.server.cli dev portfolio_server.py

# To run other tools
python -m mcp.server.cli dev <tool_filename>.py

Using the Assistant

📈 Expanded Example Trading Commands 🛒 Basic Order Placement

  • "Buy 10 shares of Infosys at market price"

  • "Sell 5 shares of TCS at limit price of ₹3500"

  • "Place a GTT order to buy 20 shares of HDFC Bank at ₹1450"

🎯 Orders with Stop-Loss and Targets

  • "Buy Reliance with 2% target and 1% stop-loss"

  • "Place a trailing stop-loss buy order for Tata Motors"

  • "Short sell Axis Bank with 5% target and 2% stop-loss"

🌙 After-Market & Scheduled Orders

  • "Create an after-market order to buy 100 shares of ONGC at ₹180"

  • "Schedule a buy order for Tech Mahindra tomorrow at 9:15 AM"

💼 Account Insights

  • "What are my current holdings?"

  • "Check my available balance and margin"

  • "Show me my open positions and unrealized profits"

📊 Portfolio & P&L Analysis

  • "Analyze my portfolio performance this month"

  • "Give me a P&L report on all banking sector trades"

  • "What was my best-performing stock in the last 30 days?"

🤖 Smart, Context-Aware Voice Commands

  • "Buy all PSU bank stocks"

  • "Short all private sector banks today"

  • "Go long on top 5 Nifty IT companies"

  • "Buy 2 shares of the company whose promoter's son just had a grand wedding"

  • "Tail the stop-loss of all chemical sector stocks"

📌 Contextual & Thematic Trading

  • "Buy all companies headquartered in Mumbai"

  • "Buy companies where promoter stake is increasing quarter-on-quarter"

  • "Short all companies dependent heavily on China for raw materials"

  • "Buy the top 5 companies based on market cap in India"

📈 Technical Signal-Based Trading

  • "Buy breakout stocks above 200-day moving average"

  • "Short stocks that broke below lower Bollinger Band"

  • "Buy stocks where RSI crossed above 70"

  • "Enter trades in mean reversion stocks with tight stop-loss"

🔍 Advanced Filtering & Signal Scanning

  • "Buy companies where profits grew more than 10% quarter-on-quarter"

  • "Buy stocks down more than 20% from all-time highs with high volume"

  • "Sell all stocks affected by global crude oil prices"

🔁 Pairs & Strategy-Based Trading

  • "Buy 3 shares of Reliance and sell 2 shares of Bharti Airtel"

  • "Do pair trading between ICICI Bank and Axis Bank"

Tool Descriptions

order_placement_tool.py

Handles basic order placement (market and limit orders). Supports buying and selling stocks by name.

super-order.py

Manages super orders with target and stop-loss limits that can be specified in absolute values or percentages.

after_market_order_tool.py

Places orders outside market hours to be executed on the next trading day.

fund_balance_tool.py

Retrieves account fund information and calculates margin requirements.

holdings_positions_tool.py

Retrieves holdings and positions information, allows conversion between product types.

margin_calculator_tool.py

Calculates margin requirements for potential trades.

order_book_tool.py

Provides access to order history, trade book, and enables order cancellation.

portfolio_server.py

Main interface for portfolio management.

Stock Information

The project uses a stocks.json file to map stock names to their security IDs. The file follows this structure:

{
  "companies": [
    {
      "stock_code": "1333",
      "company_name": "HDFC Bank Ltd.",
      "stock_name": "HDFCBANK",
      "description": "Description of the company..."
    }
  ]
}

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This software is for educational purposes only. Use at your own risk. The creators are not responsible for any financial losses incurred through the use of this software. Always verify all trading actions before execution.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP trading assistant for the DhanHQ broker from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/dhan-mcp-trades)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related finance crypto MCP Servers

Alternative and complementary servers in the same category

View all in finance crypto →
USA Spending MCP Server
usaspending-mcp-server•thsmale

A stateless streamable HTTP MCP server for interacting with the official source of government spending data.

Repository stats unavailable
Finance & Analytics
Fortnox MCP server — More AI
more-ai-chatgpt-claude-mcp-fortnox•amor3

A hosted, remote MCP server for Fortnox that lets AI assistants answer questions from a company's bookkeeping and propose changes for approval before writing them.

0
Finance & Analytics

OptimistFi is a read-only remote MCP server that provides perpetual futures market data, perps prop firm rules and pricing, and US equity investment research.

Repository stats unavailable
Finance & Analytics