@cyanheads/finnhub-mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/AGENTS.md +376 -0
  2. package/CLAUDE.md +376 -0
  3. package/Dockerfile +121 -0
  4. package/LICENSE +201 -0
  5. package/README.md +314 -0
  6. package/changelog/0.1.x/0.1.0.md +22 -0
  7. package/changelog/template.md +127 -0
  8. package/dist/config/server-config.d.ts +25 -0
  9. package/dist/config/server-config.d.ts.map +1 -0
  10. package/dist/config/server-config.js +37 -0
  11. package/dist/config/server-config.js.map +1 -0
  12. package/dist/index.d.ts +8 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +21 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/mcp-server/resources/definitions/index.d.ts +12 -0
  17. package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
  18. package/dist/mcp-server/resources/definitions/index.js +8 -0
  19. package/dist/mcp-server/resources/definitions/index.js.map +1 -0
  20. package/dist/mcp-server/resources/definitions/news-categories.resource.d.ts +16 -0
  21. package/dist/mcp-server/resources/definitions/news-categories.resource.d.ts.map +1 -0
  22. package/dist/mcp-server/resources/definitions/news-categories.resource.js +45 -0
  23. package/dist/mcp-server/resources/definitions/news-categories.resource.js.map +1 -0
  24. package/dist/mcp-server/tools/definitions/get-company.tool.d.ts +51 -0
  25. package/dist/mcp-server/tools/definitions/get-company.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/get-company.tool.js +191 -0
  27. package/dist/mcp-server/tools/definitions/get-company.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/get-earnings.tool.d.ts +59 -0
  29. package/dist/mcp-server/tools/definitions/get-earnings.tool.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/get-earnings.tool.js +201 -0
  31. package/dist/mcp-server/tools/definitions/get-earnings.tool.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/get-news.tool.d.ts +55 -0
  33. package/dist/mcp-server/tools/definitions/get-news.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/get-news.tool.js +160 -0
  35. package/dist/mcp-server/tools/definitions/get-news.tool.js.map +1 -0
  36. package/dist/mcp-server/tools/definitions/get-quote.tool.d.ts +35 -0
  37. package/dist/mcp-server/tools/definitions/get-quote.tool.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/get-quote.tool.js +132 -0
  39. package/dist/mcp-server/tools/definitions/get-quote.tool.js.map +1 -0
  40. package/dist/mcp-server/tools/definitions/get-recommendations.tool.d.ts +38 -0
  41. package/dist/mcp-server/tools/definitions/get-recommendations.tool.d.ts.map +1 -0
  42. package/dist/mcp-server/tools/definitions/get-recommendations.tool.js +110 -0
  43. package/dist/mcp-server/tools/definitions/get-recommendations.tool.js.map +1 -0
  44. package/dist/mcp-server/tools/definitions/index.d.ts +209 -0
  45. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  46. package/dist/mcp-server/tools/definitions/index.js +20 -0
  47. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  48. package/dist/mcp-server/tools/definitions/search-symbols.tool.d.ts +26 -0
  49. package/dist/mcp-server/tools/definitions/search-symbols.tool.d.ts.map +1 -0
  50. package/dist/mcp-server/tools/definitions/search-symbols.tool.js +101 -0
  51. package/dist/mcp-server/tools/definitions/search-symbols.tool.js.map +1 -0
  52. package/dist/services/finnhub/finnhub-service.d.ts +77 -0
  53. package/dist/services/finnhub/finnhub-service.d.ts.map +1 -0
  54. package/dist/services/finnhub/finnhub-service.js +148 -0
  55. package/dist/services/finnhub/finnhub-service.js.map +1 -0
  56. package/dist/services/finnhub/types.d.ts +147 -0
  57. package/dist/services/finnhub/types.d.ts.map +1 -0
  58. package/dist/services/finnhub/types.js +9 -0
  59. package/dist/services/finnhub/types.js.map +1 -0
  60. package/package.json +85 -0
  61. package/server.json +125 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Casey Hand @cyanheads
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ <div align="center">
2
+ <h1>@cyanheads/finnhub-mcp-server</h1>
3
+ <p><b>Real-time US-equity quotes, company fundamentals, earnings, analyst trends, and financial news via Finnhub. STDIO or Streamable HTTP.</b>
4
+ <div>6 Tools • 1 Resource</div>
5
+ </p>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+ [![Version](https://img.shields.io/badge/Version-0.1.0-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/finnhub-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/finnhub-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/finnhub-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
+
12
+ </div>
13
+
14
+ <div align="center">
15
+
16
+ [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/finnhub-mcp-server/releases/latest/download/finnhub-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=finnhub-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvZmlubmh1Yi1tY3Atc2VydmVyIl0sImVudiI6eyJGSU5OSFVCX0FQSV9LRVkiOiJ5b3VyLWFwaS1rZXkifX0=) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22finnhub-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Ffinnhub-mcp-server%22%5D%2C%22env%22%3A%7B%22FINNHUB_API_KEY%22%3A%22your-api-key%22%7D%7D)
17
+
18
+ [![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## Tools
25
+
26
+ 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.
27
+
28
+ | Tool | Description |
29
+ |:---|:---|
30
+ | `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. |
31
+ | `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. |
32
+ | `finnhub_get_company` | Full company context in one call — profile, headline fundamentals (P/E, EPS, margins, growth), and sector peers. |
33
+ | `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`). |
34
+ | `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`). |
35
+ | `finnhub_get_recommendations` | Analyst recommendation trends for one US symbol — strong-buy / buy / hold / sell / strong-sell counts per month, newest first. |
36
+
37
+ ### `finnhub_search_symbols`
38
+
39
+ 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.
40
+
41
+ - Full-text match across symbols and descriptions; US Common Stock matches surfaced first
42
+ - Each result carries `isLikelyUS` (a dot-suffix heuristic — `.SS`, `.T`, `.L` are international) so an agent can avoid spending a call on a symbol the free tier can't reach
43
+ - `limit` (1–50, default 10); reports the total match count and discloses truncation when more matched than returned
44
+
45
+ ---
46
+
47
+ ### `finnhub_get_quote`
48
+
49
+ Real-time price quote for one US symbol. The market-hours flag is the point — the response never presents a stale price as live.
50
+
51
+ - Current price, absolute and percent change, session open/high/low, previous close, and an ISO 8601 quote time
52
+ - 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
53
+ - Market-status failing degrades to `marketOpen: null` rather than tanking the quote
54
+ - Unknown US ticker → `symbol_not_found`; international or paid-only symbol → `not_us_or_paid`
55
+
56
+ ---
57
+
58
+ ### `finnhub_get_company`
59
+
60
+ 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.
61
+
62
+ - Profile: name, exchange, industry, country, currency, market cap, shares outstanding, IPO date, website, logo
63
+ - 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
64
+ - Sector peers from `/stock/peers` (includes the queried symbol)
65
+ - Combines three endpoints under a parallel fan-out; metrics or peers failing degrade to a `partial` list, profile drives the not-found / forbidden errors
66
+
67
+ ---
68
+
69
+ ### `finnhub_get_earnings`
70
+
71
+ Earnings data for one symbol or across the market, selected by `mode`.
72
+
73
+ - `history` (requires `symbol`): past quarters — actual vs. estimate EPS, absolute surprise, and surprise % (the market-moving signal), newest first
74
+ - `calendar` (uses `from` / `to`, defaults to today through +14 days): upcoming releases across the market — date, EPS/revenue estimates, expected report time
75
+ - `limit` (1–100, default 50); reports total rows and discloses truncation
76
+
77
+ ---
78
+
79
+ ### `finnhub_get_news`
80
+
81
+ Financial news for one company or the broad market, selected by `mode`.
82
+
83
+ - `company` (requires `symbol`): recent articles over a date range (defaults to the last 7 days) — headline, source, ISO 8601 datetime, summary, URL
84
+ - `market` (uses `category`): broad headlines by `general`, `forex`, `crypto`, or `merger` (see the `finnhub://news-categories` resource)
85
+ - `limit` (1–50, default 15 — news lists run long); articles newest first, with total and truncation disclosure
86
+
87
+ ---
88
+
89
+ ### `finnhub_get_recommendations`
90
+
91
+ Analyst recommendation consensus for one US symbol — the view to pair with the live quote and fundamentals.
92
+
93
+ - Per-month strong-buy / buy / hold / sell / strong-sell counts, newest first (typically 12–24 months of history)
94
+ - `limit` (1–24, default 12 — one year); reports total months and discloses truncation
95
+ - Empty result (no analyst coverage) → `no_coverage`, distinct from an invalid symbol
96
+
97
+ ## Resource
98
+
99
+ | Type | Name | Description |
100
+ |:---|:---|:---|
101
+ | Resource | `finnhub://news-categories` | The four valid market-news categories (`general`, `forex`, `crypto`, `merger`) with one-line descriptions. |
102
+
103
+ 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.
104
+
105
+ ## Features
106
+
107
+ Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
108
+
109
+ - Declarative tool and resource definitions — single file per primitive, framework handles registration and validation
110
+ - Unified error handling — handlers throw, framework catches, classifies, and formats
111
+ - Pluggable auth: `none`, `jwt`, `oauth`
112
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
113
+ - Structured logging with optional OpenTelemetry tracing
114
+ - STDIO and Streamable HTTP transports
115
+
116
+ Finnhub-specific:
117
+
118
+ - 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
119
+ - Live market-status pairing on quotes so a closed-market price is reported as the prior close, never as live
120
+ - 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
121
+ - `finnhub_get_company` fans out profile + metrics + peers in parallel and degrades to partial results when a leg fails
122
+
123
+ Agent-friendly output:
124
+
125
+ - 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
126
+ - 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
127
+ - Typed error contracts with recovery hints on every failure, plus `isLikelyUS` on search results so an agent avoids burning a call on an unreachable symbol
128
+ - Capped lists report their total count and disclose truncation, so an agent knows when more data exists
129
+
130
+ ## Getting started
131
+
132
+ This server requires a free [Finnhub API key](https://finnhub.io/register) (Dashboard → API key). The free tier covers US equities in real time at 60 req/min.
133
+
134
+ Each user must obtain their own API key. Use is subject to [Finnhub's Terms of Service](https://finnhub.io/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.
135
+
136
+ Add the following to your MCP client configuration file.
137
+
138
+ ```json
139
+ {
140
+ "mcpServers": {
141
+ "finnhub-mcp-server": {
142
+ "type": "stdio",
143
+ "command": "bunx",
144
+ "args": ["@cyanheads/finnhub-mcp-server@latest"],
145
+ "env": {
146
+ "MCP_TRANSPORT_TYPE": "stdio",
147
+ "MCP_LOG_LEVEL": "info",
148
+ "FINNHUB_API_KEY": "your-api-key"
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ Or with npx (no Bun required):
156
+
157
+ ```json
158
+ {
159
+ "mcpServers": {
160
+ "finnhub-mcp-server": {
161
+ "type": "stdio",
162
+ "command": "npx",
163
+ "args": ["-y", "@cyanheads/finnhub-mcp-server@latest"],
164
+ "env": {
165
+ "MCP_TRANSPORT_TYPE": "stdio",
166
+ "MCP_LOG_LEVEL": "info",
167
+ "FINNHUB_API_KEY": "your-api-key"
168
+ }
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ Or with Docker:
175
+
176
+ ```json
177
+ {
178
+ "mcpServers": {
179
+ "finnhub-mcp-server": {
180
+ "type": "stdio",
181
+ "command": "docker",
182
+ "args": [
183
+ "run", "-i", "--rm",
184
+ "-e", "MCP_TRANSPORT_TYPE=stdio",
185
+ "-e", "FINNHUB_API_KEY=your-api-key",
186
+ "ghcr.io/cyanheads/finnhub-mcp-server:latest"
187
+ ]
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ For Streamable HTTP, set the transport and start the server:
194
+
195
+ ```sh
196
+ MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 FINNHUB_API_KEY=... bun run start:http
197
+ # Server listens at http://localhost:3010/mcp
198
+ ```
199
+
200
+ ### Prerequisites
201
+
202
+ - [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).
203
+ - A free [Finnhub API key](https://finnhub.io/register). 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.
204
+
205
+ ### Installation
206
+
207
+ 1. **Clone the repository:**
208
+
209
+ ```sh
210
+ git clone https://github.com/cyanheads/finnhub-mcp-server.git
211
+ ```
212
+
213
+ 2. **Navigate into the directory:**
214
+
215
+ ```sh
216
+ cd finnhub-mcp-server
217
+ ```
218
+
219
+ 3. **Install dependencies:**
220
+
221
+ ```sh
222
+ bun install
223
+ ```
224
+
225
+ 4. **Configure environment:**
226
+
227
+ ```sh
228
+ cp .env.example .env
229
+ # edit .env and set FINNHUB_API_KEY
230
+ ```
231
+
232
+ ## Configuration
233
+
234
+ All configuration is validated at startup via Zod schemas in `src/config/server-config.ts`. Key environment variables:
235
+
236
+ | Variable | Description | Default |
237
+ |:---|:---|:---|
238
+ | `FINNHUB_API_KEY` | **Required.** Free Finnhub API key from [finnhub.io/register](https://finnhub.io/register). Sent as the `token` query param; the server fails to start without it. | — |
239
+ | `FINNHUB_BASE_URL` | Finnhub REST API base URL. Override for local testing or a proxy. | `https://finnhub.io/api/v1` |
240
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
241
+ | `MCP_HTTP_PORT` | Port for the HTTP server. | `3010` |
242
+ | `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path where the MCP server is mounted. | `/mcp` |
243
+ | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
244
+ | `MCP_LOG_LEVEL` | Log level (RFC 5424: `debug`, `info`, `notice`, `warning`, `error`). | `info` |
245
+ | `STORAGE_PROVIDER_TYPE` | Storage backend: `in-memory`, `filesystem`, `supabase`, `cloudflare-kv/r2/d1`. | `in-memory` |
246
+ | `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry) (spans, metrics, completion logs). | `false` |
247
+
248
+ See [`.env.example`](./.env.example) for the full list of optional overrides.
249
+
250
+ ## Running the server
251
+
252
+ ### Local development
253
+
254
+ - **Build and run:**
255
+
256
+ ```sh
257
+ # One-time build
258
+ bun run rebuild
259
+
260
+ # Run the built server
261
+ bun run start:stdio
262
+ # or
263
+ bun run start:http
264
+ ```
265
+
266
+ - **Run checks and tests:**
267
+
268
+ ```sh
269
+ bun run devcheck # Lint, format, typecheck, security
270
+ bun run test # Vitest test suite
271
+ bun run lint:mcp # Validate MCP definitions against spec
272
+ ```
273
+
274
+ ### Docker
275
+
276
+ ```sh
277
+ docker build -t finnhub-mcp-server .
278
+ docker run --rm -e MCP_TRANSPORT_TYPE=http -e FINNHUB_API_KEY=your-key -p 3010:3010 finnhub-mcp-server
279
+ ```
280
+
281
+ 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.
282
+
283
+ ## Project structure
284
+
285
+ | Directory | Purpose |
286
+ |:---|:---|
287
+ | `src/index.ts` | `createApp()` entry point — registers tools/resources and inits the Finnhub service. |
288
+ | `src/config` | Server-specific environment variable parsing and validation with Zod. |
289
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). Six tools across symbols, quotes, company, earnings, news, and recommendations. |
290
+ | `src/mcp-server/resources` | Resource definitions (`*.resource.ts`). News-categories reference. |
291
+ | `src/services/finnhub` | Finnhub REST client — auth, typed endpoint methods, retry, and HTTP-status classification. |
292
+ | `tests/` | Unit and integration tests mirroring `src/`. |
293
+
294
+ ## Development guide
295
+
296
+ See [`CLAUDE.md`](./CLAUDE.md) / [`AGENTS.md`](./AGENTS.md) for development guidelines and architectural rules. The short version:
297
+
298
+ - Handlers throw, framework catches — no `try/catch` in tool logic
299
+ - Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
300
+ - Register new tools and resources via the barrels in `src/mcp-server/*/definitions/index.ts`
301
+ - Wrap the Finnhub API: validate raw → normalize to domain type → return output schema; never fabricate missing fields
302
+
303
+ ## Contributing
304
+
305
+ Issues and pull requests are welcome. Run checks and tests before submitting:
306
+
307
+ ```sh
308
+ bun run devcheck
309
+ bun run test
310
+ ```
311
+
312
+ ## License
313
+
314
+ Apache-2.0 — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,22 @@
1
+ ---
2
+ summary: "Initial release — 6 tools for real-time US-equity market data via Finnhub: symbol search, live quotes with market-status, company context, earnings, news, and analyst recommendations. Requires a free Finnhub API key."
3
+ breaking: false
4
+ ---
5
+
6
+ # 0.1.0 — 2026-06-14
7
+
8
+ Initial release of finnhub-mcp-server, wrapping the [Finnhub REST API](https://finnhub.io/docs/api) (v1). Fills the fleet's live-equity gap: current market prices and company financial context, starting from a company name rather than a ticker.
9
+
10
+ **API key required:** a free key from [finnhub.io/register](https://finnhub.io/register) must be set as `FINNHUB_API_KEY`. It is sent as the `token` query parameter and never appears in a tool input, log line, or thrown error. **Free tier scope:** US equities only, 60 req/min — international symbols (exchange-suffixed like `.TO`, `.DE`) return a clear `not_us_or_paid` error rather than a silent empty result.
11
+
12
+ ## Added
13
+
14
+ - **`finnhub_search_symbols`** — resolve a company name or partial ticker to Finnhub symbols, US Common Stock first. Each result carries `isLikelyUS` (dot-suffix heuristic) so an agent can avoid spending a call on an international symbol the free tier cannot reach. `limit` (default 10) with truncation disclosure.
15
+ - **`finnhub_get_quote`** — real-time quote for one US symbol, paired with `/stock/market-status` so `priceIsLive` states whether `current` is a live price or the prior close. Detects the all-zero quote sentinel (`c=0, t=0, d=null, dp=null`) as `symbol_not_found`; carries `percentChange` (`dp`).
16
+ - **`finnhub_get_company`** — one-call company context combining `/stock/profile2` + `/stock/metric` + `/stock/peers`. Fundamentals are all-nullable and surfaced honestly (never zero-filled) for thinly-covered names; metrics/peers degrade to a `partial` array on sub-fetch failure while the profile drives errors.
17
+ - **`finnhub_get_earnings`** — two modes: `history` (a symbol's past quarters with actual-vs-estimate surprise %) and `calendar` (market-wide upcoming releases in a date window). `limit` (default 50) with truncation disclosure.
18
+ - **`finnhub_get_news`** — two modes: `company` (recent articles for one symbol over a date range) and `market` (headlines by category: general, forex, crypto, merger). `limit` (default 15) with truncation disclosure.
19
+ - **`finnhub_get_recommendations`** — analyst recommendation trends (strong-buy / buy / hold / sell / strong-sell counts per month, newest first). Empty array → `no_coverage`. `limit` (default 12) with truncation disclosure.
20
+ - **`finnhub://news-categories`** resource — the four valid market-news categories with one-line descriptions.
21
+
22
+ The API key rides in the `token` query parameter but is stripped from all thrown errors and log lines — only the endpoint path and operation name are surfaced. A bad or missing key fails loudly as a `ConfigurationError` at the first call, never masquerading as "no data".
@@ -0,0 +1,127 @@
1
+ ---
2
+ # FORMAT REFERENCE — do not edit. Copy this file to
3
+ # `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.8.x/0.8.6.md`)
4
+ # to author a new release. Set that file's H1 to `# <version> — YYYY-MM-DD`
5
+ # with a concrete date.
6
+
7
+ # Required. One-line GitHub Release-style headline. 350 character cap.
8
+ # Default short and scannable. Don't pad, don't stitch unrelated changes with
9
+ # semicolons — pick the headline. Quotes required: unquoted YAML treats `: `
10
+ # inside the value as a key separator and fails GitHub's strict parser.
11
+ summary: ""
12
+
13
+ # Set `true` when consumers must change code to upgrade: API removals,
14
+ # signature changes, config renames, behavior changes that break existing
15
+ # usage. Flagged as `Breaking` in the rollup.
16
+ breaking: false
17
+
18
+ # Set `true` if this release contains any security fix. Pairs with the
19
+ # `## Security` section below. Flagged as `Security` in the rollup so
20
+ # users can triage upgrade urgency at a glance.
21
+ security: false
22
+
23
+ # Optional free-form notes for maintenance agents processing this release.
24
+ # Not rendered in CHANGELOG — consumed by agents running `maintenance` on
25
+ # downstream servers. Use for adoption instructions that don't fit the
26
+ # human-facing sections: new files to create, fields to populate, one-time
27
+ # migration steps. Omit the field entirely when there's nothing to say.
28
+ # agent-notes: |
29
+ # <instructions for downstream maintenance agents>
30
+ ---
31
+
32
+ # <version> — YYYY-MM-DD
33
+
34
+ <!--
35
+ AUTHORING GUIDE — applies to the new per-version file you create from this
36
+ template.
37
+
38
+ Audience: someone scanning release notes to decide what affects them. Lead
39
+ each bullet with the symbol or concept name in **bold** so they can skip
40
+ what's irrelevant and zoom in on what's not.
41
+
42
+ Tone: terse, fact-dense, not verbose. Default to one sentence per bullet —
43
+ name the symbol, state what changed, stop. Use a second sentence only when
44
+ it carries weight. If a bullet feels long, it is.
45
+
46
+ Cut: mechanism walkthroughs (those belong in JSDoc, CLAUDE.md/AGENTS.md, or the
47
+ relevant skill), ceremonial framings ("This release introduces…",
48
+ backwards-compat paragraphs), file-by-file test enumerations, internal
49
+ implementation notes. Prefer code/symbol names over English re-explanations.
50
+
51
+ Narrative intro: skip by default. Add one short sentence only when the
52
+ release theme genuinely needs framing the bullets can't carry.
53
+
54
+ Sections: Keep a Changelog order — Added, Changed, Deprecated, Removed,
55
+ Fixed, Security. Include only sections with entries; delete the rest
56
+ (including the commented-out scaffolding below). Don't ship empty headers.
57
+
58
+ Include: every distinct fact a reader needs to adopt or audit the release —
59
+ new exports, signatures, lint rule IDs, env vars, breaking changes, version
60
+ bumps on shipped skills. Nothing more.
61
+
62
+ Links: link issues, PRs, docs, or skills where they help a reader jump to
63
+ context. Once per item per entry — don't re-link the same issue in summary,
64
+ narrative, and bullet. Skip links for inline symbol names; code spans speak
65
+ for themselves.
66
+
67
+ Issue/PR URLs: use full URLs. GitHub's bare `#NN` auto-link only resolves
68
+ inside its own UI, not in npm reads or local editors.
69
+
70
+ [#38](https://github.com/cyanheads/mcp-ts-core/issues/38) ← issue
71
+ [#42](https://github.com/cyanheads/mcp-ts-core/pull/42) ← PR
72
+
73
+ Verify numbers exist before linking (`gh issue view NN`, `gh pr view NN`).
74
+ Never speculate on a future number — `#42` for an upcoming PR silently
75
+ resolves to whatever real item already owns 42, and timeline previews pull
76
+ in that unrelated item's metadata.
77
+
78
+ TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
79
+ via `gh release create --notes-from-tag`. The tag is a derivative of this
80
+ changelog entry — a condensed, scannable version, not a copy. Format:
81
+
82
+ <theme — omit version number, GitHub prepends it>
83
+ ← blank line
84
+ <1-2 sentence context: what this release does>
85
+ ← blank line
86
+ Dependency bumps: ← section header
87
+ ← blank line
88
+ - `@cyanheads/mcp-ts-core` ^0.9.1 → ^0.9.6 ← bullet
89
+ ← blank line
90
+ Changed: ← only sections with entries
91
+ ← blank line
92
+ - `format()` output includes `query` in text mode
93
+ ← blank line
94
+ Added:
95
+ ← blank line
96
+ - `manifest.json` scaffolded for MCPB bundle support
97
+ - Install badges (Claude Desktop, Cursor, VS Code)
98
+ ← blank line
99
+ <N> tests pass; `bun run devcheck` clean. ← footer
100
+
101
+ Never a flat comma-separated string. Always structured markdown with
102
+ sections. The tag must scan well as a rendered GitHub Release page.
103
+ -->
104
+
105
+ ## Added
106
+
107
+ -
108
+
109
+ ## Changed
110
+
111
+ -
112
+
113
+ <!-- ## Deprecated
114
+
115
+ - -->
116
+
117
+ <!-- ## Removed
118
+
119
+ - -->
120
+
121
+ ## Fixed
122
+
123
+ -
124
+
125
+ <!-- ## Security
126
+
127
+ - -->