stock-price-mcp-server
Enables real-time stock price queries and historical data retrieval for US, Taiwan, and other global markets via Yahoo Finance.
README
Stock Price MCP Server
A FastMCP-based stock price query server providing real-time stock market data.
Features
Powered by yfinance for real-time stock data:
-
get_stock_price(symbol: str)- Get real-time stock price and related information- Supports US stocks (AAPL, GOOGL, TSLA, MSFT, etc.)
- Supports Taiwan stocks (2330.TW, 2317.TW, etc.)
- Returns price, change, volume, market cap, and more
-
get_stock_history(symbol: str, period: str)- Get historical prices- Period options: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
- Returns OHLCV (Open, High, Low, Close, Volume) data
-
get_stock_info(symbol: str)- Get detailed stock information- Company name, sector, country
- Employee count, market cap, P/E ratio
- 52-week high/low, and more
-
greet(name: str)- Greeting tool
Quick Deploy to FastMCP Cloud
Step 1: Fork or Clone this Repository
git clone https://github.com/YOUR_USERNAME/stock-price-mcp-server.git
cd stock-price-mcp-server
Step 2: Push to Your GitHub
git remote set-url origin https://github.com/YOUR_USERNAME/stock-price-mcp-server.git
git push -u origin main
Step 3: Deploy to FastMCP Cloud
- Go to FastMCP Cloud
- Sign in with your GitHub account
- Click "Create New Project"
- Fill in project information:
- Name:
stock-price-server(or your preferred name) - GitHub Repository: Select your repository
- Entry Point:
server.py:mcp - Authentication: Choose Public or Organization only
- Name:
- Click "Deploy"
Step 4: Use Your Server
After deployment, your server will be available at:
https://your-project-name.fastmcp.app/mcp
You can connect this server in Claude Desktop, Cursor, or other MCP clients.
Local Development
Requirements
- Python 3.10 or higher
- uv (recommended) or pip
- FastMCP CLI
Install Dependencies
Using uv:
uv pip install -r requirements.txt
Run the Server Locally
Start the FastMCP development server:
fastmcp dev server.py:mcp
The server will be available at http://localhost:8000
Note: Don't use uv run server.py - FastMCP servers must be run through the fastmcp CLI tool.
Verify Server Configuration
Inspect the server without running it:
fastmcp inspect server.py:mcp
Test the Server
After starting the server, you can test it using the test client (in a separate terminal):
uv run main.py
Supported Stock Symbols
US Stocks
- AAPL - Apple Inc.
- GOOGL - Alphabet Inc.
- TSLA - Tesla Inc.
- MSFT - Microsoft Corporation
- NVDA - NVIDIA Corporation
- META - Meta Platforms Inc.
Taiwan Stocks
- 2330.TW - Taiwan Semiconductor
- 2317.TW - Hon Hai Precision
- 2454.TW - MediaTek
- 2412.TW - Chunghwa Telecom
Other Markets
- 9988.HK - Alibaba (Hong Kong)
- 600519.SS - Kweichow Moutai (Shanghai)
Usage Examples
Using in Claude Desktop
- Open Claude Desktop settings
- Add MCP server:
{
"mcpServers": {
"stock-price": {
"url": "https://your-project-name.fastmcp.app/mcp"
}
}
}
- Restart Claude Desktop
- Now you can ask: "What's the stock price of AAPL?" or "Show me TSMC's price trend for the last month"
Using FastMCP Client
import asyncio
from fastmcp import Client
async def query_stock():
client = Client("https://your-project-name.fastmcp.app/mcp")
async with client:
# Query real-time stock price
result = await client.call_tool("get_stock_price", {"symbol": "AAPL"})
print(result.data)
# Query historical prices
history = await client.call_tool("get_stock_history", {
"symbol": "TSLA",
"period": "1mo"
})
print(history.data)
asyncio.run(query_stock())
Technical Details
- Data Source: Yahoo Finance (via yfinance package)
- Update Frequency: Real-time (15-minute delay per Yahoo Finance API limits)
- Supported Markets: Major global stock markets (US, Taiwan, Hong Kong, China, etc.)
- Deployment Platform: FastMCP Cloud
- Auto Deployment: Automatically redeploys on push to main branch
- PR Preview: Each PR gets a unique testing URL
File Structure
stock-price-mcp-server/
├── server.py # FastMCP server implementation
├── requirements.txt # Python dependencies
├── pyproject.toml # Project configuration
├── .gitignore # Git ignore rules
└── README.md # Documentation
License
MIT License
Contributing
Issues and Pull Requests are welcome!
Support
For questions:
- Check FastMCP Official Documentation
- Submit a GitHub Issue
- Visit FastMCP Cloud for help
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。