MCP Financial Datasets Server
Provides backtesting-compliant financial data including company financials, historical stock and crypto prices, and news with sentiment analysis from financialdatasets.ai API.
README
MCP Financial Datasets Server
MCP server providing financial data from financialdatasets.ai with backtesting support.
Overview
This server provides comprehensive financial data including company financials, stock prices, crypto prices, and company news from the financialdatasets.ai API. All tools are backtesting-compliant, ensuring no future information leakage.
Features
- Backtesting Compliant: All data strictly filtered to before cutoff date
- Company Financials: Income statements, balance sheets, cash flow statements
- Historical Prices: Stock and cryptocurrency price data (OHLCV)
- Company News: News articles with sentiment analysis
- Flexible Periods: Annual, quarterly, or trailing twelve months (TTM) data
- Crypto Support: 100+ cryptocurrencies with historical price data
Tools
Financial Statements
get_income_statements
Get historical income statements for a company.
Parameters:
ticker(str): Stock ticker symbol (e.g., AAPL, MSFT, GOOGL)cutoff_date(str): Only return data with report_period <= cutoff_dateperiod(str): "annual", "quarterly", or "ttm" (default: "annual")limit(int): Number of historical periods (default: 4)
Returns: JSON array with revenue, net_income, operating_income, earnings_per_share, etc.
get_balance_sheets
Get historical balance sheets for a company.
Parameters: Same as get_income_statements
Returns: JSON array with total_assets, cash_and_equivalents, total_debt, shareholders_equity, etc.
get_cash_flow_statements
Get historical cash flow statements for a company.
Parameters: Same as get_income_statements
Returns: JSON array with net_cash_flow_from_operations, capital_expenditure, free_cash_flow, etc.
Stock Prices
get_historical_stock_prices
Get historical stock price data (OHLCV) for a date range.
Parameters:
ticker(str): Stock ticker symbol (e.g., AAPL, TSLA, NVDA)start_date(str): Start date in YYYY-MM-DD formatend_date(str): End date in YYYY-MM-DD format (clamped to cutoff_date)cutoff_date(str): Maximum date for returned datainterval(str): "minute", "hour", "day", "week", or "month" (default: "day")interval_multiplier(int): Multiply interval (e.g., 5 with "minute" = 5-minute bars)
Returns: JSON array with open, close, high, low, volume, timestamp fields
Company News
get_company_news
Get recent news articles about a company with sentiment analysis.
Parameters:
ticker(str): Stock ticker symbolcutoff_date(str): Only return news published before this date
Returns: JSON array (up to 20 articles) with title, url, date, author, source, sentiment
Cryptocurrency
get_available_crypto_tickers
Get list of all available cryptocurrency tickers.
Returns: JSON array of ticker symbols (e.g., ["BTC-USD", "ETH-USD", "SOL-USD"])
get_crypto_prices
Get historical cryptocurrency price data (OHLCV).
Parameters:
ticker(str): Crypto ticker symbol (e.g., BTC-USD, ETH-USD, SOL-USD)start_date(str): Start date in YYYY-MM-DD formatend_date(str): End date in YYYY-MM-DD format (clamped to cutoff_date)cutoff_date(str): Maximum date for returned datainterval(str): "minute", "hour", "day", "week", or "month" (default: "day")interval_multiplier(int): Multiply interval
Returns: JSON array with open, close, high, low, volume, timestamp fields
Environment Variables
Required:
FINANCIAL_DATASETS_API_KEY: API key for financialdatasets.ai
Get your API key at: https://financialdatasets.ai/
Installation
cd mcp-financial-datasets
uv sync
Usage
Testing Locally
mcp run -t sse financial_datasets_server.py:mcp
As Git Submodule
git submodule add <repo-url> mcp-servers/mcp-financial-datasets
Backtesting Compliance
This server implements strict backtesting controls:
Financial Statements
- Filter Parameter:
report_period_lte={cutoff_date}in API requests - Guarantee: Only returns financial statements for periods ending on or before cutoff_date
- Note: Report period is when the fiscal period ended, not when filed with SEC
Price Data
- End Date Clamping: If
end_date > cutoff_date, automatically clamps tocutoff_date - Guarantee: No price data returned after cutoff_date
- Safe Pattern: Always request with
end_dateat or beforecutoff_date
Company News
- Filter Parameter:
end_date={cutoff_date}in API requests - Guarantee: Only returns news published before cutoff_date
- Includes: Title, URL, publication date, author, source, sentiment
Disabled Tools
The following tools are intentionally disabled for backtesting compliance:
get_current_stock_price- Always returns latest price (future information)get_current_crypto_price- Always returns latest price (future information)get_sec_filings- API only providesreport_date, notfiling_date(when made public)
Alternative: Use get_historical_stock_prices or get_crypto_prices with start_date=end_date=cutoff_date to get price at a specific historical date.
API Details
Base URL: https://api.financialdatasets.ai
Authentication: X-API-KEY header (optional but recommended for higher rate limits)
Endpoints Used:
/financials/income-statements//financials/balance-sheets//financials/cash-flow-statements//prices/(stock prices)/news/(company news)/crypto/prices/(cryptocurrency prices)/crypto/prices/tickers(available crypto tickers)
Error Handling
All tools return user-friendly error messages:
- Missing or invalid API key
- Invalid ticker symbols
- Date parsing errors
- API request failures
- No data found for requested parameters
Errors are returned as strings rather than raising exceptions.
Example Queries
Get Apple's Annual Financials
income = await get_income_statements(
ticker="AAPL",
period="annual",
limit=4,
cutoff_date="2024-01-01"
)
Get Bitcoin Price History
prices = await get_crypto_prices(
ticker="BTC-USD",
start_date="2024-01-01",
end_date="2024-06-01",
interval="day",
cutoff_date="2024-06-01"
)
Get Tesla News
news = await get_company_news(
ticker="TSLA",
cutoff_date="2024-06-01"
)
Limitations
- SEC Filings: Not available due to lack of
filing_datefield in API - Real-time Data: Current price endpoints disabled for backtesting compliance
- Rate Limits: Subject to financialdatasets.ai API rate limits
- API Coverage: Data availability depends on what financialdatasets.ai provides
Testing
Setup
- Install test dependencies:
uv pip install -e ".[test]"
- Configure environment variables by copying
.env.exampleto.env:
cp .env.example .env
- Add your API key to
.env:FINANCIAL_DATASETS_API_KEY- Required from https://financialdatasets.ai/
Running Tests
Run all tests:
pytest
Run with verbose output:
pytest -v
Run specific test file:
pytest tests/test_financial_datasets_server.py
Run specific test:
pytest tests/test_financial_datasets_server.py::test_get_income_statements -v
Test Coverage
The test suite covers:
- Financial statements: Income statements, balance sheets, cash flow statements (annual, quarterly, TTM)
- Stock prices: Historical price data with different intervals and cutoff date enforcement
- Company news: News article retrieval with date filtering
- Cryptocurrency: Available tickers, price data for multiple crypto pairs
- Error handling: Invalid tickers, date validation, API errors
- Edge cases: Large limits, different periods, interval multipliers
Note: Tests make real API calls and require a valid FINANCIAL_DATASETS_API_KEY. Tests will be skipped if the API key is not set. API rate limits may apply.
Dependencies
- fastmcp: MCP server framework
- httpx: Async HTTP client for API requests
- python-dotenv: Environment variable management
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。