Yahoo Finance MCP server

Integrates with Yahoo Finance to provide real-time stock market data, financial statements, company information, earnings reports, and news for informed investment analysis and research.
Back to servers
Setup instructions
Provider
airjlee
Release date
Mar 19, 2025
Language
Python

This MCP server provides augmented language model capabilities specifically for stock market-related queries and generations. It implements the Model Context Protocol (MCP) to enhance LLM responses with accurate, timely stock market information.

Installation

To set up the stock-LLM server, follow these steps:

Prerequisites

  • Python 3.9 or higher
  • pip (Python package manager)

Setup Process

  1. Clone the repository and navigate to the project directory:
git clone https://github.com/username/stock-LLM.git
cd stock-LLM
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Set up your environment variables by creating a .env file in the root directory with the following:
ALPHA_VANTAGE_API_KEY=your_api_key_here
PORT=8000

Replace your_api_key_here with your actual Alpha Vantage API key.

Usage

Starting the Server

To start the MCP server, run:

python server.py

The server will start on the port specified in your .env file (default: 8000).

Making Requests

You can interact with the server using the Model Context Protocol. Here's an example of a basic request:

{
  "messages": [
    {"role": "user", "content": "What's the current price of AAPL?"}
  ],
  "mcp": {
    "augmentation": true
  }
}

Send this as a POST request to the server's endpoint:

curl -X POST http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"What is the current price of AAPL?"}],"mcp":{"augmentation":true}}'

Available Functions

The server supports the following stock market functions:

  • get_stock_price: Retrieves the current price of a specified stock
  • get_stock_history: Fetches historical data for a stock over a specified time range
  • get_company_overview: Returns key information about a company
  • get_market_news: Provides recent news related to the stock market or specific stocks

Configuration Options

You can customize the server's behavior with these configuration parameters in your requests:

  • augmentation (boolean): Enable or disable the augmentation feature
  • max_history_days (integer): Maximum number of days for historical data (default: 30)
  • data_source (string): Specify which data source to prioritize (default: "alpha_vantage")

Example request with configuration:

{
  "messages": [
    {"role": "user", "content": "Show me TSLA stock performance over the last week"}
  ],
  "mcp": {
    "augmentation": true,
    "max_history_days": 7,
    "data_source": "alpha_vantage"
  }
}

Troubleshooting

Common Issues

  • API Rate Limits: Alpha Vantage has rate limits. If you encounter errors, you might need to wait or upgrade your API plan.
  • Connection Errors: Ensure your server has internet access to fetch real-time stock data.
  • Missing Data: Some smaller stocks may have limited data available.

Logs

Check the server logs for detailed error information and debugging:

tail -f logs/server.log

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "stock-llm" '{"command":"npx","args":["-y","stock-llm"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "stock-llm": {
            "command": "npx",
            "args": [
                "-y",
                "stock-llm"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "stock-llm": {
            "command": "npx",
            "args": [
                "-y",
                "stock-llm"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later