Zerodha MCP server

Integrates with Zerodha trading platform to enable authentication, portfolio management, order placement, market data retrieval, and SIP setup for automated trading workflows.
Back to servers
Provider
aptro
Release date
Mar 17, 2025
Language
Python
Stats
35 stars

The Zerodha MCP Integration allows you to interact with your Zerodha trading account directly through Claude AI using the Multi-Cloud Plugin (MCP) framework. This integration enables you to check your portfolio, place orders, manage mutual funds, and more through simple conversational prompts.

Installation

Using Smithery (Recommended)

Install zerodha-mcp for Claude Desktop automatically:

npx -y @smithery/cli install @aptro/zerodha-mcp --client claude

Manual Setup

Step 1: Create a Zerodha Developer Account

  1. Sign up for a developer account at Kite Connect
  2. Log in to your account

Step 2: Create a New App

  1. Navigate to the "Apps" section in your Kite Developer dashboard
  2. Click on "Create a new app"
  3. Fill in the required details:
    • App Name: Choose a descriptive name (e.g., "Claude Zerodha Integration")
    • App Category: Select "Personal" or appropriate category
    • Redirect URL: Set to http://127.0.0.1:5000/zerodha/auth/redirect
    • Description: Brief description of your application

Step 3: Get API Credentials

After creating your app, you'll receive:

  • API Key (Consumer Key)
  • API Secret (Consumer Secret)

Step 4: Configure Environment Variables

Create a .env file in the root directory with:

KITE_API_KEY=your_api_key_here
KITE_API_SECRET=your_api_secret_here

Step 5: Install Dependencies

uv pip install kiteconnect fastapi uvicorn python-dotenv httpx

Step 6: Install MCP Config on Claude Desktop

mcp install main.py

Usage

Authentication

To check login status or authenticate:

Can you please check if I'm logged into my Zerodha account and authenticate if needed?

Trading Functions

Stocks and General Trading

  • Check margins:

    What are my current margins on Zerodha?
    
  • View holdings:

    Show me my current holdings on Zerodha
    
  • Check positions:

    What positions do I currently have open on Zerodha?
    
  • Get quotes:

    What's the current price of RELIANCE and INFY on NSE?
    
  • Place an order:

    Place a buy order for 10 shares of INFY at market price on NSE
    
  • Get historical data:

    Can you show me the historical price data for SBIN for the last 30 days?
    

Mutual Funds

  • View mutual fund holdings:

    Show me my mutual fund holdings on Zerodha
    
  • Get mutual fund orders:

    List all my mutual fund orders on Zerodha
    
  • Place a mutual fund order:

    Place a buy order for ₹5000 in the mutual fund with symbol INF090I01239
    
  • Cancel a mutual fund order:

    Cancel my mutual fund order with order ID 123456789
    
  • View SIPs:

    Show all my active SIPs on Zerodha
    
  • Create a new SIP:

    Set up a monthly SIP of ₹2000 for the fund with symbol INF090I01239 for 12 installments
    
  • Modify an existing SIP:

    Change my SIP with ID 987654321 to ₹3000 per month
    
  • Cancel a SIP:

    Cancel my SIP with ID 987654321
    
  • Browse available mutual funds:

    Show me a list of available mutual funds on Zerodha
    

Authentication Flow

When using any Zerodha functionality for the first time:

  1. A local server starts on port 5000
  2. A browser window opens for Zerodha login
  3. After successful login, the access token is stored for future sessions

Your session remains active until the token expires (typically 24 hours), after which Claude will automatically initiate the login flow again.

Troubleshooting

  • For authentication issues, remove the .tokens file and restart authentication
  • Verify Zerodha credentials in the .env file
  • Ensure port 5000 is not being used by another application
  • Check Zerodha's API status at status.zerodha.com

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later