Labsco
quantabox logo

Fyers MCP Server

โ˜… 7

from quantabox

An MCP server for the Fyers API v3, featuring automated OAuth authentication.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Fyers MCP Server

MCP (Model Context Protocol) server for Fyers API v3 with automated OAuth authentication

Python 3.10+ Fyers API v3 License: MIT

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

<video src="https://github.com/quantabox/fyers-mcp-server/assets/fyers-mcp.mp4" width ="300"/>

โœจ Features

๐Ÿ” Smart Authentication

  • One-click OAuth flow with automatic browser handling
  • Persistent token storage in .env file
  • Auto-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

๐Ÿ› ๏ธ Available Tools

Authentication & Profile

  • authenticate() - One-click OAuth authentication
  • check_auth_status() - Verify current authentication
  • get_profile() - User profile information

Portfolio & Funds

  • get_funds() - Account balance and margin details
  • get_holdings() - Portfolio holdings with P&L
  • get_positions() - Current trading positions

Orders & Trading

  • place_order(symbol, quantity, order_type, side, ...) - Place new orders
  • modify_order(order_id, quantity, limit_price, ...) - Modify existing orders
  • cancel_order(order_id) - Cancel pending orders
  • get_orders() - Order history and status

Market Data

  • get_quotes(symbols) - Real-time quotes for multiple symbols

๐Ÿšง Development

Project Structure

fyers-mcp-server/
โ”œโ”€โ”€ fyers_mcp_complete.py    # Main MCP server
โ”œโ”€โ”€ pyproject.toml          # Dependencies
โ”œโ”€โ”€ .env.example           # Environment template
โ”œโ”€โ”€ claude_config.json     # Claude Desktop config
โ””โ”€โ”€ README.md             # This file

Adding New Features

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/new-tool
  3. Add MCP tool: Use @mcp.tool() decorator
  4. Test with Claude Desktop
  5. Submit pull request

Testing

# Install development dependencies
uv sync --dev

# Run tests
uv run pytest

# Type checking
uv run mypy fyers_mcp_complete.py

๐Ÿ“‹ API Reference

Authentication Flow

graph TD
    A[Claude: authenticate] --> B[Generate Auth URL]
    B --> C[Open Browser]
    C --> D[User Login]
    D --> E[Auth Code Capture]
    E --> F[Exchange for Token]
    F --> G[Store in .env]
    G --> H[Ready for Trading]

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 โœ…

<p align="center"> <strong>Made with โค๏ธ for the trading community</strong><br> <sub>Enable algorithmic trading with Claude's intelligence</sub> </p>