@cyanheads/finnhub-mcp-server
Real-time US-equity quotes, company fundamentals, earnings, analyst trends, and financial news via Finnhub. STDIO or Streamable HTTP.
6 Tools โข 1 Resource
Overview
Real-time US-equity data from Finnhub โ quotes, company fundamentals, earnings, analyst recommendations, and financial news. Resolve a company name to a symbol with finnhub_search_symbols, then pull live pricing, valuation, or news for it from any MCP client. Runs as a stdio process or a local Streamable HTTP server.
| Tool | Description |
|---|
finnhub_search_symbols | Resolve a company name or partial ticker to stock symbols, best likely-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, including the returned session and named holiday. |
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 upcoming releases in a date window with an optional symbol filter (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. |
Resources
| Resource | Description |
|---|
finnhub://news-categories | The four valid market-news categories (general, forex, crypto, merger) with one-line descriptions. |
Fully covered by the category enum on finnhub_get_news, so tool-only clients lose nothing.
Capability reference
- Full-text match across symbols and descriptions; likely-US Common Stock matches surfaced first
query accepts 1โ20 characters; use a shorter company name or ticker fragment when needed
- Each result carries
isLikelyUS, a symbol-format heuristic: plain tickers and .A/.B class shares are likely US, while exchange suffixes such as .SS, .T, and .L are not. Quote and profile responses remain authoritative
limit (1โ50, default 10); reports the total match count and discloses truncation when more matched than returned
- Current price, absolute and percent change, session open/high/low, previous close, and an ISO 8601 quote time
- Pairs
/quote with /stock/market-status (parallel fan-out) to derive priceIsLive โ true only when the US market is open; when closed, current is the prior close, surfaced as such
- Exposes Finnhub's nullable
session (pre-market, regular, or post-market) and returned holiday event name without inferring either value
- Market-status failing degrades to
marketOpen: null, session: null, and holiday: null rather than tanking the quote
- Unknown US ticker โ
symbol_not_found; international or paid-only symbol โ not_us_or_paid
- 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
partial list, profile drives the not-found / forbidden errors
history (requires symbol): past quarters โ actual vs. estimate EPS, absolute surprise, and surprise % (the market-moving signal), newest first
calendar (uses from / to, defaults to today through +14 days; optional symbol filter): upcoming releases across the market or for one symbol โ date, EPS/revenue estimates, expected report time
limit (1โ100, default 50); reports total rows and discloses truncation
history without symbol โ missing_symbol; international or paid-only symbol โ not_us_or_paid
company (requires symbol): recent articles over a date range (defaults to the last 7 days) โ headline, source, ISO 8601 datetime, summary, URL
market (uses category): broad headlines by general, forex, crypto, or merger (see the finnhub://news-categories resource)
limit (1โ100, default 15 โ news lists run long); articles newest first, with total and truncation disclosure
company without symbol โ missing_symbol; international or paid-only symbol โ not_us_or_paid
- 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; international or paid-only symbol โ not_us_or_paid
finnhub://news-categories resource
- Returns the four valid
finnhub_get_news market-mode categories (general, forex, crypto, merger) with one-line descriptions, as application/json
- Convenience mirror โ fully covered by the
category enum's .describe() 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, so freshness lives only in the tools
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
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_paid domain error, 401 โ loud configuration failure at first call (not "no data"), 429/5xx โ retried
finnhub_get_company fans 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 the
isLikelyUS search heuristic so an agent can prioritize likely free-tier symbols
- 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_SESSION_MODE=stateless MCP_HTTP_PORT=3010 FINNHUB_API_KEY=... bun run start:http
Prerequisites
- Bun v1.4.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
.TO or .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:
- Install dependencies:
- Configure environment:
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_SESSION_MODE | Session handling: auto, stateful, or stateless. The server declares stateless in src/index.ts, so an unset variable resolves there; .env.example and the Docker image set it explicitly too. An explicit environment value takes precedence. | stateless |
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:
bun run rebuild
bun run start:stdio
bun run start:http
-
Run checks and tests:
bun run devcheck
bun run test
bun run lint:mcp
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/catch in tool logic
- Use
ctx.log for request-scoped logging, ctx.state for 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 are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
License
Apache-2.0 โ see LICENSE for details.