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.
- Fetch real-time stock prices from Google Finance
- Get company descriptions
- Simple command-line interface
- Easy to integrate with other applications
-
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
-
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.
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.
Use the format TICKER:EXCHANGE for best results:
AAPL:NASDAQ- AppleMSFT:NASDAQ- MicrosoftTSLA:NASDAQ- TeslaAMZN:NASDAQ- AmazonGOOGL:NASDAQ- Google/AlphabetIBM:NYSE- IBMDIS:NYSE- Disney
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
The server provides the following tool:
get_stock_info(ticker: str): Returns stock information including price and description
get_stock_info(ticker: str): Fetches and displays stock information
- 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
This project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the LICENSE file for details.