{"id":27234458,"url":"https://github.com/mtwn105/zerodha-mcp","last_synced_at":"2025-06-13T16:34:55.750Z","repository":{"id":287038827,"uuid":"959954763","full_name":"mtwn105/zerodha-mcp","owner":"mtwn105","description":"Zerodha MCP Server \u0026 Client - AI Agent (w/Agno \u0026 w/Google ADK)","archived":false,"fork":false,"pushed_at":"2025-04-17T10:31:54.000Z","size":49,"stargazers_count":15,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T04:54:45.085Z","etag":null,"topics":["agent","agentic-ai","agno","ai","artificial-intelligence","kite","kiteconnect","mcp","mcp-client","mcp-server","model-context-protocol","model-context-protocol-client","model-context-protocol-servers","python","zerodha"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtwn105.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-03T16:11:57.000Z","updated_at":"2025-05-28T04:00:35.000Z","dependencies_parsed_at":"2025-04-09T17:43:38.294Z","dependency_job_id":null,"html_url":"https://github.com/mtwn105/zerodha-mcp","commit_stats":null,"previous_names":["mtwn105/zerodha-mcp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mtwn105/zerodha-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtwn105%2Fzerodha-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtwn105%2Fzerodha-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtwn105%2Fzerodha-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtwn105%2Fzerodha-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtwn105","download_url":"https://codeload.github.com/mtwn105/zerodha-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtwn105%2Fzerodha-mcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259680485,"owners_count":22895199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","agentic-ai","agno","ai","artificial-intelligence","kite","kiteconnect","mcp","mcp-client","mcp-server","model-context-protocol","model-context-protocol-client","model-context-protocol-servers","python","zerodha"],"created_at":"2025-04-10T15:56:40.922Z","updated_at":"2025-06-13T16:34:55.736Z","avatar_url":"https://github.com/mtwn105.png","language":"Python","funding_links":[],"categories":["🤖 AI/ML","🌟 Community Excellence","📚 Projects (2474 total)"],"sub_categories":["Domain-Specific Applications","MCP Servers"],"readme":"# Zerodha MCP Server \u0026 Client\n\nA Python-based trading assistant that connects to a Zerodha MCP server to help users manage their trading account.\n\n## Features\n\n- **Account Management**: Manage Zerodha trading account, orders, and positions\n- **Interactive Chat Interface**: Natural language interface for trading operations\n- **MCP Integration**: Built on the Model Context Protocol for standardized communication\n- **Zerodha API Integration**: Uses Zerodha's API to interact with the trading platform\n- **Agno Agent**: Uses Agno Agent to interact with the trading platform\n- **Google ADK Agent**: Uses Google ADK Agent to interact with the trading platform\n\n## Tech Stack\n\n- **Protocol**: [Model Context Protocol (MCP)](https://modelcontextprotocol.io/)\n- **Agent Framework**:\n  - [Agno](https://github.com/agno-agi/agno)\n  - [Google ADK](https://developers.google.com/adk)\n \n![diagram-export-4-17-2025-4_00_54-PM](https://github.com/user-attachments/assets/e2dc5414-d95e-4297-8eb1-fdbd4fbe4a9b)\n\n## Tools\n\n- **Place Orders**: Place orders in the trading platform\n- **Modify Orders**: Modify orders in the trading platform\n- **Cancel Orders**: Cancel orders in the trading platform\n- **Get Orders**: Get orders in the trading platform\n- **Get Order History**: Get order history in the trading platform\n- **Get Order Trades**: Get order trades in the trading platform\n- **Get Margins**: Get margins in the trading platform\n- **Get Holdings**: Get holdings in the trading platform\n- **Get Positions**: Get positions in the trading platform\n- **Get User Profile**: Get user profile in the trading platform\n\n## Prerequisites\n\n- Python\n- Zerodha trading account with Personal API access from [here](https://developers.kite.trade/login)\n- Zerodha API key and secret\n- OpenAI API key (for Agno Agent)\n- Gemini API key or Application Default Credentials (for Google ADK Agent)\n\n## Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/mtwn105/zerodha-mcp-server-client.git\ncd zerodha-mcp-server-client\n```\n\n2. Create and activate a virtual environment:\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n4. Set up environment variables:\n\n```bash\n# Copy the example environment file\ncp .env.example .env\n\n# Edit the .env file with your credentials\n```\n\n5. Create a `.env` file with your configuration:\n\n```env\n# Server Configuration\nZERODHA_API_KEY=your_api_key\nZERODHA_API_SECRET=your_api_secret\nPORT=8001\nSERVER_MODE=sse  # or stdio\n\n# Client Configuration\nMCP_HOST=localhost\nMCP_PORT=8001\nOPENAI_API_KEY=your_openai_api_key\n# GOOGLE_API_KEY=your_google_api_key\n```\n\n## Server Usage\n\nThe server provides a set of tools for interacting with the Zerodha trading platform. To start the server:\n\n1. Make sure your `.env` file is properly configured with your Zerodha API credentials.\n\n2. Start the server using one of the following methods:\n\n```bash\n# Using environment variables\npython server.py\n\n# Or using command line arguments\npython server.py --api-key your_api_key --api-secret your_api_secret --port 8001 --mode sse\n```\n\nThe server provides the following tools:\n\n- `get_login_url`: Get the login URL for user authentication\n- `get_access_token`: Generate access token using request token\n- `get_user_profile`: Get user's Zerodha profile information\n- `get_margins`: Get available margins and fund details\n- `get_holdings`: Get portfolio holdings\n- `get_positions`: Get current positions\n- `get_orders`: Get all orders for the day\n- `get_order_history`: Get history of a specific order\n- `get_order_trades`: Get trades generated by an order\n- `place_order`: Place a new order\n- `modify_order`: Modify an existing order\n- `cancel_order`: Cancel an order\n\n## Client Usage\n\nThis project provides three client implementations:\n\n1. Using the Agno framework (`client/agno_client.py`)\n2. Using Agno with Gradio web interface (`client/agno_gradio_client.py`)\n3. Using Google ADK (`client/google_adk_client.py`)\n\nAll clients connect to the MCP server and provide an interactive interface for trading operations.\n\n### Running the Agno Client\n\n1. Ensure your `.env` file includes `OPENAI_API_KEY`.\n2. Start the client using one of the following methods:\n\n```bash\n# Using environment variables from .env file\npython client/agno_client.py\n\n# Using command line arguments\npython client/agno_client.py --host localhost --port 8001\n\n# Using a combination (command line arguments take precedence)\nMCP_HOST=localhost MCP_PORT=8001 python client/agno_client.py --host otherhost --port 9000\n```\n\n### Running the Google ADK Client\n\n1. Ensure you have authenticated with Google AI, either by setting the `GOOGLE_API_KEY` environment variable (and uncommenting it in `.env`) or by using Application Default Credentials (run `gcloud auth application-default login`).\n2. Start the client using one of the following methods:\n\n```bash\n# Using environment variables from .env file\npython client/google_adk_client.py\n\n# Using command line arguments\npython client/google_adk_client.py --host localhost --port 8001\n\n# Using a combination (command line arguments take precedence)\nMCP_HOST=localhost MCP_PORT=8001 python client/google_adk_client.py --host otherhost --port 9000\n```\n\n### Running the Gradio Web Interface\n\n1. Ensure your `.env` file includes `OPENAI_API_KEY`.\n2. Start the Gradio web interface:\n\n```bash\n# Using environment variables from .env file\npython client/agno_gradio_client.py\n\n# Using command line arguments for server configuration\npython client/agno_gradio_client.py --host localhost --port 8001\n```\n\n3. Open your web browser and navigate to the URL shown in the terminal (typically `http://localhost:7860`).\n\n4. Use the web interface to:\n   - Connect to the MCP server by entering the host and port\n   - Chat with the AI assistant using natural language\n   - Manage your Zerodha account through a user-friendly interface\n\nThe Gradio interface provides:\n\n- Easy connection management with host/port configuration\n- Real-time chat interface with the AI assistant\n- Visual feedback for connection status\n- Mobile-friendly responsive design\n\n### Client Configuration\n\nBoth clients support configuration through multiple sources, with the following precedence:\n\n1. Command-line arguments (highest precedence)\n2. Environment variables\n3. `.env` file variables\n\nConfiguration options:\n\n- Environment variables: `MCP_HOST` and `MCP_PORT`\n- Command-line arguments: `--host` and `--port`\n- `.env` file variables: `MCP_HOST`, `MCP_PORT`, `OPENAI_API_KEY`, and `GOOGLE_API_KEY`\n\nDefault values (if no configuration is provided):\n\n- Host: localhost\n- Port: 8001\n\nThe client automatically loads environment variables from the `.env` file in the project root directory. Make sure your `.env` file contains the necessary configuration:\n\n```env\n# Client Configuration\nMCP_HOST=localhost\nMCP_PORT=8001\nOPENAI_API_KEY=your_openai_api_key\n# GOOGLE_API_KEY=your_google_api_key\n```\n\n3. The client will automatically connect to the MCP server using the provided configuration.\n\n4. Once connected, you can interact with the assistant using natural language commands. For example:\n\n   - \"Show me my portfolio holdings\"\n   - \"What are my current positions?\"\n   - \"Place a market order for 10 shares of RELIANCE\"\n   - \"Cancel order ID 123456\"\n\n5. To exit the client, type 'quit' when prompted.\n\n## Development\n\n### Project Structure\n\n- `client/agno_client.py`: MCP client implementation using Agno\n- `client/google_adk_client.py`: MCP client implementation using Google ADK\n- `client/agno_gradio_client.py`: Web interface using Gradio and Agno\n- `server.py`: MCP server implementation with Zerodha API integration\n- `generate_token.py`: Utility for generating access tokens\n- `requirements.txt`: Project dependencies\n- `.env`: Environment configuration\n\n### Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit your changes\n4. Push to the branch\n5. Create a Pull Request\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Built using [Agno](https://github.com/agno-agi/agno)\n- Built using [Google ADK](https://google.github.io/adk-docs/)\n- Uses [MCP](https://modelcontextprotocol.io/) for standardized communication\n- Powered by [KiteConnect](https://kite.trade/) for Zerodha API integration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtwn105%2Fzerodha-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtwn105%2Fzerodha-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtwn105%2Fzerodha-mcp/lists"}