Stock Price MCP Server

Stock Price MCP Server

By ekadetov GitHub

A Simple MCP Server

stock-price mcp-server
Overview

what is Stock Price MCP Server?

The Stock Price MCP Server is a simple Model Context Protocol (MCP) server that provides stock price information using the yfinance library.

how to use Stock Price MCP Server?

To use the Stock Price MCP Server, clone the repository, install the required dependencies, and run the server using the command python stock_price_server.py. You can then access stock information through various tools or resource-based interfaces.

key features of Stock Price MCP Server?

  • Fetch current stock prices for valid ticker symbols.
  • Retrieve historical stock data in CSV format.
  • Compare prices between different stocks.
  • Expose stock data as resources using the pattern stock://{symbol}.

use cases of Stock Price MCP Server?

  1. Retrieving the latest stock price for investment decisions.
  2. Analyzing historical stock performance over time.
  3. Comparing stock prices to identify investment opportunities.

FAQ from Stock Price MCP Server?

  • What programming language is used for the server?

The server is built using Python 3.7+.

  • How do I handle errors when retrieving stock data?

The server includes robust error handling for invalid symbols, network issues, and market closures.

  • Is there a license for using this server?

Yes, the server is licensed under the MIT License.

Content

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

No tools information available.

Mirror of

image-generation mcp-server
View Details

Secure MCP server for analyzing Excel files with oletools

oletools mcp-server
View Details

Mirror of

bigquery mcp-server
View Details

MCPHubs is a website that showcases projects related to Anthropic's Model Context Protocol (MCP)

mcp mcp-server
View Details
Dealx
Dealx by DealExpress

-

dealx mcp-server
View Details

Google Analytics MCP server for accessing analytics data through tools and resources

google-analytics mcp-server
View Details

A Python-based MCP server that lets Claude run boto3 code to query and manage AWS resources. Execute powerful AWS operations directly through Claude with proper sandboxing and containerization. No need for complex setups - just pass your AWS credentials and start interacting with all AWS services.

aws mcp-server
View Details