zerodha-claude-mcp
Provides tools for interacting with the Zerodha trading platform, enabling portfolio management, position tracking, order execution, and profile access via the KiteConnect API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@zerodha-claude-mcpshow my current portfolio holdings"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
š Zerodha Trading MCP Server -- Claude
A powerful Model Context Protocol (MCP) server that enables AI models to interact seamlessly with the Zerodha trading platform
š Table of Contents
Related MCP server: Zerodha MCP Server
⨠Features
Feature | Description |
š Secure Authentication | Robust authentication with Zerodha API using official KiteConnect SDK |
š Portfolio Management | Real-time access to your complete portfolio holdings and valuations |
š Position Tracking | Monitor open positions with live P&L calculations |
š¹ Order Execution | Place buy/sell orders with market/limit options |
š¤ Profile Access | Retrieve comprehensive user profile and account information |
š Real-time Data | Live market data and portfolio updates |
š”ļø Type Safety | Built with TypeScript and Zod validation for reliability |
šÆ What is MCP?
The Model Context Protocol (MCP) is a standardized way for AI models to interact with external systems and APIs. This server acts as a bridge between AI assistants (like Claude) and the Zerodha trading platform, enabling natural language trading operations.
ā” Quick Start
Prerequisites
Before you begin, ensure you have:
ā Node.js (v16 or higher) - Download here
ā Zerodha Trading Account - Sign up here
ā Zerodha API Access - Get API credentials
ā Bun Runtime (recommended) - Install here
š¦ Installation
Step 1: Clone the Repository
# Clone the repository
git clone https://github.com/gamandeepsingh/zerodha-claude-mcp.git
# Navigate to the project directory
cd zerodha-claude-mcpStep 2: Install Dependencies
Choose your preferred package manager:
# Using npm
npm install
# Using bun (recommended for better performance)
bun install
# Using yarn
yarn installStep 3: Environment Setup
Create a .env file in the root directory:
# Copy the example environment file
cp .env.example .envAdd your Zerodha credentials to the .env file:
# Zerodha API Configuration
KITE_API_KEY=your_api_key_here
KITE_SECRET_KEY=your_secret_key_here
REQUEST_TOKEN=your_request_token_here
ACCESS_TOKEN=your_access_token_here
# Optional: Debug mode
DEBUG=falseš” Pro Tip: You can get your API credentials from the Kite Connect Developer Console
š³ Docker Installation (Alternative)
For a containerized setup, you can use Docker to run the MCP server:
Prerequisites for Docker
ā Docker - Install Docker
ā Docker Compose (optional, for easier management) - Usually included with Docker Desktop
Option 1: Using Docker Compose (Recommended)
Clone the repository:
git clone https://github.com/gamandeepsingh/zerodha-claude-mcp.git cd zerodha-claude-mcpCreate environment file:
# Create .env file with your credentials cp .env.example .envEdit the .env file with your Zerodha credentials:
KITE_API_KEY=your_api_key_here KITE_SECRET_KEY=your_secret_key_here REQUEST_TOKEN=your_request_token_here ACCESS_TOKEN=your_access_token_here DEBUG=falseBuild and run with Docker Compose:
# Build and start the container docker-compose up --build # Run in detached mode (background) docker-compose up -d --buildStop the container:
docker-compose down
Option 2: Using Docker directly
Build the Docker image:
docker build -t zerodha-claude-mcp .Run the container:
docker run -d \ --name zerodha-mcp \ -e KITE_API_KEY=your_api_key \ -e KITE_SECRET_KEY=your_secret_key \ -e REQUEST_TOKEN=your_request_token \ -e ACCESS_TOKEN=your_access_token \ zerodha-claude-mcp
Docker Management Commands
# View running containers
docker ps
# View logs
docker logs zerodha-mcp
# Stop the container
docker stop zerodha-mcp
# Remove the container
docker rm zerodha-mcp
# Remove the image
docker rmi zerodha-claude-mcpClaude Desktop Configuration with Docker
When using Docker, update your claude_desktop_config.json to point to the containerized version:
{
"mcpServers": {
"zerodha-trading": {
"command": "docker",
"args": ["exec", "-i", "zerodha-mcp", "bun", "run", "index.ts"],
"env": {
"KITE_API_KEY": "your_actual_api_key",
"KITE_SECRET_KEY": "your_actual_secret_key",
"REQUEST_TOKEN": "your_actual_request_token",
"ACCESS_TOKEN": "your_actual_access_token"
}
}
}
}ā ļø Note: Make sure your Docker container is running before starting Claude Desktop when using this configuration.
āļø Configuration
Getting Zerodha API Credentials
Sign up for a Kite Connect app at developers.kite.trade
Create a new app and note down your
api_keyandapi_secretGenerate tokens using the authentication flow
Add credentials to your
.envfile
Token Generation Process
# Step 1: Get the login URL
curl "https://kite.trade/connect/login?api_key=your_api_key&v=3"
# Step 2: After login, extract request_token from redirect URL
# Step 3: Generate access_token using the request_tokenš§ Claude Desktop Setup
To integrate this MCP server with Claude Desktop, follow these steps:
Step 1: Locate Claude Desktop Config
Find your claude_desktop_config.json file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Step 2: Add MCP Server Configuration
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"zerodha-trading": {
"command": "bun",
"args": ["run", "/absolute/path/to/your/index.ts"],
"env": {
"KITE_API_KEY": "your_actual_api_key",
"KITE_SECRET_KEY": "your_actual_secret_key",
"REQUEST_TOKEN": "your_actual_request_token",
"ACCESS_TOKEN": "your_actual_access_token"
}
}
}
}Step 3: Restart Claude Desktop
After saving the configuration, restart Claude Desktop to load the MCP server.
Alternative: Using Node.js
If you prefer Node.js over Bun:
{
"mcpServers": {
"zerodha-trading": {
"command": "node",
"args": ["--loader", "ts-node/esm", "/absolute/path/to/your/index.ts"],
"env": {
"KITE_API_KEY": "your_actual_api_key",
"KITE_SECRET_KEY": "your_actual_secret_key",
"REQUEST_TOKEN": "your_actual_request_token",
"ACCESS_TOKEN": "your_actual_access_token"
}
}
}
}ā ļø Important:
Replace
/absolute/path/to/your/index.tswith the actual path to your projectUse your real Zerodha API credentials
Ensure the path uses forward slashes even on Windows
š API Reference
The MCP server exposes the following tools for AI interaction:
š¤ Profile Operations
get-profile
Retrieves comprehensive user profile information.
// Usage in Claude
"Can you show me my Zerodha profile?"
// Returns
{
user_id: string,
user_name: string,
email: string,
user_type: string,
broker: string,
// ... additional profile data
}š° Portfolio & Positions
show-portfolio
Displays complete portfolio holdings with current valuations.
// Usage in Claude
"What's in my portfolio right now?"
// Returns detailed holdings with:
// - Stock symbols and quantities
// - Current market prices
// - P&L calculations
// - Total portfolio valueshow-positions
Shows all open positions with live P&L.
// Usage in Claude
"Show me my current trading positions"
// Returns active positions with:
// - Entry prices and quantities
// - Current market prices
// - Unrealized P&L
// - Position statusš Trading Operations
buy-stock
Places a buy order for specified stock and quantity.
// Parameters
{
stock: string, // Stock symbol (e.g., "RELIANCE", "TCS")
quantity: number // Number of shares to buy
}
// Usage in Claude
"Buy 10 shares of RELIANCE"
"Purchase 50 TCS stocks"sell-stock
Places a sell order for specified stock and quantity.
// Parameters
{
stock: string, // Stock symbol (e.g., "RELIANCE", "TCS")
quantity: number // Number of shares to sell
}
// Usage in Claude
"Sell 5 shares of HDFC Bank"
"Exit my position in Infosys"š Example Conversations
Here are some natural language examples you can use with Claude:
š£ļø "What's my current portfolio value?"
š£ļø "Buy 25 shares of ITC"
š£ļø "Show me all my losing positions"
š£ļø "What's my profile information?"
š£ļø "Sell half of my Wipro holdings"š ļø Development
Technology Stack
Technology | Purpose | Version |
TypeScript | Type-safe development | ^5.0.0 |
KiteConnect | Zerodha API integration | Latest |
MCP SDK | Model Context Protocol | Latest |
Zod | Runtime type validation | ^3.0.0 |
Bun | Fast runtime & package manager | ^1.0.0 |
Project Structure
zerodha-claude-mcp/
āāā š index.ts # MCP server entry point
āāā š trade.ts # Trading logic and API calls
āāā š package.json # Dependencies and scripts
āāā š tsconfig.json # TypeScript configuration
āāā š .env # Environment variables
āāā š README.md # Documentation
āāā š bun.lock # Lock file
āāā š³ Dockerfile # Docker image configuration
āāā š³ docker-compose.yml # Docker Compose setup
āāā š .dockerignore # Docker ignore rulesLocal Development
Clone and setup (if not already done):
git clone https://github.com/gamandeepsingh/zerodha-claude-mcp.git cd zerodha-claude-mcp bun installStart development server:
# Development mode with auto-reload bun run dev # Production mode bun run startRun tests (if available):
bun test
Adding New Features
To add new trading tools:
Define the tool in your MCP server
Add Zod schema for parameter validation
Implement handler using KiteConnect API
Update documentation in this README
Debugging
Enable debug mode by setting DEBUG=true in your .env file:
DEBUG=trueThis will provide detailed logging of API calls and responses.
š¤ Contributing
We welcome contributions! Here's how you can help:
Ways to Contribute
š Bug Reports: Found a bug? Open an issue
⨠Feature Requests: Have an idea? Start a discussion
š Documentation: Improve docs, add examples
š§ Code: Fix bugs, add features, improve performance
Development Workflow
Fork the repository
Create a feature branch:
git checkout -b feature/amazing-featureCommit your changes:
git commit -m 'Add amazing feature'Push to the branch:
git push origin feature/amazing-featureOpen a Pull Request
Code Standards
ā Use TypeScript for all new code
ā Follow existing code style
ā Add tests for new features
ā Update documentation
ā Ensure all tests pass
š License
This project is licensed under the MIT License - see the LICENSE file for full details.
MIT License Summary
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...ā ļø Disclaimer
IMPORTANT: This project is for educational and development purposes only.
Risk Warning
š Trading Risk: Trading in financial markets involves substantial risk of loss
š° Capital Risk: Never trade with money you cannot afford to lose
š Due Diligence: Always conduct your own research before making trading decisions
š¤ AI Limitations: AI-generated trading decisions should not be followed blindly
š Market Volatility: Past performance does not guarantee future results
Best Practices
Start Small: Test with small amounts first
Paper Trading: Use Zerodha's paper trading feature initially
Risk Management: Set stop-losses and position limits
Stay Informed: Keep up with market news and regulations
Continuous Learning: Educate yourself about trading strategies
Support
š Documentation: Check this README and inline code comments
š¬ Discussions: Join GitHub Discussions
š Issues: Report bugs via GitHub Issues
š§ Email: Contact the maintainers for specific questions
Made with ā¤ļø for the trading community
ā Star this repo if you find it useful! | š“ Fork it to customize for your needs
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceAn automated trading bot that interfaces with Zerodha to execute stock trades, manage positions, and access market information through natural language commands.Last updated1
- Flicense-qualityDmaintenanceEnables AI assistants to interact with the Zerodha trading platform for placing stock orders, viewing portfolio holdings, and managing mutual fund investments. Provides secure OAuth authentication and real-time trading capabilities through Zerodha's official API.Last updated1
- Alicense-qualityDmaintenanceEnables trading operations on Zerodha platform through natural language, supporting account management, order placement/modification, portfolio holdings, positions, margins, and stock news retrieval.Last updatedApache 2.0
- AlicenseBqualityDmaintenanceEnables trading and portfolio management on Zerodha Kite Connect through natural language. Supports placing orders, viewing positions/holdings, accessing real-time market data, and managing GTT orders.Last updated24MIT
Related MCP Connectors
Connect AI agents to bank accounts, transactions, balances, and investments.
Connect your Necton account to AI via Brazil's Open Finance: balances, statements, cards, investment
Connect your XP account to AI via Brazil's Open Finance: balances, statements, cards, investments. R
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/gamandeepsingh/zerodha-claude-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server