mcpField
F
finnhub-mcp-server

finnhub-mcp-server

Local
github.com/cyanheadsFinance1Updated 3w ago

About finnhub-mcp-server

finnhub-mcp-server serves Finnhub US-equity data for analysts and investment researchers, including quotes, company fundamentals, earnings, recommendations, and news. Quotes include market status, while company lookups can return partial results when some metrics are unavailable.

Key features

  1. 01Search companies by name or ticker
  2. 02Retrieve quotes with market status
  3. 03Fetch fundamentals and sector peers
  4. 04Get historical and upcoming earnings
  5. 05Search company and market news
  6. 06Review analyst recommendation trends

Use cases

  1. 01Check a US stock price and trading session
  2. 02Inspect company valuation metrics and sector peers
  3. 03Track earnings results and upcoming release dates
  4. 04Review company news or broad market headlines

MCP support

As an MCP server, it exposes Finnhub stock-data query tools and a news-category resource to clients. It supports STDIO and Streamable HTTP and requires a Finnhub API key.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"cyanheads-finnhub": {
"command": "npx",
"args": [
"-y",
"@cyanheads/finnhub-mcp-server"
],
"env": {
"FINNHUB_API_KEY": "<FINNHUB_API_KEY>",
"FINNHUB_BASE_URL": "<FINNHUB_BASE_URL>",
"MCP_LOG_LEVEL": "<MCP_LOG_LEVEL>",
"MCP_TRANSPORT_TYPE": "<MCP_TRANSPORT_TYPE>",
"MCP_HTTP_HOST": "<MCP_HTTP_HOST>",
"MCP_HTTP_PORT": "<MCP_HTTP_PORT>",
"MCP_HTTP_ENDPOINT_PATH": "<MCP_HTTP_ENDPOINT_PATH>",
"MCP_AUTH_MODE": "<MCP_AUTH_MODE>"
}
}
}
}
Run commandnpx -y @cyanheads/finnhub-mcp-server
Environment variables to set
FINNHUB_API_KEYSecretRequired. Free Finnhub API key from https://finnhub.io/register (Dashboard → API key). Free tier: 60 req/min, US real-time.
FINNHUB_BASE_URLOverride the Finnhub REST API base URL (local testing / proxy).
MCP_LOG_LEVELSets the minimum log level for output (e.g., 'debug', 'info', 'warn').
MCP_TRANSPORT_TYPESelects the HTTP transport.
MCP_HTTP_HOSTThe hostname for the HTTP server.
MCP_HTTP_PORTThe port to run the HTTP server on.
MCP_HTTP_ENDPOINT_PATHThe endpoint path for the MCP server.
MCP_AUTH_MODESecretAuthentication mode to use: 'none', 'jwt', or 'oauth'.

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@cyanheads/finnhub-mcp-server0.1.6

Tools

6

Saved tool list · updated 2w ago

ParameterTypeRequiredDescription
limitintegerNoMax symbols to return (Finnhub often returns 10–50 matches for a common word). Default 10. Likely-US Common Stock matches are surfaced first.
querystringYesCompany name (e.g., "Apple"), partial name ("micro"), or ticker fragment, up to 20 characters. Finnhub full-text matches across symbols and descriptions. Use this first when you have a company name, not a ticker — the rest of the tools need a symbol.

Details

From the project README

@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

Version License Docker MCP SDK npm TypeScript Bun

Install in Claude Desktop Install in Cursor Install in VS Code

Framework


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.

Tools
ToolDescription
finnhub_search_symbolsResolve a company name or partial ticker to stock symbols, best likely-US match first. The entry point for every other tool.
finnhub_get_quoteReal-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_companyFull company context in one call — profile, headline fundamentals (P/E, EPS, margins, growth), and sector peers.
finnhub_get_earningsEarnings 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_newsFinancial news in two modes: recent articles for one symbol over a date range (company), or broad market headlines by category (market).
finnhub_get_recommendationsAnalyst recommendation trends for one US symbol — strong-buy / buy / hold / sell / strong-sell counts per month, newest first.
Resources
ResourceDescription
finnhub://news-categoriesThe 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

