Stock Information MCP Server
This project provides a simple MCP (Modular Command Protocol) server and client for fetching stock information from Google Finance.
This project is built using FastMCP, a Pythonic framework that simplifies the creation of MCP servers and clients. FastMCP handles all the complex protocol details and server management, allowing for clean and intuitive implementation of MCP tools.
Features
- Fetch real-time stock prices from Google Finance
- Get company descriptions
- Simple command-line interface
- Easy to integrate with other applications
Installation
-
Clone this repository:
git clone https://github.com/natifridman/stocks-mcp.git cd stocks-mcp -
Install the required dependencies:
Using uv (recommended):
uv sync source .venv/bin/activateThis will create a virtual environment, install all dependencies from the lock file, and activate the environment.
Or using pip:
pip install fastmcp aiohttp beautifulsoup4
Usage
Starting the Server
-
Run the server in a terminal:
uv run my_server.pyThe server will start and display a message like: "Starting server 'Stock Information MCP Server'..."
-
Keep this terminal open while using the client.
Using the Client
The client can be used in several ways:
-
With Command Line Arguments:
uv run my_client.py IBM:NYSEReplace
IBM:NYSEwith your desired stock ticker. -
Interactive Mode:
uv run my_client.pyThen enter the ticker when prompted.
Stock Ticker Format
Use the format TICKER:EXCHANGE for best results:
AAPL:NASDAQ- AppleMSFT:NASDAQ- MicrosoftTSLA:NASDAQ- TeslaAMZN:NASDAQ- AmazonGOOGL:NASDAQ- Google/AlphabetIBM:NYSE- IBMDIS:NYSE- Disney
Adding MCP Config in VS Code or Cursor
To use this MCP tool in your editor:
-
Cursor Configuration:
- Open or create the MCP configuration file at
~/.cursor/mcp.json - Add the following configuration:
{ "mcpServers": { "stock-info": { "command": "/path/to/your/stocks-mcp/.venv/bin/python", "args": ["/path/to/your/stocks-mcp/my_server.py"] } } }- Replace
/path/to/your/with your actual project path
- Open or create the MCP configuration file at
-
VS Code Configuration:
- For VS Code, the configuration format might vary depending on the extension you're using
API Reference
Server Tools
The server provides the following tool:
get_stock_info(ticker: str): Returns stock information including price and description
Client Functions
get_stock_info(ticker: str): Fetches and displays stock information
Troubleshooting
- Make sure the server is running before using the client
- Check your internet connection if stock data isn't loading
- Verify the ticker symbol format is correct
License
This project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the LICENSE file for details.
Recommend MCP Servers 💡
financial-markets-analyser
A FastMCP server providing financial data endpoints for stocks and cryptocurrencies with free data sources and fallback mechanisms
@xiaok/etherscan-mcp
A dynamic MCP server for interacting with Etherscan's API and services
@stripe/mcp
A toolkit enabling AI agents to interact with Stripe APIs through function calling, offering both local stdio and remote SSE MCP server options.
@kukapay/pancakeswap-poolspy-mcp
An MCP server that tracks newly created liquidity pools on Pancake Swap, providing real-time data for DeFi analysts, traders, and developers.
longportapp/openapi
A MCP server for LongPort OpenAPI enabling real-time stock data, analysis, and trading via AI.
alphavantage
An MCP server providing real-time and historical stock market data by integrating with the Alpha Vantage API.