
kite mcp
一个基于 TypeScript 的 Zerodha Kite Connect API 集成服务,用于自动化交易和投资组合管理。
Repository Info
About This Server
一个基于 TypeScript 的 Zerodha Kite Connect API 集成服务,用于自动化交易和投资组合管理。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
🚀 Kite Trading API Service
A robust, production-ready TypeScript service that integrates with Zerodha's Kite Connect API for automated trading and portfolio management. Built with modern best practices, clean architecture, and comprehensive documentation.
Features
- OAuth-based authentication with Kite Connect
- Real-time portfolio tracking
- Stock price monitoring with alerts
- Portfolio performance analytics
- Order placement capabilities
- RESTful API endpoints
Prerequisites
- Node.js (v14 or higher)
- npm (Node Package Manager)
- Zerodha Kite Connect API credentials
- API Key
- API Secret
- You can obtain these from Kite Connect Developer Portal
Installation
- Clone the repository:
git clone <repository-url>
cd kite-mcp
- Install dependencies:
npm install
- Create a
config.jsonfile in the root directory with your Kite credentials:
{
"apiKey": "your_api_key",
"apiSecret": "your_api_secret"
}
Running the Service
Start the service using:
npm start
Or for development with auto-reload:
npm run dev
The service will run on port 3000 by default.
Security Notes
- Keep your
config.jsonfile secure and never commit it to version control - Add
config.jsonto your.gitignorefile - For production deployments, consider using a secure configuration management system
API Endpoints
Authentication
Login
- GET
/login - Returns a Kite Connect login URL
- Response:
{ loginUrl: string }
Callback
- GET
/callback - Handles OAuth callback from Kite Connect
- Query Parameters:
request_token - Response:
{ accessToken: string }
Portfolio Management
Get Profile
- GET
/profile - Returns user profile information
- Requires authentication
Get Portfolio Summary
- GET
/portfolio - Returns current portfolio summary including:
- Total value
- Today's P&L
- Total P&L
- Individual holdings
Get Portfolio Performance
- GET
/portfolio/performance - Returns detailed portfolio analysis including:
- Current value
- Performance metrics (daily, weekly, monthly, yearly)
- Top gainers and losers
Market Data
Get Stock Quotes
- GET
/quote?symbols=SYMBOL1,SYMBOL2 - Returns current market quotes for specified symbols
- Query Parameters:
symbols(comma-separated list)
Stock Monitoring
Start Monitoring
- POST
/monitor - Sets up price alerts for a stock
- Request Body:
{
"symbol": "SYMBOL",
"abovePrice": number,
"belowPrice": number
}
Stop Monitoring
- POST
/stop-monitor - Stops monitoring a stock
- Request Body:
{
"symbol": "SYMBOL"
}
Example API Usage
Getting Stock Quotes
curl "http://localhost:3000/quote?symbols=RELIANCE,TCS,INFY"
Setting Up Price Alerts
curl -X POST -H "Content-Type: application/json" \
-d '{"symbol":"RELIANCE","abovePrice":2500,"belowPrice":2400}' \
http://localhost:3000/monitor
Getting Portfolio Summary
curl http://localhost:3000/portfolio
Error Handling
All endpoints return appropriate HTTP status codes:
- 200: Success
- 400: Bad Request
- 401: Unauthorized
- 404: Not Found
- 500: Internal Server Error
Error responses include a JSON object with an error message:
{
"error": "Error message description"
}
CORS Support
The API includes CORS support and accepts requests from any origin (*). The following HTTP methods are allowed:
- GET
- POST
- OPTIONS
Project Structure
├── src/
│ ├── index.ts # Application entry point
│ ├── controllers/ # Request handlers
│ ├── services/ # Business logic
│ ├── models/ # Data models
│ ├── routes/ # API routes
│ └── utils/ # Helper functions
├── Dockerfile # Container configuration
├── tsconfig.json # TypeScript configuration
├── package.json # Project dependencies
├── .env.example # Example environment variables
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
├── README.md # Project documentation
└── CONTRIBUTING.md # Contribution guidelines
Tech Stack
- Language: TypeScript
- Runtime: Node.js
- Authentication: OAuth 2.0
- API Integration: Zerodha Kite Connect
- Development Tools:
- ESLint for code linting
- Prettier for code formatting
- Jest for testing
- Docker for containerization
Code Quality & Best Practices
- Clean Architecture principles
- SOLID design patterns
- Comprehensive error handling
- API input validation
- Secure credential management
- Detailed logging
- Unit and integration tests
- TypeScript strict mode
- Automated CI/CD pipeline ready
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Quick Start
Clone the repository
git clone https://github.com/suryabonagiri/kite-mcpInstall dependencies
cd kite-mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.