Trading Bot with MCP
A trading bot built using the Model Context Protocol (MCP) that provides a set of tools for automated trading operations. This bot offers various functionalities for trading stocks, managing positions, and accessing market information.
Features
-
Stock Trading
- Buy stocks with specified quantity
- Sell stocks with specified quantity
- Cancel existing orders
-
Market Information
- Get real-time quotes for stocks
- Check market status
- View order history
-
Account Management
- View current positions
- Check account balance
- Monitor order status
Prerequisites
- Node.js (Latest LTS version recommended)
- npm or yarn package manager
- Trading account credentials (configured in
mcp-conf.json)
Installation
- Clone the repository:
git clone https://github.com/AmritanshuPrashar/zerodha-mcp.git
cd mcp-zerodha
- Install dependencies:
npm install
- Configure your trading credentials:
- Create a
mcp-conf.jsonfile in the root directory - Add your trading platform credentials and configuration
- Create a
Configuration
The mcp-conf.json file should contain the following structure:
{
"buyStock": {
"prompt": "Your buy stock prompt"
},
"sellStock": {
"prompt": "Your sell stock prompt"
},
"getPosition": {
"prompt": "Your get position prompt"
},
"getMarketStatus": {
"prompt": "Your market status prompt"
},
"getQuote": {
"prompt": "Your quote prompt"
},
"getOrderHistory": {
"prompt": "Your order history prompt"
},
"cancelOrder": {
"prompt": "Your cancel order prompt"
},
"getAccountBalance": {
"prompt": "Your account balance prompt"
}
}
Usage
The bot provides several tools that can be used through the MCP interface:
buy-stock: Place buy orders for stockssell-stock: Place sell orders for stocksget-positions: View current positionsget-market-status: Check market statusget-quote: Get real-time quotesget-order-history: View order historycancel-order: Cancel existing ordersget-account-balance: Check account balance
Development
The project is built using:
- TypeScript
- Model Context Protocol (MCP) SDK
- Zod for schema validation
License
[Add your chosen license here]
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Disclaimer
This trading bot is for educational purposes only. Use at your own risk. Always test thoroughly before using with real money.
