home / mcp / zerodha mcp server

Zerodha MCP Server

Provides Zerodha trading actions via MCP to interact with Kite Connect accounts through Claude.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "aptro-zerodha-mcp": {
      "command": "mcp",
      "args": [
        "install",
        "main.py"
      ],
      "env": {
        "KITE_API_KEY": "your_api_key_here",
        "KITE_API_SECRET": "your_api_secret_here"
      }
    }
  }
}

This MCP (Multi-Cloud Plugin) lets you access Zerodha trading capabilities directly from Claude. You install a local plugin that talks to Zerodha’s Kite Connect API and exposes trading actions to your Claude conversations, so you can check margins, view holdings, place orders, and manage mutual funds from a single AI interface.

How to use

Once you have the MCP configured, you can interact with Zerodha through Claude to perform common trading tasks. Authentication starts the first time you use Zerodha features, opening a local login flow and storing tokens for future sessions. Your session remains valid until the access token expires, at which point Claude will re-run the login flow automatically.

Practical actions you can perform include checking account margins, viewing portfolio holdings, checking current positions, getting live quotes for symbols, placing orders, and retrieving historical price data. You can also manage mutual funds by listing orders, placing or canceling SIPs, and viewing holdings. Each action maps to a specific tool available to Claude, so you can issue natural-language requests like “What are my margins on Zerodha?” or “Show my current holdings.”.

A typical authentication flow begins by opening a local server on port 5000 to start Zerodha login, after which the access token is saved for subsequent uses. The token cadence follows Zerodha’s authorization lifecycle, renewing as needed without manual re-authentication on every run.

How to install

mcp install main.py

Prerequisites you need before installing the MCP include Python and common development tooling. Ensure you have Python installed and access to terminal/command line to run the MCP install command shown above.

Additional sections

Configuration and environment variables to connect Zerodha are stored locally. You will create a .env file in your project root and add your Kite API credentials.

Important environment variables shown in the setup are:

- KITE_API_KEY: your Kite API key (Consumer Key)

- KITE_API_SECRET: your Kite API secret (Consumer Secret)

These credentials are stored in your local environment and are not transmitted to Claude or third parties.

Troubleshooting tips include verifying your .env values, ensuring port 5000 is free, and restarting the authentication flow if you encounter issues. If authentication fails, you can remove the .tokens file and re-run the login process.

Security Notes

Your Zerodha API credentials are stored only in your local .env file. Access tokens are kept in the .tokens file within your project directory. No credentials are sent to Claude or any external service; all authentication occurs directly with Zerodha.

Available tools

check_and_authenticate

Verifies authentication status and initiates login if needed

initiate_login

Starts the Zerodha login flow

get_request_token

Retrieves the request token after login

get_holdings

Retrieves portfolio holdings

get_positions

Gets current positions

get_margins

Retrieves account margins

place_order

Places a trading order

get_quote

Gets quotes for specified symbols

get_historical_data

Retrieves historical price data

get_mf_orders

Retrieves mutual fund orders

place_mf_order

Places a mutual fund order

cancel_mf_order

Cancels a mutual fund order

get_mf_instruments

Gets available mutual fund instruments

get_mf_holdings

Retrieves mutual fund holdings

get_mf_sips

Gets active SIPs

place_mf_sip

Creates a new SIP

modify_mf_sip

Modifies an existing SIP

cancel_mf_sip

Cancels a SIP