sriejan/zerodha-trade-mcp
If you are the rightful owner of zerodha-trade-mcp 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.
A Model Context Protocol (MCP) server that enables AI models to interact with the Zerodha trading platform, providing tools for executing trades, viewing portfolios, and managing positions through a standardized interface.
Get Profile
Retrieves the user's profile information from Zerodha.
Buy Stock
Places a buy order for the specified stock and quantity.
Sell Stock
Places a sell order for the specified stock and quantity.
Show Portfolio
Displays current holdings and their values.
Show Positions
Shows all open positions with P&L information.
Zerodha Trading MCP
A Model Context Protocol (MCP) server that enables AI models to interact with the Zerodha trading platform. This project provides a set of tools for executing trades, viewing portfolio, and managing positions on Zerodha through a standardized interface.
Features
- š Secure authentication with Zerodha API
- š View portfolio holdings
- š Check open positions
- š¹ Place buy/sell orders
- š¤ Access user profile information
- š¤ NEW: Automated paper trading with Background Agents
- š± NEW: Smart auto-trigger system for continuous monitoring
Prerequisites
- Node.js (v14 or higher)
- Zerodha Trading Account
- API credentials from Zerodha
- Git repository initialized
Installation
- Clone the repository:
git clone https://github.com/shubhamprajapati7748/zerodha-trade-mcp.git
cd zerodha-trade-mcp
- Install dependencies:
npm install
- Create a
.env
file in the root directory with your Zerodha credentials:
KITE_API_KEY=your_api_key
KITE_SECRET_KEY=your_secret_key
REQUEST_TOKEN=your_request_token
ACCESS_TOKEN=your_access_token
Automated Trading Setup
Background Agents (Recommended)
-
Initialize Git repository (required):
git init git config user.name "Your Name" git config user.email "your.email@example.com" git add . git commit -m "Initial commit"
-
Configure environment (
.cursor/environment.json
already created):- Auto-trading monitor
- Market data stream
- Continuous portfolio updates
-
Start Background Agent:
- Press Ctrl+E in Cursor IDE
- Submit prompt: "Monitor my ā¹1 lakh paper trading portfolio continuously, execute light-risk scalping trades, analyze market data every 30 seconds, and provide updates until market close"
Smart Auto-Trigger System
node smart_auto_trigger.cjs
- Copies trading commands to clipboard every 45 seconds
- Audio and visual alerts
- Windows notifications
- Just paste (Ctrl+V) in Cursor chat
Browser-Based Monitor
Open auto_chat_trigger.html
in your browser:
- 30-second interval reminders
- Auto-clipboard functionality
- Market hours detection
- Audio alerts
Claude Desktop MCP Configuration
To use this MCP server with Claude Desktop, you need to configure the mcp server details. Here's how to set it up:
- Open
claude_desktop_config.json
in your project root - Add the following configuration:
{
"mcpServers": {
"tradeStocks": {
"command": "/opt/homebrew/bin/bun",
"args": [
"/path/to/your/index.ts"
],
"env": {
"KITE_API_KEY": "your_api_key",
"KITE_SECRET_KEY": "your_secret_key",
"REQUEST_TOKEN": "your_request_token",
"ACCESS_TOKEN": "your_access_token"
}
}
}
}
Make sure to:
- Update the path to your
index.ts
file - Replace the environment variables with your actual Zerodha credentials
Paper Trading Strategy
Light Risk Scalping Approach
- Starting Capital: ā¹1,00,000 (paper money)
- Risk per Trade: Maximum 0.5%
- Target: 0.5-1% quick profits
- Strategy: High-frequency monitoring with tight stops
- Focus: Quality stocks (ICICI, TCS, ITC, etc.)
Current Positions Example
š° Cash: ā¹1,240
š ICICI BANK: 700 shares @ ā¹1,426.8 (+ā¹700 profit)
šÆ Target: ā¹1,435 | Stop: ā¹1,420
Usage
The MCP server provides the following tools:
Get Profile
get-profile
Retrieves the user's profile information from Zerodha.
Buy Stock
buy-stock {stock: string, quantity: number}
Places a buy order for the specified stock and quantity.
Sell Stock
sell-stock {stock: string, quantity: number}
Places a sell order for the specified stock and quantity.
Show Portfolio
show-portfolio
Displays current holdings and their values.
Show Positions
show-positions
Shows all open positions with P&L information.
Files Structure
āāā index.ts # Main MCP server
āāā trade.ts # Trading functions
āāā auto-trader.js # Standalone auto-trader
āāā simple_auto_trader.py # Python auto-trader
āāā smart_auto_trigger.cjs # Smart reminder system
āāā auto_chat_trigger.html # Browser-based monitor
āāā .cursor/
ā āāā environment.json # Background Agent config
āāā cursor-mcp-config.json # MCP configuration
āāā README.md # This file
Security
- All trading credentials are stored securely in environment variables
- Paper trading mode recommended for testing
- Real money trading requires careful risk management
- Background Agents run in isolated environments
Troubleshooting
Git Repository Required
git init
git config user.name "Your Name"
git config user.email "your.email@example.com"
ES Module Errors
Use .cjs
extension for CommonJS modules or update package.json
type setting.
MCP Connection Issues
Check cursor-mcp-config.json
configuration and restart Cursor IDE.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- 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 and testing purposes only. Trading involves risk of financial loss. The authors are not responsible for any financial losses incurred through the use of this software. Always test with paper trading before using real money.
Support
For issues and questions:
- Create an issue on GitHub
- Check the troubleshooting section
- Review the MCP documentation
Happy Trading! šš¹