Stock Market MCP Server

Stock Market MCP Server

Provides stock market data and analysis tools using the Finnhub API, including stock prices, financial metrics, news, and historical data.

Category
访问服务器

README

Stock Market MCP Server

A Machine Conversation Protocol (MCP) server that provides stock market data and analysis tools using the Finnhub API.

Features

  • Stock symbol lookup
  • Real-time stock prices
  • Basic financial metrics
  • Market and company news
  • Historical price data (candles)
  • Pre-built prompts for common analysis tasks

Prerequisites

  • Python 3.8 or higher
  • uv - Fast Python package installer and resolver
  • Finnhub API key (get one for free at finnhub.io)
  • Claude Desktop (for using the MCP server with Claude)

Setup Instructions

1. Clone the Repository

git clone https://github.com/yourusername/stock-market-mcp-server.git
cd stock-market-mcp-server

2. Set Up Environment with uv

uv is a fast, reliable Python package installer and virtual environment manager. Here's how to set up your environment:

# Install uv if you don't have it already
pip install uv

# Create a virtual environment
uv venv

# Activate the virtual environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows:
# .venv\Scripts\activate

# Install dependencies
uv add -r requirements.txt

3. Configure Environment Variables

Create a .env.local file in the project root with your Finnhub API key:

FINNHUB_API_KEY=your_api_key_here

Replace your_api_key_here with your actual Finnhub API key.

Running the MCP Server

To start the MCP server:

uv run stock-market-server.py

The server runs in stdio mode by default, which means it reads from standard input and writes to standard output.

Using with Claude Desktop

To use this MCP server with Claude Desktop:

  1. Start Claude Desktop
  2. Go to Settings > Developer
  3. Enable "Developer Mode"
  4. Click "Add Tool"
  5. Select "Local MCP Server"
  6. Configure the tool:
    • Name: Stock Market
    • Command: The full path to your Python executable and the script
      • Example: /Users/username/.venv/bin/python /Users/username/stock-market-mcp-server/stock-market-server.py
    • Working Directory: The full path to your project directory
  7. Click "Save"

Now you can use the stock market tools in your conversations with Claude!

Alternatively, you can add the tool to your Claude Desktop tools list manually. You can find the configuration file in the installation directory of Claude Desktop. On a MacBook Pro, it's located at ~/Library/Application\ Support/Claude/claude_desktop_config.json. Add the following JSON to the tools array, note modify the path to suite your environment:

"stock-market": {
   "command": "uv",
   "args": [
     "--directory",
     "<YOUR_PATH_GOES_HERE>/stock-market-mcp-server",
     "run",
     "stock_market_server.py"
   ]
 }

Using with Stock Market Client

To use the MCP server with the Stock Market Client, follow these steps:

  1. You will need an Anthropic API key. You can get one for free at Anthropic.
  2. Update the .env file with your API key. ANTHROPIC_API_KEY=your_api_key_here
  3. Start the MCP Client with the following command: uv run stock_market_client.py

Available Tools

The MCP server provides the following tools:

  • get_stock_symbol_lookup: Search for stock symbols by company name
  • get_stock_price: Get the latest price for a stock
  • get_basic_financials: Get key financial metrics for a company
  • get_market_news: Get the latest market news by category
  • get_company_news: Get news for a specific company over a date range
  • get_stock_candles: Get historical price data for a stock

Available Prompts

The server includes these pre-built prompts:

  • stock_analysis: Analyze a stock for potential investment
  • market_overview: Get a comprehensive market overview
  • stock_price_history: Analyze historical price movements
  • company_news_analysis: Analyze news and its impact on stock price

Example Usage Prompts

Here are some examples of how to use the tools with Claude:

  1. Looking up a stock symbol: "Can you look up the stock symbol for Apple?"

  2. Getting current stock price: "What's the current price of AAPL?"

  3. Using a prompt: "I'd like to analyze Tesla stock as a potential investment."

  4. Combining multiple tools: "Give me a market overview with the latest news and the current prices for AAPL, MSFT, and TSLA."

Troubleshooting

  • API Key Issues: Make sure your Finnhub API key is correctly set in the .env.local file
  • Module Not Found Errors: Ensure you've activated the virtual environment and installed all dependencies
  • Connection Issues: Check your internet connection and Finnhub API status

License

MIT License

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选