finnhub_search_symbols tool
  • Search by company name or ticker fragment with query (1–20 characters) and limit (1–50, default 10).
  • Returns likely-US Common Stock matches first, with an isLikelyUS symbol-format heuristic, total match count, and truncation disclosure. Quote and profile responses remain authoritative.

finnhub_get_quote tool
  • Requires symbol; returns current price, change, session open/high/low, previous close, and an ISO 8601 quote time.
  • priceIsLive distinguishes a live price from the prior close; marketOpen, session, and holiday are nullable when market status is unavailable. Unknown ticker → symbol_not_found; international or paid-only symbol → not_us_or_paid.

finnhub_get_company tool
  • Requires symbol; returns company profile, nullable headline fundamentals (P/E, EPS, 52-week range, beta, dividend yield, margins, growth, ROE), and sector peers.
  • Failed metrics or peers appear in partial; the profile determines symbol_not_found and not_us_or_paid errors.

finnhub_get_earnings tool
  • history requires symbol and returns past quarters' actual/estimate EPS and surprise, newest first. calendar accepts from / to (default today through +14 days) and an optional symbol, returning release dates, EPS/revenue estimates, and report times.
  • limit (1–100, default 50) caps rows with total and truncation disclosure. History without a symbol → missing_symbol; international or paid-only symbol → not_us_or_paid.

finnhub_get_news tool
  • company requires symbol and accepts a date range (default last 7 days). market uses category: general, forex, crypto, or merger (see finnhub://news-categories).
  • Returns headline, source, ISO 8601 datetime, summary, and URL, newest first. limit (1–100, default 15) caps articles with total and truncation disclosure; company mode without a symbol → missing_symbol, international or paid-only symbol → not_us_or_paid.

finnhub_get_recommendations tool
  • 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
# Server listens at http://localhost:3010/mcp
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
  1. Clone the repository:
git clone https://github.com/cyanheads/finnhub-mcp-server.git
  1. Navigate into the directory:
cd finnhub-mcp-server
  1. Install dependencies:
bun install
  1. 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:

VariableDescriptionDefault
FINNHUB_API_KEYRequired. Free Finnhub API key from finnhub.io/register. Sent as the token query param; the server fails to start without it.—
FINNHUB_BASE_URLFinnhub REST API base URL. Override for local testing or a proxy.https://finnhub.io/api/v1
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTPort for the HTTP server.3010
MCP_HTTP_ENDPOINT_PATHHTTP endpoint path where the MCP server is mounted./mcp
MCP_SESSION_MODESession 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_MODEAuth mode: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (RFC 5424: debug, info, notice, warning, error).info
LOG_TOOL_FAILURE_PAYLOADSLog failed tool calls' arguments and results, redacted by key name and capped at LOG_TOOL_FAILURE_PAYLOAD_MAX_BYTES (default 16384). Secrets inside free-form values are not redacted.false
STORAGE_PROVIDER_TYPEStorage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1.in-memory
OTEL_ENABLEDEnable OpenTelemetry instrumentation (spans, metrics, completion logs).false
OTEL_EXPORTER_OTLP_ENDPOINTOTLP base URL for traces (/v1/traces) and metrics (/v1/metrics); signal-specific endpoints override it.—
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTOpt-in OTLP log endpoint, used as-is. The base URL does not enable log export.—

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

DirectoryPurpose
src/index.tscreateApp() entry point — registers tools/resources and inits the Finnhub service.
src/configServer-specific environment variable parsing and validation with Zod.
src/mcp-server/toolsTool definitions (*.tool.ts). Six tools across symbols, quotes, company, earnings, news, and recommendations.
src/mcp-server/resourcesResource definitions (*.resource.ts). News-categories reference.
src/services/finnhubFinnhub 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.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.