MCP Stock Market Servers
Provides real-time stock prices, sector analysis, historical data, and top performers for Indian NSE and global markets. Also includes stock-specific and market news from multiple sources with intelligent caching.
README
MCP Stock Market Servers
Two Model Context Protocol (MCP) servers providing comprehensive stock market data and news for Indian (NSE) and global markets.
🚀 Features
Stock Market Server (stock_market_server.py)
- Real-time Stock Prices: Get current prices for NSE and global stocks
- Sector Analysis: Browse stocks by industry sectors
- Historical Data: Retrieve historical price data with customizable periods
- Top Performers: Get top gainers, losers, and most active stocks from NIFTY 50
- Intelligent Caching: 1-hour cache system to reduce API calls
- Fallback Data: Backup data for major Indian stocks when APIs are unavailable
Stock News Server (stock_news_server.py)
- Stock-specific News: Get latest news for individual stocks
- Market News: General market news and updates
- Multiple Sources: Integrates Alpha Vantage, Yahoo Finance, and NewsAPI
- Smart Caching: 1-hour cache system for news articles
- Error Resilience: Graceful fallback when API limits are reached
📋 Prerequisites
Python Dependencies
Using UV (Recommended)
uv add fastmcp yfinance requests beautifulsoup4 pandas pathlib
Using Pip
pip install fastmcp yfinance requests beautifulsoup4 pandas pathlib
API Keys (Optional but Recommended)
-
NewsAPI (Free tier available)
- Visit: https://newsapi.org/
- Get your API key
- Set environment variable:
NEWS_API_KEY
-
Alpha Vantage (Free tier available)
- Visit: https://www.alphavantage.co/
- Get your API key
- Set environment variable:
ALPHA_VANTAGE_API_KEY
Setting Environment Variables
Windows (PowerShell)
# Temporary (current session only)
$env:NEWS_API_KEY = "your_newsapi_key_here"
$env:ALPHA_VANTAGE_API_KEY = "your_alphavantage_key_here"
# Permanent
[System.Environment]::SetEnvironmentVariable('NEWS_API_KEY', 'your_newsapi_key_here', 'User')
[System.Environment]::SetEnvironmentVariable('ALPHA_VANTAGE_API_KEY', 'your_alphavantage_key_here', 'User')
Linux/macOS
# Add to ~/.bashrc or ~/.zshrc
export NEWS_API_KEY="your_newsapi_key_here"
export ALPHA_VANTAGE_API_KEY="your_alphavantage_key_here"
# Or set temporarily
export NEWS_API_KEY="your_newsapi_key_here"
export ALPHA_VANTAGE_API_KEY="your_alphavantage_key_here"
🛠️ Installation & Setup
-
Clone or download the server files
-
Install dependencies:
Using UV (Recommended)
uv add fastmcp yfinance requests beautifulsoup4 pandasUsing Pip
pip install fastmcp yfinance requests beautifulsoup4 pandas -
Set API keys (optional but recommended)
-
Test the servers (opens server for testing):
Using UV
# Test Stock Market Server (opens interactive testing environment) uv run mcp dev stock_market_server.py # Test Stock News Server (opens interactive testing environment) uv run mcp dev stock_news_server.pyUsing Python directly
# Stock Market Server python stock_market_server.py # Stock News Server python stock_news_server.py -
Install in Claude:
Using UV
# Install Stock Market Server uv run mcp install stock_market_server.py # Install Stock News Server uv run mcp install stock_news_server.py
📚 Available Tools
Stock Market Server Tools
get_stock_price(ticker: str)
Get current stock price with formatted output.
Parameters:
ticker: Stock symbol (e.g., "RELIANCE.NS", "AAPL")
Example:
get_stock_price("RELIANCE.NS")
# Returns: "💰 Reliance Industries (RELIANCE.NS): ₹2,500.00"
get_sector_stocks(sector: str)
Get list of stocks in a specific sector.
Available Sectors:
- Information Technology
- Financial Services
- Energy
- Consumer Goods
- Healthcare
Example:
get_sector_stocks("Information Technology")
# Returns list of IT sector stocks
get_stock_history(ticker: str, period: str, interval: str)
Get historical stock data for analysis.
Parameters:
ticker: Stock symbolperiod: Time period ('1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max')interval: Data interval ('1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo')
Example:
get_stock_history("RELIANCE.NS", "1mo", "1d")
# Returns JSON with historical data and summary statistics
get_top_nse_stocks(category: str)
Get top performing stocks from NSE NIFTY 50.
Categories:
gainers: Top gaining stockslosers: Top losing stocksmost_active: Most actively traded stocks
Example:
get_top_nse_stocks("gainers")
# Returns JSON with NIFTY 50 data and top gaining stocks
Stock News Server Tools
get_stock_news(ticker: str, source: str)
Get latest news articles for a specific stock.
Parameters:
ticker: Stock symbol (e.g., "RELIANCE.NS")source: News source ('all', 'alpha_vantage', 'yahoo')
Example:
get_stock_news("RELIANCE.NS", "all")
# Returns JSON with news articles for Reliance
get_market_news()
Get latest general market news.
Example:
get_market_news()
# Returns formatted list of latest market news
🎯 Usage Examples
Once installed in Claude Desktop, you can use these tools through natural language commands:
Stock Market Server Examples
- "Get the current price of Reliance Industries"
- "Show me IT sector stocks"
- "Get 1-month historical data for HDFC Bank"
- "What are the top gainers in NIFTY 50 today?"
Stock News Server Examples
- "Get latest news for TCS"
- "Show me general market news"
- "What's the latest news about Infosys from all sources?"
Sample Interactions
User: "What's the current price of RELIANCE.NS?"
Claude: Uses get_stock_price("RELIANCE.NS") → "💰 Reliance Industries (RELIANCE.NS): ₹2,500.00"
User: "Show me the top performing stocks today"
Claude: Uses get_top_nse_stocks("gainers") → Returns formatted list of top gainers
User: "Get me news about TCS"
Claude: Uses get_stock_news("TCS.NS", "all") → Returns latest news articles
🔧 Development Workflow
Using UV (Recommended)
# Initialize project
uv init
# Add dependencies
uv add fastmcp yfinance requests beautifulsoup4 pandas
# Test servers during development (opens interactive testing environment)
uv run mcp dev stock_market_server.py
uv run mcp dev stock_news_server.py
# Install servers for production use
uv run mcp install stock_market_server.py
uv run mcp install stock_news_server.py
Using Traditional Python
# Install dependencies
pip install fastmcp yfinance requests beautifulsoup4 pandas
# Run servers
python stock_market_server.py
python stock_news_server.py
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。