Fyers MCP Server
MCP (Model Context Protocol) server for Fyers API v3 with automated OAuth authentication
A comprehensive MCP server that enables Claude Desktop to interact with Fyers trading platform through a secure, automated authentication flow. Supports all major trading operations including portfolio management, order placement, and real-time market data.
π¬ Demo
β¨ Features
π Smart Authentication
One-click OAuth flow with automatic browser handling
Persistent token storage in
.envfileAuto-refresh capabilities with session management
π Complete Trading Toolkit
Portfolio Management: Holdings, positions, funds, profile
Order Management: Place, modify, cancel orders
Market Data: Real-time quotes for multiple symbols
Order History: Complete order and trade book
π Production Ready
Full error handling with detailed error messages
Type safety with parameter validation
Comprehensive logging for debugging
Claude Desktop integration with simple configuration
π Quick Start
Prerequisites
Python 3.10 or higher
Claude Desktop installed
Fyers Trading Account with API access
1. Installation
2. Get Fyers API Credentials
Create Fyers API App:
Visit Fyers API Dashboard
Create a new app with redirect URI:
http://localhost:8080/Note down your
App IDandSecret Key
Configure Environment:
cp .env.example .envEdit
.envfile:FYERS_CLIENT_ID=YOUR_APP_ID-100 # e.g., ABC123XYZ-100 FYERS_SECRET_KEY=YOUR_SECRET_KEY # Secret from Fyers app FYERS_REDIRECT_URI=http://localhost:8080/
3. Configure Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
4. First Run
Restart Claude Desktop
Authenticate: In Claude, type:
authenticateBrowser will open β Login to Fyers β Automatic token capture
Start trading: All 11 tools are now available!
π οΈ Available Tools
Authentication & Profile
authenticate()- One-click OAuth authenticationcheck_auth_status()- Verify current authenticationget_profile()- User profile information
Portfolio & Funds
get_funds()- Account balance and margin detailsget_holdings()- Portfolio holdings with P&Lget_positions()- Current trading positions
Orders & Trading
place_order(symbol, quantity, order_type, side, ...)- Place new ordersmodify_order(order_id, quantity, limit_price, ...)- Modify existing orderscancel_order(order_id)- Cancel pending ordersget_orders()- Order history and status
Market Data
get_quotes(symbols)- Real-time quotes for multiple symbols
π Usage Examples
Portfolio Analysis
Order Management
Market Data
π§ Configuration Options
Order Types
MARKET- Market order (immediate execution)LIMIT- Limit order (execute at specific price)STOP- Stop loss orderSTOPLIMIT- Stop limit order
Product Types
MARGIN- Margin trading (intraday with leverage)CNC- Cash and Carry (delivery)INTRADAY- Intraday tradingBO- Bracket OrderCO- Cover Order
Validity Options
DAY- Valid for current trading dayIOC- Immediate or CancelGTD- Good Till Date
π Troubleshooting
Common Issues
1. Authentication Failed
2. Claude Desktop Connection Issues
3. Order Placement Errors
Verify symbol format:
NSE:SYMBOL-EQfor equityCheck market hours (9:15 AM - 3:30 PM IST)
Ensure sufficient funds/margin
Debug Mode
Enable detailed logging:
π§ Development
Project Structure
Adding New Features
Fork the repository
Create feature branch:
git checkout -b feature/new-toolAdd MCP tool: Use
@mcp.tool()decoratorTest with Claude Desktop
Submit pull request
Testing
π API Reference
Authentication Flow
Error Handling
All functions return standardized responses:
β Success: Clear confirmation with relevant data
β Error: Detailed error message with troubleshooting hints
π€ Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Areas for Contribution
WebSocket real-time data streaming
Advanced order types (OCO, Iceberg)
Portfolio analytics and reporting
Options chain analysis tools
Risk management features
π License
This project is licensed under the MIT License - see the LICENSE file for details.
β οΈ Disclaimer
This software is for educational and development purposes. Trading involves financial risk. Users are responsible for their trading decisions and should thoroughly test in demo environments before live trading.
π Links
π Status
Current Version: 1.0.0
API Compatibility: Fyers API v3.1.7
Python Support: 3.10+
Tools Available: 11/11 β
Production Ready: Yes β