Skip to main content
Glama
Stock Market MCP Server

Stock Market MCP Server

by sverze

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

Related MCP server: Stock Research MCP Server

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

Available Tools

6 tools
get_basic_financialsA
Get basic financial information for a company.

Args:
    symbol: The stock symbol to look up (e.g., AAPL for Apple Inc.)

Returns:
    str: Basic financial metrics in JSON format including P/E ratio, market cap, etc.

Inputs: symbol (required).

get_company_newsA
Get news for a specific company over a date range.

Args:
    symbol: The stock symbol (e.g., AAPL for Apple Inc.)
    from_date: Start date in YYYY-MM-DD format
    to_date: End date in YYYY-MM-DD format

Returns:
    str: Company-specific news in JSON format with headlines, summaries, and URLs.

Inputs: symbol (required), to_date (required), from_date (required).

get_market_newsA
Get the latest market news.

Args:
    category: News category. Available values: general, forex, crypto, merger.
    min_id: Use this to get only news after this ID.

Returns:
    str: Latest market news in JSON format with headlines, summaries, and URLs.

Inputs: min_id, category.

get_stock_candlesA
Get historical price data (candles) for a stock.
Note: This is a premium feature, your API key may not have access to this feature.

Args:
    symbol: The stock symbol (e.g., AAPL for Apple Inc.)
    resolution: Time interval between data points. Supported values: 1, 5, 15, 30, 60, D, W, M (minutes, day, week, month)
    from_time: Start time in YYYY-MM-DD format or Unix timestamp
    to_time: End time in YYYY-MM-DD format or Unix timestamp

Returns:
    str: Historical price data in JSON format with open, high, low, close values.

Inputs: symbol (required), to_time, from_time, resolution.

get_stock_priceA
Get the latest stock price and related information for a given symbol.

Args:
    symbol: The stock symbol to look up (e.g., AAPL for Apple Inc.)

Returns:
    str: Current price information in JSON format

Inputs: symbol (required).

get_stock_symbol_lookupA
Stock Symbol Lookup - searches for best-matching symbols based on your query.

Args:
    query: You can input anything from symbol, security's name to ISIN and CUSIP e.g. apple

Returns:
    str: A list of matching symbols with formatted information

Inputs: query (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct resource: symbol lookup, latest price, financials, market news, company news, and historical candles. The overlap between market news and company news is clear from their descriptions, so no confusion.

    Naming Consistency5/5

    All tool names follow the get_ noun pattern in snake_case, e.g., get_stock_price, get_market_news. This is perfectly consistent and predictable.

    Tool Count5/5

    With 6 tools, the server is well-scoped for stock market data retrieval. Each tool covers a core function without unnecessary bloat.

    Completeness4/5

    The server covers symbol lookup, real-time price, fundamentals, news, and historical data, which covers most basic stock market needs. A minor gap is the lack of batch quotes or sector/ETF data, but these are not essential for the stated purpose.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides comprehensive financial market data and news through the Finnhub API. Enables real-time stock quotes, company profiles, financial metrics, analyst recommendations, and market news access.
      1
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Provides comprehensive stock intelligence and technical analysis by integrating Alpha Vantage and Finnhub data. It enables users to generate detailed research reports and retrieve real-time market metrics, indicators, and news sentiment.
      -
    • A
      license
      A
      quality
      D
      maintenance
      Provides financial data tools like stock price, company info, historical data, news, and market indices using yfinance and MarketAux API.
      5
      4
      MIT