This is my first MCP (Model Context Protocol) server project. The goal is to build a small and useful service around stock market data using Python and yfinance, following the official MCP guide: MCP with Python
What it can do (tools)
Planned / supported commands:
Get stock data for a ticker: STOCK_TICKER
Get stock data for multiple tickers: [list of tickers]
Search by sector (returns top companies for that sector)
Get latest news for a ticker
Specific goals
Getting started
Logging (important for debugging)
Note
When working with MCP over stdio, prefer stderr for debug output, or use logging.
Environment setup (uv)
You need uv to manage the virtual environment and dependencies:
Then configure VS Code to use the .venv interpreter.
Notes about yfinance
I’m using the Yahoo Finance wrapper library yfinance. Documentation:
yfinance reference
For now, I’m focusing on:
ticker data (single and multiple)
sector search (top companies)
news section
Current implementation
Sector search change
I modified the search tool so it works by sector key and returns the top companies of that sector.
News section
I added a tool that fetches the latest news for a given ticker.
Code
The main server script currently looks like this:
Testing
Testing failed a bit because mcp.tool() has some specific parameters that I can use to improve the tool definitions and overall quality.
I updated the script, added the configuration in Claude, and now I’m debugging until everything works properly.