mcpField
S
Stock Price MCP Server

Stock Price MCP Server

Local
github.com/ekadetovFinance0Updated 80w ago

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

  1. 01Retrieves current stock prices
  2. 02Returns historical data as CSV
  3. 03Compares two stock prices
  4. 04Exposes stock information as resources
  5. 05Handles invalid symbols and network errors

Use cases

  1. 01Checking the latest price for a ticker
  2. 02Getting historical data for a chosen period
  3. 03Comparing prices across stocks
  4. 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.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Stock 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

  1. Clone this repository
  2. 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:

  1. get_stock_price(symbol): Returns the current price of a stock as a float
  2. get_stock_history(symbol, period): Returns historical stock data in CSV format
  3. compare_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

MIT License

Comments

Markdown supported

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.