MCP_TRADING_SERVER

yagyagoel1/MCP_TRADING_SERVER

3.2

If you are the rightful owner of MCP_TRADING_SERVER and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

An MCP server for executing and managing stock trades on Zerodha, providing a programmable interface for trading operations.

Tools
  1. placeBuyStockOrder

    Place a buy order for a given stock symbol and quantity.

  2. sellStocks

    Place a sell order for a given stock symbol and quantity.

  3. getOrders

    Fetch all orders from your Zerodha account.

  4. getHoldings

    Retrieve all current holdings from your Zerodha account.

  5. cancelOrder

    Cancel a specific order by order_id.

  6. add

    A sample utility tool to add two integers (demo/test purpose).

MCP Zerodha Trading Server

An MCP (Model Context Protocol) server for executing and managing stock trades on Zerodha. Exposes tools for placing orders, checking holdings, and managing trades through a programmable interface.


๐Ÿ“ฆ Features

โœ… Trading Operations via Zerodha

All tools are accessible using the MCP protocol through CLI or HTTP transport.

placeBuyStockOrder

Place a buy order for a given stock symbol and quantity.

Input: { "symbol": "TATAMOTORS", "quantity": 10 }
Output: "Order buy placed successfully ..."
sellStocks

Place a sell order for a given stock symbol and quantity.

Input: { "symbol": "RELIANCE", "quantity": 5 }
Output: "Order sell placed successfully ..."
getOrders

Fetch all orders from your Zerodha account.

Output: "Orders fetched successfully ..."
getHoldings

Retrieve all current holdings from your Zerodha account.

Output: "Holdings fetched successfully ..."
cancelOrder

Cancel a specific order by order_id.

Input: { "order_id": 123456 }
Output: "Cancelled the order successfully ..."
add

A sample utility tool to add two integers (demo/test purpose).

Input: { "a": 5, "b": 10 }
Output: 15

๐Ÿง  Backed By

  • Zerodha Kite Connect โ€” For real-time order placement, portfolio insights, and trading actions.
  • FastMCP โ€” Lightweight MCP server framework for tool-based workflows.

๐Ÿงช Quick Start

๐Ÿงฐ Requirements

  • Python 3.11+
  • MCP runtime (FastMCP)
  • Zerodha trading credentials setup in your environment (handled inside trade.py)

๐Ÿ“ฆ Setup

git clone https://github.com/yagyagoel1/MCP_TRADING_SERVER.git
cd MCP_TRADING_SERVER
pip install -r requirements.txt

Make sure your trade.py file has access to Zerodha API keys and session setup.


๐Ÿš€ Run the Server

CLI Mode (via stdio):

python mcp_trading_server.py

Or with uv and HTTP:

uv run mcp_trading_server.py --http

๐Ÿ“ค Calling Tools (Example via cURL)

curl -X POST http://localhost:8000/call-tool \
  -H "Content-Type: application/json" \
  -d '{
    "name": "getHoldings",
    "arguments": {}
  }'

๐Ÿ” Use Cases

  • Place buy/sell orders programmatically.
  • Cancel specific open orders via tool call.
  • Automate trading via MCP-compatible LLM agents or chat interfaces.
  • Integrate with bots or portfolio dashboards.

๐Ÿค Contributing

Feature requests, bug reports, and PRs are welcome! Just open an issue or contact me directly.


๐Ÿ“„ License

โ€” free to use and modify.