About Stock Price MCP Server
A finance MCP server built on yfinance that provides clients with current prices, historical stock data, and price comparisons. It also exposes stock information through the `stock://{symbol}` resource pattern.
Key features
- 01Retrieves current stock prices
- 02Returns historical data as CSV
- 03Compares two stock prices
- 04Exposes stock information as resources
- 05Handles invalid symbols and network errors
Use cases
- 01Checking the latest price for a ticker
- 02Getting historical data for a chosen period
- 03Comparing prices across stocks
- 04Reading stock information through a resource
MCP support
The server provides MCP clients with tools for current prices, historical data, and stock comparisons, and exposes stock information as resources using `stock://{symbol}`.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEStock Price MCP Server
A simple Model Context Protocol (MCP) server that provides stock price information using the yfinance library.
Overview
This MCP server offers tools to retrieve and compare stock prices. It demonstrates how to build a functional MCP server with multiple capabilities:
- Fetch current stock prices
- Retrieve historical stock data
- Compare prices between different stocks
- Expose stock data as resources
Features
Stock Price Retrieval
Retrieve the latest stock price for any valid ticker symbol. The server handles market closures and invalid symbols gracefully.
Historical Data Access
Get historical stock data in CSV format for different time periods (1 month by default, but customizable).
Stock Comparison
Compare prices between two different stocks with a human-readable output.
Resource Exposure
Access stock information through a resource-based interface using the pattern stock://{symbol}.
Installation
- Clone this repository
- Install the required dependencies:
pip install -r requirements.txt
Usage
Starting the Server
Run the server with:
python stock_price_server.py
Available Tools
The server provides the following tools:
get_stock_price(symbol): Returns the current price of a stock as a floatget_stock_history(symbol, period): Returns historical stock data in CSV formatcompare_stocks(symbol1, symbol2): Compares prices between two stocks
Using Resources
Resources are accessible using the pattern stock://{symbol} which returns formatted price information.
Error Handling
All functions include robust error handling that returns meaningful error messages when data retrieval fails:
- Invalid symbols return appropriate error messages
- Network issues are properly handled
- Market closures are managed with fallback price information
Requirements
- Python 3.7+
- mcp-server (Model Context Protocol)
- yfinance
- FastAPI
- Uvicorn
License
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.