yfinance MCP Server
Provides Yahoo Finance data including stock info, historical prices, dividends, financials, earnings, news, and more through a set of MCP tools, deployable on Azure Functions.
README
yfinance MCP Server on Azure Functions
A Model Context Protocol (MCP) server providing Yahoo Finance data, hosted on Azure Functions as a self-hosted MCP server.
Based on yfinance, adapted for Azure Functions using the custom handler pattern with streamable-http transport.
Tools
| Tool | Description |
|---|---|
get_stock_info |
Get stock price, valuation, financials, and company info |
get_historical_data |
Get historical OHLCV price data with configurable period/interval |
get_dividends |
Get dividend payment history |
get_splits |
Get stock split history |
get_financials |
Get income statement, balance sheet, and cash flow (annual/quarterly) |
get_earnings |
Get earnings data from income statements |
get_news |
Get recent news articles for a stock |
get_recommendations |
Get analyst recommendations breakdown |
search_stocks |
Search for stocks by company name or ticker |
get_multiple_quotes |
Get quotes for multiple stocks at once |
get_option_chain |
Get options data with strikes, bid/ask, volume, implied volatility |
get_analyst_estimates |
Get EPS forecasts, revenue estimates, and growth projections |
get_analyst_ratings |
Get price targets and upgrade/downgrade history |
get_insider_holdings |
Get insider transactions, institutional and fund holders |
batch_download |
Download historical data for multiple tickers efficiently |
screen_stocks |
Screen stocks using predefined Yahoo Finance screeners |
get_esg_data |
Get ESG sustainability scores |
get_sec_filings |
Get SEC filings (10-K, 10-Q, 8-K) with links |
get_calendar |
Get upcoming earnings dates, ex-dividend, and estimates |
Prerequisites
- Python 3.11+
- uv (package manager)
- Azure Functions Core Tools v4 (for local dev and deployment)
Local Development
# Install dependencies
uv sync
# Run with Azure Functions Core Tools
func start
# Or run the server directly (without Functions host)
uv run python server.py
The MCP server starts on http://localhost:8000/mcp using the streamable-http transport.
Testing Locally
Send MCP requests to http://localhost:8000/mcp:
# Initialize the MCP session
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
# List available tools
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
# Call a tool (e.g., get stock info for AAPL)
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_stock_info","arguments":{"symbol":"AAPL"}}}'
Or connect any MCP client (VS Code Copilot, Claude Desktop, etc.) with:
{
"mcpServers": {
"yfinance": {
"url": "http://localhost:8000/mcp"
}
}
}
Deploy to Azure
The server is deployed to an Azure Functions Flex Consumption plan using the Azure CLI and Azure Functions Core Tools.
1. Create Azure Resources
az login
# Create a resource group
az group create --name <resource-group> --location <region>
# Create a storage account (required by Azure Functions)
az storage account create \
--name <storage-account> \
--resource-group <resource-group> \
--location <region> \
--sku Standard_LRS
# Create the Function App on Flex Consumption
az functionapp create \
--name <function-app-name> \
--resource-group <resource-group> \
--storage-account <storage-account> \
--flexconsumption-location <region> \
--runtime python \
--runtime-version 3.11
Region must support Flex Consumption — see supported regions.
2. Configure App Settings
az functionapp config appsettings set \
--name <function-app-name> \
--resource-group <resource-group> \
--settings \
"AzureWebJobsFeatureFlags=EnableMcpCustomHandlerPreview" \
"PYTHONPATH=/home/site/wwwroot/.python_packages/lib/site-packages"
3. Build and Deploy
Azure Functions custom handlers require Python packages to be pre-built for the target platform (Linux x86_64, Python 3.11):
# Generate requirements.txt from pyproject.toml
uv pip compile pyproject.toml -o requirements.txt
# Install packages for the Azure Functions target platform
pip install -r requirements.txt \
--target .python_packages/lib/site-packages \
--platform manylinux2014_x86_64 \
--python-version 3.11 \
--only-binary=:all:
# Deploy (--no-build since packages are pre-built)
func azure functionapp publish <function-app-name> --python --no-build
After deployment, the server is live at https://<function-app-name>.azurewebsites.net/mcp.
Authentication
Choose one of three authentication options depending on your security requirements.
Option 1: No Authentication (Anonymous)
The server is open to the internet with no authentication. Anyone can connect.
This is the default configuration — host.json sets DefaultAuthorizationLevel to anonymous, and no App Service Authentication is configured.
No additional setup is required after deployment.
{
"mcpServers": {
"yfinance": {
"url": "https://<function-app-name>.azurewebsites.net/mcp"
}
}
}
Option 2: Function Key Authentication
Azure Functions provides built-in key-based authentication. Clients must include a function key in each request.
Configure
-
Change
DefaultAuthorizationLevelinhost.jsonfromanonymoustofunction:{ "customHandler": { "http": { "DefaultAuthorizationLevel": "function" } } } -
Redeploy the function app.
-
Retrieve the default function key:
az functionapp keys list \ --name <function-app-name> \ --resource-group <resource-group> \ --query "functionKeys.default" -o tsv
Connect
Pass the key as a query parameter or header:
{
"mcpServers": {
"yfinance": {
"url": "https://<function-app-name>.azurewebsites.net/mcp?code=<function-key>"
}
}
}
Or use the x-functions-key header:
curl -X POST https://<function-app-name>.azurewebsites.net/mcp \
-H "x-functions-key: <function-key>" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
Note: Function keys provide basic access control but are shared secrets. Rotate keys periodically via the Azure Portal or CLI. For production workloads with user-level access control, use Entra ID (Option 3).
Option 3: Microsoft Entra ID (Recommended for Production)
Built-in App Service Authentication implements the MCP authorization specification. Clients receive a 401 challenge and must authenticate via OAuth before connecting.
1. Configure an Identity Provider
-
In Azure Portal, open your function app → Settings → Authentication
-
Add an identity provider (e.g., Microsoft Entra ID)
-
The identity provider registration should be unique for this MCP server — don't reuse an existing registration from another app
-
Make note of the scopes defined in your registration (e.g.,
api://<client-id>/user_impersonation) -
Under App Service authentication settings:
Setting Value Restrict access Require authentication Unauthenticated requests HTTP 401 Unauthorized Token store ✅ Checked
2. Configure Protected Resource Metadata
MCP server authorization requires that the server host protected resource metadata (PRM):
az functionapp config appsettings set \
--name <function-app-name> \
--resource-group <resource-group> \
--settings "WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES=api://<client-id>/user_impersonation"
3. Preauthorize MCP Clients
Microsoft Entra ID does not support Dynamic Client Registration, so MCP clients must be preconfigured.
To preauthorize a client (e.g., VS Code):
- On the Authentication page, click the Entra app name next to Microsoft
- Go to Manage → Expose an API
- Under Authorized client applications, click + Add a client application
- Enter the client ID (VS Code:
aebc6443-996d-45c2-90f0-388ff96faa56) - Select the
user_impersonationscope checkbox → Add application
Note: Without preauthorization, users or an admin must consent to the MCP server registration. Some clients (e.g., GitHub Copilot in VS Code) don't surface interactive login prompts, so preauthorization is required. For dev/test, you can grant consent by navigating to
<your-app-url>/.auth/login/aadin a browser.
Connect
{
"mcpServers": {
"yfinance": {
"url": "https://<function-app-name>.azurewebsites.net/mcp"
}
}
}
MCP clients that support the MCP authorization specification (e.g., VS Code Copilot, Claude Desktop) will automatically handle the OAuth flow when connecting.
For full details, see Configure built-in MCP server authorization and the Azure Functions MCP tutorial.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.