Financial Hub MCP Server
A TypeScript MCP server for financial data aggregation. Connects any MCP-compatible AI assistant to SEC EDGAR filings, XBRL financial statements, FRED economic indicators, and real-time market data — with built-in XBRL normalization, fact deduplication, computed analytics, stock screening, and rate-limit protection.
Core Concepts
SEC EDGAR
All SEC EDGAR data comes directly from the SEC's free public APIs at data.sec.gov. No API key is required. The server automatically handles:
- XBRL concept resolution — Different companies use different XBRL tags for the same metric. The server normalizes across 20+ financial concepts (e.g.,
revenue resolves to Revenues, RevenueFromContractWithCustomerExcludingAssessedTax, SalesRevenueNet, and 11 other variants).
- Fact deduplication — Raw XBRL data contains duplicate values from overlapping 10-K/10-Q filings and amendments. The server collapses these to one clean value per fiscal period.
- Rate limiting — SEC enforces 10 requests/second. A token-bucket rate limiter with bounded queuing (max 50 pending, 30s timeout) prevents IP bans.
FRED
FRED (Federal Reserve Economic Data) provides 800,000+ time series from 100+ sources. Requires a free API key from fred.stlouisfed.org. Rate limited to 120 requests/minute (enforced via 2 req/s token bucket). Includes a curated catalog of ~50 essential economic indicators across 9 categories for zero-API-call browsing.
Finnhub Market Data
Real-time stock quotes, company profiles, market news, insider transactions, and financial metrics via the Finnhub API. Free tier provides 30 API calls/second with no credit card required. The server rate-limits to 25 req/s to stay safely under the threshold. Quotes are never cached (stale prices are worse than no cache), while profiles (24h), news (5min), and financial metrics (1h) use appropriate TTLs.
Caching
In-memory LRU cache with TTL expiry reduces redundant API calls:
| Company facts | 1 hour | 10 | 20-50 MB each |
| Company submissions | 1 hour | 30 | ~50 KB each |
| Company tickers | 24 hours | 1 | ~3 MB |
| FRED series metadata | 6 hours | 100 | ~1 KB each |
| FRED observations | 1 hour | 50 | ~5 KB each |
| Market profiles | 24 hours | 50 | ~1 KB each |
| Market news | 5 minutes | 10 | ~5 KB each |
| Insider transactions | 1 hour | 30 | ~3 KB each |
| Basic financials | 1 hour | 30 | ~2 KB each |
Eviction is LRU — frequently accessed entries are promoted on read, so the least recently used entry is evicted when capacity is full. Expired entries are proactively swept on every write.
API
Tools
Resources
Prompts
-
financial_analysis
- Guided company financial health analysis
- Input:
ticker (string)
- Walks through revenue trends, profitability, balance sheet health, and risk assessment
-
peer_comparison
- Side-by-side comparison of two companies
- Input:
ticker1 (string), ticker2 (string)
-
economic_overview
- Current US economic conditions dashboard
- No input required
- Pulls GDP, unemployment, CPI, fed funds rate, treasury yields, and mortgage rates
Tool Annotations
All tools set MCP ToolAnnotations for safe agent composition:
readOnlyHint | true | All tools are read-only — no data is modified |
destructiveHint | false | No data destruction |
idempotentHint | true | Same inputs produce same outputs |
openWorldHint | true | All tools make external API calls |
Error Handling
All tools return MCP-compliant error envelopes with isError: true on failure:
{
"content": [{ "type": "text", "text": "SEC EDGAR request failed: 404 Not Found" }],
"isError": true
}
This allows the LLM to receive semantic error messages, correct parameters, and retry — rather than receiving opaque transport-level JSON-RPC errors that break the agent loop.
Usage with Claude Desktop
Add this to your claude_desktop_config.json:
NPX
{
"mcpServers": {
"financial-hub": {
"command": "npx",
"args": ["-y", "financial-hub-mcp"],
"env": {
"FRED_API_KEY": "your-free-api-key",
"SEC_USER_AGENT_EMAIL": "your-email@example.com",
"FINNHUB_API_KEY": "your-free-api-key"
}
}
}
}
Usage with VS Code
For manual installation, add the configuration to your user-level MCP configuration file. Open the Command Palette (Ctrl + Shift + P) and run MCP: Open User Configuration, then add:
NPX
{
"servers": {
"financial-hub": {
"command": "npx",
"args": ["-y", "financial-hub-mcp"],
"env": {
"FRED_API_KEY": "your-free-api-key",
"SEC_USER_AGENT_EMAIL": "your-email@example.com",
"FINNHUB_API_KEY": "your-free-api-key"
}
}
}
}
For more details about MCP configuration in VS Code, see the official VS Code MCP documentation.
Environment Variables
SEC_USER_AGENT_EMAIL | Yes | Your email address for SEC EDGAR API compliance. The server will exit immediately if this is not set — SEC EDGAR bans requests with missing or generic User-Agent headers. |
FRED_API_KEY | For FRED tools | Free 32-character key from fred.stlouisfed.org. The server starts without it but FRED tools will fail at runtime with a clear error message. |
FINNHUB_API_KEY | For market tools | Free API key from finnhub.io. Required for stock quotes, market news, insider transactions, and company overviews. The server starts without it but market tools will fail at runtime. |
Architecture
src/
├── index.ts # Entry point — startup validation, MCP server init
├── rate-limiter.ts # Token-bucket rate limiter with bounded queue + timeout
├── cache.ts # In-memory TTL cache with proactive eviction
├── edgar/
│ ├── client.ts # SEC EDGAR HTTP client (rate-limited, cached)
│ ├── tools.ts # MCP tool registrations (12 tools, isError envelopes)
│ ├── resources.ts # MCP resource templates (company profiles)
│ ├── xbrl.ts # XBRL fact deduplication, growth, trend detection
│ ├── concepts.ts # Concept alias normalization (20+ financial concepts)
│ ├── analytics.ts # Computed ratios, health scoring, company comparison
│ ├── events.ts # 8-K corporate event classification (25 item types)
│ └── screening.ts # Stock screening by exchange, industry, health score
├── fred/
│ ├── client.ts # FRED HTTP client (rate-limited, cached)
│ ├── tools.ts # FRED MCP tool registrations
│ ├── catalog.ts # Curated catalog of ~50 essential FRED indicators
│ └── resources.ts # FRED MCP resource templates (catalog + indicators)
├── market/
│ ├── client.ts # Finnhub HTTP client (rate-limited, cached)
│ └── tools.ts # Market data MCP tool registrations (4 tools)
└── prompts.ts # Financial analysis prompt templates
Data Pipeline
Raw XBRL data from SEC EDGAR goes through several processing stages:
- Rate-limited fetch — Token bucket ensures SEC's 10 req/s limit is never exceeded. Queue rejects after 50 pending requests or 30s wait.
- Caching — Company facts cached for 1 hour, max 15 entries to avoid OOM on large payloads.
- Concept resolution — Friendly names like
revenue are mapped to all known XBRL tag variants across the us-gaap taxonomy.
- Deduplication — Overlapping 10-K/10-Q/amendment values are collapsed to one per fiscal period. Prefers 10-K over 10-Q, latest filing date over earlier.
- Analysis — Growth rates, CAGR, financial ratios, and health scores are computed from clean data.
- Serialization — Minified JSON output to minimize context window usage.
Building from Source
git clone https://github.com/ykshah1309/financial-hub-mcp.git
cd financial-hub-mcp
npm install
npm run build
Run locally:
FRED_API_KEY=your-key SEC_USER_AGENT_EMAIL=your-email FINNHUB_API_KEY=your-key node dist/index.js
Contributing
Pull requests welcome. See CONTRIBUTING.md for the development loop, commit style, and PR checklist. By participating you agree to the Code of Conduct.
Security
Please report security issues privately — see SECURITY.md. Do not file public issues for vulnerabilities or credential leaks.
Changelog
See CHANGELOG.md for release notes.
License
MIT — see LICENSE.
Badges
