finnhub-mcp-server
Real-time US-equity quotes, company fundamentals, earnings, analyst trends, and financial news via Finnhub. Supports STDIO and Streamable HTTP transports.
README
<div align="center"> <h1>@cyanheads/finnhub-mcp-server</h1> <p><b>Real-time US-equity quotes, company fundamentals, earnings, analyst trends, and financial news via Finnhub. STDIO or Streamable HTTP.</b> <div>6 Tools • 1 Resource</div> </p> </div>
<div align="center">
</div>
<div align="center">
</div>
Tools
Six tools, name-first: finnhub_search_symbols resolves a company name to a US ticker, then the other five work from that symbol — a live quote, full company context, earnings, news, and analyst consensus.
| Tool | Description |
|---|---|
finnhub_search_symbols |
Resolve a company name or partial ticker to US stock symbols, best US match first. The entry point for every other tool. |
finnhub_get_quote |
Real-time price quote for one US symbol, paired with live market-status so the response states whether the price is live or the prior close. |
finnhub_get_company |
Full company context in one call — profile, headline fundamentals (P/E, EPS, margins, growth), and sector peers. |
finnhub_get_earnings |
Earnings in two modes: a symbol's past quarters with actual-vs-estimate surprises (history), or market-wide upcoming releases in a date window (calendar). |
finnhub_get_news |
Financial news in two modes: recent articles for one symbol over a date range (company), or broad market headlines by category (market). |
finnhub_get_recommendations |
Analyst recommendation trends for one US symbol — strong-buy / buy / hold / sell / strong-sell counts per month, newest first. |
finnhub_search_symbols
Resolve a company name, partial name, or ticker fragment to Finnhub stock symbols. Run this first when you have a name, not a ticker — the rest of the surface needs a symbol.
- Full-text match across symbols and descriptions; US Common Stock matches surfaced first
- Each result carries
isLikelyUS(a dot-suffix heuristic —.SS,.T,.Lare international) so an agent can avoid spending a call on a symbol the free tier can't reach limit(1–50, default 10); reports the total match count and discloses truncation when more matched than returned
finnhub_get_quote
Real-time price quote for one US symbol. The market-hours flag is the point — the response never presents a stale price as live.
- Current price, absolute and percent change, session open/high/low, previous close, and an ISO 8601 quote time
- Pairs
/quotewith/stock/market-status(parallel fan-out) to derivepriceIsLive—trueonly when the US market is open; when closed,currentis the prior close, surfaced as such - Market-status failing degrades to
marketOpen: nullrather than tanking the quote - Unknown US ticker →
symbol_not_found; international or paid-only symbol →not_us_or_paid
finnhub_get_company
Full company context for one US symbol in a single call — profile is hollow without the valuation numbers, so this is deliberately one tool over three.
- Profile: name, exchange, industry, country, currency, market cap, shares outstanding, IPO date, website, logo
- Headline fundamentals: P/E (TTM), EPS (TTM), 52-week range, beta, dividend yield, net/gross margin, revenue growth YoY, ROE — every field nullable, surfaced honestly for thinly-covered names rather than zero-filled
- Sector peers from
/stock/peers(includes the queried symbol) - Combines three endpoints under a parallel fan-out; metrics or peers failing degrade to a
partiallist, profile drives the not-found / forbidden errors
finnhub_get_earnings
Earnings data for one symbol or across the market, selected by mode.
history(requiressymbol): past quarters — actual vs. estimate EPS, absolute surprise, and surprise % (the market-moving signal), newest firstcalendar(usesfrom/to, defaults to today through +14 days): upcoming releases across the market — date, EPS/revenue estimates, expected report timelimit(1–100, default 50); reports total rows and discloses truncation
finnhub_get_news
Financial news for one company or the broad market, selected by mode.
company(requiressymbol): recent articles over a date range (defaults to the last 7 days) — headline, source, ISO 8601 datetime, summary, URLmarket(usescategory): broad headlines bygeneral,forex,crypto, ormerger(see thefinnhub://news-categoriesresource)limit(1–50, default 15 — news lists run long); articles newest first, with total and truncation disclosure
finnhub_get_recommendations
Analyst recommendation consensus for one US symbol — the view to pair with the live quote and fundamentals.
- Per-month strong-buy / buy / hold / sell / strong-sell counts, newest first (typically 12–24 months of history)
limit(1–24, default 12 — one year); reports total months and discloses truncation- Empty result (no analyst coverage) →
no_coverage, distinct from an invalid symbol
Resource
| Type | Name | Description |
|---|---|---|
| Resource | finnhub://news-categories |
The four valid market-news categories (general, forex, crypto, merger) with one-line descriptions. |
The resource is a convenience mirror — its data is fully covered by the category enum on finnhub_get_news, so tool-only clients lose nothing. Live data (quotes, news, earnings) is intentionally not exposed as a resource: it's time-sensitive, and the value is in the freshness, so it's reachable only through the tools.
Features
Built on @cyanheads/mcp-ts-core:
- Declarative tool and resource definitions — single file per primitive, framework handles registration and validation
- Unified error handling — handlers throw, framework catches, classifies, and formats
- Pluggable auth:
none,jwt,oauth - Swappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1 - Structured logging with optional OpenTelemetry tracing
- STDIO and Streamable HTTP transports
Finnhub-specific:
- Single rate-aware Finnhub client — token injected server-side (never a tool input), with timeout and retry calibrated to the 60 req/min free tier
- Live market-status pairing on quotes so a closed-market price is reported as the prior close, never as live
- Status classification at the service boundary: 403 → a clear
not_us_or_paiddomain error, 401 → loud configuration failure at first call (not "no data"), 429/5xx → retried finnhub_get_companyfans out profile + metrics + peers in parallel and degrades to partial results when a leg fails
Agent-friendly output:
- Honest sparsity — every fundamental is nullable and absent values stay null; Finnhub's thinly-covered names are surfaced as-is, never zero-filled or fabricated
- Two distinct "not available" signals —
symbol_not_found(unknown US ticker, detected from the all-zero quote / empty profile sentinel) vs.not_us_or_paid(international or paid-only, HTTP 403) — so an agent can tell them apart and recover - Typed error contracts with recovery hints on every failure, plus
isLikelyUSon search results so an agent avoids burning a call on an unreachable symbol - Capped lists report their total count and disclose truncation, so an agent knows when more data exists
Getting started
This server requires a free Finnhub API key (Dashboard → API key). The free tier covers US equities in real time at 60 req/min.
Each user must obtain their own API key. Use is subject to Finnhub's Terms of Service — the free tier is for personal use only, and redistributing or sharing access to Finnhub data with third parties requires written approval from Finnhub.
Add the following to your MCP client configuration file.
{
"mcpServers": {
"finnhub-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/finnhub-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"FINNHUB_API_KEY": "your-api-key"
}
}
}
}
Or with npx (no Bun required):
{
"mcpServers": {
"finnhub-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/finnhub-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"FINNHUB_API_KEY": "your-api-key"
}
}
}
}
Or with Docker:
{
"mcpServers": {
"finnhub-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"-e", "FINNHUB_API_KEY=your-api-key",
"ghcr.io/cyanheads/finnhub-mcp-server:latest"
]
}
}
}
For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 FINNHUB_API_KEY=... bun run start:http
# Server listens at http://localhost:3010/mcp
Prerequisites
- Bun v1.3.0 or higher (or Node.js v24+).
- A free Finnhub API key. The free tier is US equities only, real-time, 60 req/min — international symbols (any exchange-suffixed ticker like
.TOor.DE) and candle/forex endpoints are paid-tier and return a clear error.
Installation
- Clone the repository:
git clone https://github.com/cyanheads/finnhub-mcp-server.git
- Navigate into the directory:
cd finnhub-mcp-server
- Install dependencies:
bun install
- Configure environment:
cp .env.example .env
# edit .env and set FINNHUB_API_KEY
Configuration
All configuration is validated at startup via Zod schemas in src/config/server-config.ts. Key environment variables:
| Variable | Description | Default |
|---|---|---|
FINNHUB_API_KEY |
Required. Free Finnhub API key from finnhub.io/register. Sent as the token query param; the server fails to start without it. |
— |
FINNHUB_BASE_URL |
Finnhub REST API base URL. Override for local testing or a proxy. | https://finnhub.io/api/v1 |
MCP_TRANSPORT_TYPE |
Transport: stdio or http. |
stdio |
MCP_HTTP_PORT |
Port for the HTTP server. | 3010 |
MCP_HTTP_ENDPOINT_PATH |
HTTP endpoint path where the MCP server is mounted. | /mcp |
MCP_AUTH_MODE |
Auth mode: none, jwt, or oauth. |
none |
MCP_LOG_LEVEL |
Log level (RFC 5424: debug, info, notice, warning, error). |
info |
STORAGE_PROVIDER_TYPE |
Storage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1. |
in-memory |
OTEL_ENABLED |
Enable OpenTelemetry instrumentation (spans, metrics, completion logs). | false |
See .env.example for the full list of optional overrides.
Running the server
Local development
-
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:http -
Run checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t finnhub-mcp-server .
docker run --rm -e MCP_TRANSPORT_TYPE=http -e FINNHUB_API_KEY=your-key -p 3010:3010 finnhub-mcp-server
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/finnhub-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
| Directory | Purpose |
|---|---|
src/index.ts |
createApp() entry point — registers tools/resources and inits the Finnhub service. |
src/config |
Server-specific environment variable parsing and validation with Zod. |
src/mcp-server/tools |
Tool definitions (*.tool.ts). Six tools across symbols, quotes, company, earnings, news, and recommendations. |
src/mcp-server/resources |
Resource definitions (*.resource.ts). News-categories reference. |
src/services/finnhub |
Finnhub REST client — auth, typed endpoint methods, retry, and HTTP-status classification. |
tests/ |
Unit and integration tests mirroring src/. |
Development guide
See CLAUDE.md / AGENTS.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storage - Register new tools and resources via the barrels in
src/mcp-server/*/definitions/index.ts - Wrap the Finnhub API: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
License
Apache-2.0 — see LICENSE for details.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。