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 💡
raydium-launchlab
An MCP server that enables AI agents to launch, buy, and sell tokens on the Raydium Launchpad(aka LaunchLab).
@kukapay/crypto-feargreed-mcp
Providing real-time and historical Crypto Fear & Greed Index data
sui-trader
An MCP server designed for AI agents to perform optimal token swaps on the Sui blockchain.
freqtrade-mcp
An MCP server that integrates with the Freqtrade cryptocurrency trading bot.
chainlink-feeds-mcp
An MCP server that provides real-time access to Chainlink's decentralized on-chain price feeds.
@paypal/mcp
PayPal's MCP server enables merchants to interact with their business tasks using natural language via MCP clients, streamlining operations like invoice creation.