@cyanheads/finnhub-mcp-server 0.2.0 → 0.2.1
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.
- package/AGENTS.md +7 -5
- package/CLAUDE.md +7 -5
- package/README.md +15 -12
- package/changelog/0.2.x/0.2.1.md +35 -0
- package/changelog/template.md +10 -3
- package/dist/mcp-server/tools/definitions/get-company.tool.d.ts +11 -1
- package/dist/mcp-server/tools/definitions/get-company.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-company.tool.js +11 -5
- package/dist/mcp-server/tools/definitions/get-company.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-earnings.tool.d.ts +25 -2
- package/dist/mcp-server/tools/definitions/get-earnings.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-earnings.tool.js +84 -40
- package/dist/mcp-server/tools/definitions/get-earnings.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-news.tool.d.ts +16 -0
- package/dist/mcp-server/tools/definitions/get-news.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-news.tool.js +87 -33
- package/dist/mcp-server/tools/definitions/get-news.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.js +1 -2
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +135 -84
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-symbols.tool.d.ts +2 -0
- package/dist/mcp-server/tools/definitions/search-symbols.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-symbols.tool.js +28 -18
- package/dist/mcp-server/tools/definitions/search-symbols.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/window-page.d.ts +21 -0
- package/dist/mcp-server/tools/definitions/window-page.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/window-page.js +39 -0
- package/dist/mcp-server/tools/definitions/window-page.js.map +1 -0
- package/dist/services/finnhub/date-window.d.ts +13 -0
- package/dist/services/finnhub/date-window.d.ts.map +1 -0
- package/dist/services/finnhub/date-window.js +32 -0
- package/dist/services/finnhub/date-window.js.map +1 -0
- package/dist/services/finnhub/finnhub-service.d.ts +4 -4
- package/dist/services/finnhub/finnhub-service.d.ts.map +1 -1
- package/dist/services/finnhub/finnhub-service.js +6 -6
- package/dist/services/finnhub/finnhub-service.js.map +1 -1
- package/dist/services/finnhub/normalize-article-text.d.ts +6 -0
- package/dist/services/finnhub/normalize-article-text.d.ts.map +1 -0
- package/dist/services/finnhub/normalize-article-text.js +97 -0
- package/dist/services/finnhub/normalize-article-text.js.map +1 -0
- package/dist/services/finnhub/types.d.ts +3 -3
- package/dist/services/finnhub/types.d.ts.map +1 -1
- package/package.json +10 -7
- package/server.json +3 -3
- package/skills/finnhub-guide/SKILL.md +5 -5
|
@@ -4,9 +4,122 @@
|
|
|
4
4
|
* @module mcp-server/tools/definitions/index
|
|
5
5
|
*/
|
|
6
6
|
export declare const allToolDefinitions: (import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
7
|
+
symbol: import("zod").ZodString;
|
|
8
|
+
peerGrouping: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
9
|
+
industry: "industry";
|
|
10
|
+
sector: "sector";
|
|
11
|
+
subIndustry: "subIndustry";
|
|
12
|
+
}>>;
|
|
13
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
14
|
+
symbol: import("zod").ZodString;
|
|
15
|
+
profile: import("zod").ZodObject<{
|
|
16
|
+
name: import("zod").ZodString;
|
|
17
|
+
exchange: import("zod").ZodString;
|
|
18
|
+
industry: import("zod").ZodString;
|
|
19
|
+
country: import("zod").ZodString;
|
|
20
|
+
currency: import("zod").ZodString;
|
|
21
|
+
marketCapitalization: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
22
|
+
shareOutstanding: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
23
|
+
ipo: import("zod").ZodNullable<import("zod").ZodString>;
|
|
24
|
+
weburl: import("zod").ZodNullable<import("zod").ZodString>;
|
|
25
|
+
logo: import("zod").ZodNullable<import("zod").ZodString>;
|
|
26
|
+
}, import("zod/v4/core").$strip>;
|
|
27
|
+
fundamentals: import("zod").ZodObject<{
|
|
28
|
+
peTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
29
|
+
epsTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
30
|
+
week52High: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
31
|
+
week52Low: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
32
|
+
beta: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
33
|
+
dividendYieldTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
34
|
+
netProfitMarginTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
35
|
+
grossMarginTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
36
|
+
revenueGrowthTTMYoy: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
37
|
+
roeTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
38
|
+
}, import("zod/v4/core").$strip>;
|
|
39
|
+
peerGrouping: import("zod").ZodEnum<{
|
|
40
|
+
industry: "industry";
|
|
41
|
+
sector: "sector";
|
|
42
|
+
subIndustry: "subIndustry";
|
|
43
|
+
}>;
|
|
44
|
+
peers: import("zod").ZodArray<import("zod").ZodString>;
|
|
45
|
+
partial: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
46
|
+
}, import("zod/v4/core").$strip>, readonly [{
|
|
47
|
+
readonly reason: "symbol_not_found";
|
|
48
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.NotFound;
|
|
49
|
+
readonly when: "/stock/profile2 returned an empty object for the symbol.";
|
|
50
|
+
readonly recovery: "Verify the ticker with finnhub_search_symbols. ETFs, funds, or trusts may lack company profiles; try finnhub_get_quote for price data.";
|
|
51
|
+
}, {
|
|
52
|
+
readonly reason: "not_us_or_paid";
|
|
53
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.Forbidden;
|
|
54
|
+
readonly when: "Upstream HTTP 403 — international or paid-only symbol.";
|
|
55
|
+
readonly recovery: "Free tier is US equities only; international symbols need a paid Finnhub plan. Try the company's US listing.";
|
|
56
|
+
}], undefined> | import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
57
|
+
mode: import("zod").ZodEnum<{
|
|
58
|
+
company: "company";
|
|
59
|
+
market: "market";
|
|
60
|
+
}>;
|
|
61
|
+
symbol: import("zod").ZodOptional<import("zod").ZodString>;
|
|
62
|
+
from: import("zod").ZodOptional<import("zod").ZodString>;
|
|
63
|
+
to: import("zod").ZodOptional<import("zod").ZodString>;
|
|
64
|
+
category: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
65
|
+
crypto: "crypto";
|
|
66
|
+
forex: "forex";
|
|
67
|
+
general: "general";
|
|
68
|
+
merger: "merger";
|
|
69
|
+
}>>;
|
|
70
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
71
|
+
offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
72
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
73
|
+
mode: import("zod").ZodEnum<{
|
|
74
|
+
company: "company";
|
|
75
|
+
market: "market";
|
|
76
|
+
}>;
|
|
77
|
+
articles: import("zod").ZodArray<import("zod").ZodObject<{
|
|
78
|
+
headline: import("zod").ZodString;
|
|
79
|
+
source: import("zod").ZodString;
|
|
80
|
+
datetime: import("zod").ZodString;
|
|
81
|
+
summary: import("zod").ZodString;
|
|
82
|
+
url: import("zod").ZodString;
|
|
83
|
+
category: import("zod").ZodOptional<import("zod").ZodString>;
|
|
84
|
+
related: import("zod").ZodOptional<import("zod").ZodString>;
|
|
85
|
+
}, import("zod/v4/core").$strip>>;
|
|
86
|
+
}, import("zod/v4/core").$strip>, readonly [{
|
|
87
|
+
readonly reason: "invalid_date";
|
|
88
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
89
|
+
readonly when: "A company-news date bound is not a real YYYY-MM-DD calendar date.";
|
|
90
|
+
readonly recovery: "Use YYYY-MM-DD for a real calendar date.";
|
|
91
|
+
readonly thrownBy: "service";
|
|
92
|
+
}, {
|
|
93
|
+
readonly reason: "inverted_date_window";
|
|
94
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
95
|
+
readonly when: "The resolved company-news start date is later than the end date.";
|
|
96
|
+
readonly recovery: "Choose a start date on or before the end date.";
|
|
97
|
+
readonly thrownBy: "service";
|
|
98
|
+
}, {
|
|
99
|
+
readonly reason: "missing_symbol";
|
|
100
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
101
|
+
readonly when: "mode 'company' was requested without a symbol.";
|
|
102
|
+
readonly recovery: "Provide a `symbol` for company mode, or switch to mode: market with a category.";
|
|
103
|
+
}, {
|
|
104
|
+
readonly reason: "not_us_or_paid";
|
|
105
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.Forbidden;
|
|
106
|
+
readonly when: "Upstream HTTP 403 on the symbol.";
|
|
107
|
+
readonly recovery: "Free tier is US equities only; use a US symbol or a paid plan.";
|
|
108
|
+
}], {
|
|
109
|
+
readonly fetchedFrom: import("zod").ZodOptional<import("zod").ZodString>;
|
|
110
|
+
readonly fetchedTo: import("zod").ZodOptional<import("zod").ZodString>;
|
|
111
|
+
readonly nextOffset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
112
|
+
readonly totalCount: import("zod").ZodNumber;
|
|
113
|
+
readonly truncated: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
114
|
+
readonly shown: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
115
|
+
readonly cap: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
116
|
+
readonly notice: import("zod").ZodOptional<import("zod").ZodString>;
|
|
117
|
+
}> | import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
7
118
|
query: import("zod").ZodString;
|
|
8
119
|
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
120
|
+
exchange: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
121
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
122
|
+
exchange: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
123
|
results: import("zod").ZodArray<import("zod").ZodObject<{
|
|
11
124
|
symbol: import("zod").ZodString;
|
|
12
125
|
displaySymbol: import("zod").ZodString;
|
|
@@ -50,46 +163,6 @@ export declare const allToolDefinitions: (import("@cyanheads/mcp-ts-core").ToolD
|
|
|
50
163
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.Forbidden;
|
|
51
164
|
readonly when: "Upstream HTTP 403 — international or paid-only symbol.";
|
|
52
165
|
readonly recovery: "This free Finnhub tier covers US stocks only; international symbols require a paid plan. Try the US listing of the company.";
|
|
53
|
-
}], undefined> | import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
54
|
-
symbol: import("zod").ZodString;
|
|
55
|
-
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
56
|
-
symbol: import("zod").ZodString;
|
|
57
|
-
profile: import("zod").ZodObject<{
|
|
58
|
-
name: import("zod").ZodString;
|
|
59
|
-
exchange: import("zod").ZodString;
|
|
60
|
-
industry: import("zod").ZodString;
|
|
61
|
-
country: import("zod").ZodString;
|
|
62
|
-
currency: import("zod").ZodString;
|
|
63
|
-
marketCapitalization: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
64
|
-
shareOutstanding: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
65
|
-
ipo: import("zod").ZodNullable<import("zod").ZodString>;
|
|
66
|
-
weburl: import("zod").ZodNullable<import("zod").ZodString>;
|
|
67
|
-
logo: import("zod").ZodNullable<import("zod").ZodString>;
|
|
68
|
-
}, import("zod/v4/core").$strip>;
|
|
69
|
-
fundamentals: import("zod").ZodObject<{
|
|
70
|
-
peTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
71
|
-
epsTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
72
|
-
week52High: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
73
|
-
week52Low: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
74
|
-
beta: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
75
|
-
dividendYieldTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
76
|
-
netProfitMarginTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
77
|
-
grossMarginTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
78
|
-
revenueGrowthTTMYoy: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
79
|
-
roeTTM: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
80
|
-
}, import("zod/v4/core").$strip>;
|
|
81
|
-
peers: import("zod").ZodArray<import("zod").ZodString>;
|
|
82
|
-
partial: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
83
|
-
}, import("zod/v4/core").$strip>, readonly [{
|
|
84
|
-
readonly reason: "symbol_not_found";
|
|
85
|
-
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.NotFound;
|
|
86
|
-
readonly when: "/stock/profile2 returned an empty object for the symbol.";
|
|
87
|
-
readonly recovery: "Verify the ticker with finnhub_search_symbols. ETFs, funds, or trusts may lack company profiles; try finnhub_get_quote for price data.";
|
|
88
|
-
}, {
|
|
89
|
-
readonly reason: "not_us_or_paid";
|
|
90
|
-
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.Forbidden;
|
|
91
|
-
readonly when: "Upstream HTTP 403 — international or paid-only symbol.";
|
|
92
|
-
readonly recovery: "Free tier is US equities only; international symbols need a paid Finnhub plan. Try the company's US listing.";
|
|
93
166
|
}], undefined> | import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
94
167
|
mode: import("zod").ZodEnum<{
|
|
95
168
|
calendar: "calendar";
|
|
@@ -99,6 +172,7 @@ export declare const allToolDefinitions: (import("@cyanheads/mcp-ts-core").ToolD
|
|
|
99
172
|
from: import("zod").ZodOptional<import("zod").ZodString>;
|
|
100
173
|
to: import("zod").ZodOptional<import("zod").ZodString>;
|
|
101
174
|
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
175
|
+
offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
102
176
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
103
177
|
mode: import("zod").ZodEnum<{
|
|
104
178
|
calendar: "calendar";
|
|
@@ -117,8 +191,10 @@ export declare const allToolDefinitions: (import("@cyanheads/mcp-ts-core").ToolD
|
|
|
117
191
|
symbol: import("zod").ZodString;
|
|
118
192
|
date: import("zod").ZodString;
|
|
119
193
|
hour: import("zod").ZodString;
|
|
194
|
+
epsActual: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
120
195
|
epsEstimate: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
121
196
|
revenueEstimate: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
197
|
+
revenueActual: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
122
198
|
year: import("zod").ZodNumber;
|
|
123
199
|
quarter: import("zod").ZodNumber;
|
|
124
200
|
}, import("zod/v4/core").$strip>>>;
|
|
@@ -126,58 +202,33 @@ export declare const allToolDefinitions: (import("@cyanheads/mcp-ts-core").ToolD
|
|
|
126
202
|
readonly reason: "missing_symbol";
|
|
127
203
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
128
204
|
readonly when: "mode 'history' was requested without a symbol.";
|
|
129
|
-
readonly recovery: "Provide a `symbol` for history mode, or switch to mode
|
|
205
|
+
readonly recovery: "Provide a `symbol` for history mode, or switch to calendar mode for market-wide releases.";
|
|
130
206
|
}, {
|
|
131
|
-
readonly reason: "
|
|
132
|
-
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.Forbidden;
|
|
133
|
-
readonly when: "Upstream HTTP 403 on the symbol.";
|
|
134
|
-
readonly recovery: "Free tier is US equities only; use a US symbol or a paid plan.";
|
|
135
|
-
}], {
|
|
136
|
-
readonly totalCount: import("zod").ZodNumber;
|
|
137
|
-
readonly truncated: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
138
|
-
readonly shown: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
139
|
-
readonly cap: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
140
|
-
readonly notice: import("zod").ZodOptional<import("zod").ZodString>;
|
|
141
|
-
}> | import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
142
|
-
mode: import("zod").ZodEnum<{
|
|
143
|
-
company: "company";
|
|
144
|
-
market: "market";
|
|
145
|
-
}>;
|
|
146
|
-
symbol: import("zod").ZodOptional<import("zod").ZodString>;
|
|
147
|
-
from: import("zod").ZodOptional<import("zod").ZodString>;
|
|
148
|
-
to: import("zod").ZodOptional<import("zod").ZodString>;
|
|
149
|
-
category: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
150
|
-
crypto: "crypto";
|
|
151
|
-
forex: "forex";
|
|
152
|
-
general: "general";
|
|
153
|
-
merger: "merger";
|
|
154
|
-
}>>;
|
|
155
|
-
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
156
|
-
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
157
|
-
mode: import("zod").ZodEnum<{
|
|
158
|
-
company: "company";
|
|
159
|
-
market: "market";
|
|
160
|
-
}>;
|
|
161
|
-
articles: import("zod").ZodArray<import("zod").ZodObject<{
|
|
162
|
-
headline: import("zod").ZodString;
|
|
163
|
-
source: import("zod").ZodString;
|
|
164
|
-
datetime: import("zod").ZodString;
|
|
165
|
-
summary: import("zod").ZodString;
|
|
166
|
-
url: import("zod").ZodString;
|
|
167
|
-
category: import("zod").ZodOptional<import("zod").ZodString>;
|
|
168
|
-
related: import("zod").ZodOptional<import("zod").ZodString>;
|
|
169
|
-
}, import("zod/v4/core").$strip>>;
|
|
170
|
-
}, import("zod/v4/core").$strip>, readonly [{
|
|
171
|
-
readonly reason: "missing_symbol";
|
|
207
|
+
readonly reason: "invalid_date";
|
|
172
208
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
173
|
-
readonly when: "
|
|
174
|
-
readonly recovery: "
|
|
209
|
+
readonly when: "A calendar bound is not a real YYYY-MM-DD date.";
|
|
210
|
+
readonly recovery: "Use YYYY-MM-DD for a real calendar date.";
|
|
211
|
+
readonly thrownBy: "service";
|
|
212
|
+
}, {
|
|
213
|
+
readonly reason: "inverted_date_window";
|
|
214
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
215
|
+
readonly when: "The resolved calendar start date is later than the end date.";
|
|
216
|
+
readonly recovery: "Choose a start date on or before the end date.";
|
|
217
|
+
readonly thrownBy: "service";
|
|
218
|
+
}, {
|
|
219
|
+
readonly reason: "calendar_limit_exceeded";
|
|
220
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
221
|
+
readonly when: "Calendar mode requested more than 100 rows per page.";
|
|
222
|
+
readonly recovery: "Use a limit of 100 or less and continue with nextOffset.";
|
|
175
223
|
}, {
|
|
176
224
|
readonly reason: "not_us_or_paid";
|
|
177
225
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.Forbidden;
|
|
178
226
|
readonly when: "Upstream HTTP 403 on the symbol.";
|
|
179
227
|
readonly recovery: "Free tier is US equities only; use a US symbol or a paid plan.";
|
|
180
228
|
}], {
|
|
229
|
+
readonly fetchedFrom: import("zod").ZodOptional<import("zod").ZodString>;
|
|
230
|
+
readonly fetchedTo: import("zod").ZodOptional<import("zod").ZodString>;
|
|
231
|
+
readonly nextOffset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
181
232
|
readonly totalCount: import("zod").ZodNumber;
|
|
182
233
|
readonly truncated: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
183
234
|
readonly shown: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAO9B,CAAC"}
|
|
@@ -8,7 +8,9 @@ import { z } from '@cyanheads/mcp-ts-core';
|
|
|
8
8
|
export declare const searchSymbols: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
9
9
|
query: z.ZodString;
|
|
10
10
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
exchange: z.ZodOptional<z.ZodString>;
|
|
11
12
|
}, z.core.$strip>, z.ZodObject<{
|
|
13
|
+
exchange: z.ZodOptional<z.ZodString>;
|
|
12
14
|
results: z.ZodArray<z.ZodObject<{
|
|
13
15
|
symbol: z.ZodString;
|
|
14
16
|
displaySymbol: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-symbols.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-symbols.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"search-symbols.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-symbols.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAOjD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;EAmIxB,CAAC"}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* @module mcp-server/tools/definitions/search-symbols.tool
|
|
6
6
|
*/
|
|
7
7
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { escapeMarkdownInline } from '@cyanheads/mcp-ts-core/utils';
|
|
8
9
|
import { getFinnhubService } from '../../../services/finnhub/finnhub-service.js';
|
|
9
10
|
/** Finnhub uses `.A` and `.B` for US class-share symbols as well as dots for exchanges. */
|
|
10
11
|
const US_CLASS_SHARE_SYMBOL = /^[A-Z]+\.[AB]$/;
|
|
11
12
|
export const searchSymbols = tool('finnhub_search_symbols', {
|
|
12
|
-
description: 'Resolve a company name or partial ticker to Finnhub stock symbols.
|
|
13
|
+
description: 'Resolve a company name or partial ticker to Finnhub stock symbols. Returns matched symbols with display symbol, description, and security type. Exact ticker matches rank first, then likely-US Common Stock. Each result carries isLikelyUS, a symbol-format heuristic for likely free-tier availability; quote and profile responses remain authoritative.',
|
|
13
14
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
14
15
|
input: z.object({
|
|
15
16
|
query: z
|
|
@@ -25,9 +26,14 @@ export const searchSymbols = tool('finnhub_search_symbols', {
|
|
|
25
26
|
.min(1)
|
|
26
27
|
.max(50)
|
|
27
28
|
.default(10)
|
|
28
|
-
.describe('Max symbols to return
|
|
29
|
+
.describe('Max symbols to return after ranking. Default 10.'),
|
|
30
|
+
exchange: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('Finnhub exchange code, e.g. "US" for US listings. Omit or leave blank for global search. A filtered company-name search can miss listings found by a ticker search.'),
|
|
29
34
|
}),
|
|
30
35
|
output: z.object({
|
|
36
|
+
exchange: z.string().optional().describe('Exchange filter sent to Finnhub, when applied.'),
|
|
31
37
|
results: z
|
|
32
38
|
.array(z
|
|
33
39
|
.object({
|
|
@@ -46,7 +52,7 @@ export const searchSymbols = tool('finnhub_search_symbols', {
|
|
|
46
52
|
.describe('Symbol-format heuristic for likely US free-tier availability. Plain tickers and `.A`/`.B` class-share symbols are likely US; recognized exchange suffixes such as `.SS`, `.T`, and `.L` are not. Quote and profile responses remain authoritative.'),
|
|
47
53
|
})
|
|
48
54
|
.describe('A single matched symbol.'))
|
|
49
|
-
.describe('
|
|
55
|
+
.describe('Exact ticker matches first, then likely-US Common Stock, then other matches. Finnhub order is preserved within each group.'),
|
|
50
56
|
}),
|
|
51
57
|
enrichment: {
|
|
52
58
|
totalCount: z
|
|
@@ -61,7 +67,8 @@ export const searchSymbols = tool('finnhub_search_symbols', {
|
|
|
61
67
|
notice: z.string().optional().describe('Guidance when nothing matched the query.'),
|
|
62
68
|
},
|
|
63
69
|
async handler(input, ctx) {
|
|
64
|
-
const
|
|
70
|
+
const exchange = input.exchange?.trim().toUpperCase() || undefined;
|
|
71
|
+
const { count, result } = await getFinnhubService().search(input.query, ctx, exchange);
|
|
65
72
|
const mapped = result.map((match) => ({
|
|
66
73
|
symbol: match.symbol,
|
|
67
74
|
displaySymbol: match.displaySymbol,
|
|
@@ -69,17 +76,18 @@ export const searchSymbols = tool('finnhub_search_symbols', {
|
|
|
69
76
|
type: match.type,
|
|
70
77
|
isLikelyUS: !match.symbol.includes('.') || US_CLASS_SHARE_SYMBOL.test(match.symbol),
|
|
71
78
|
}));
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
const query = input.query.toUpperCase();
|
|
80
|
+
const rank = (r) => {
|
|
81
|
+
if (r.symbol.toUpperCase() === query || r.displaySymbol.toUpperCase() === query)
|
|
82
|
+
return 0;
|
|
83
|
+
return r.isLikelyUS && r.type === 'Common Stock' ? 1 : 2;
|
|
84
|
+
};
|
|
85
|
+
mapped.sort((a, b) => rank(a) - rank(b));
|
|
78
86
|
ctx.enrich.total(count);
|
|
79
87
|
if (count === 0) {
|
|
80
88
|
ctx.enrich.notice(`No symbols matched "${input.query}". Try the company's common name or a ticker fragment.`);
|
|
81
89
|
}
|
|
82
|
-
const results =
|
|
90
|
+
const results = mapped.slice(0, input.limit);
|
|
83
91
|
if (count > input.limit) {
|
|
84
92
|
ctx.enrich.truncated({ shown: results.length, cap: input.limit });
|
|
85
93
|
}
|
|
@@ -88,19 +96,21 @@ export const searchSymbols = tool('finnhub_search_symbols', {
|
|
|
88
96
|
count,
|
|
89
97
|
returned: results.length,
|
|
90
98
|
});
|
|
91
|
-
return { results };
|
|
99
|
+
return { ...(exchange && { exchange }), results };
|
|
92
100
|
},
|
|
93
101
|
format: (result) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
const lines = [];
|
|
103
|
+
if (result.exchange)
|
|
104
|
+
lines.push(`Exchange: ${escapeMarkdownInline(result.exchange)}`, '');
|
|
105
|
+
if (result.results.length === 0)
|
|
106
|
+
lines.push('No matching symbols.');
|
|
107
|
+
for (const r of result.results) {
|
|
98
108
|
const region = r.isLikelyUS
|
|
99
109
|
? 'likely US (symbol heuristic)'
|
|
100
110
|
: 'not likely US (exchange-suffix heuristic)';
|
|
101
111
|
const type = r.type || 'Unknown type';
|
|
102
|
-
|
|
103
|
-
}
|
|
112
|
+
lines.push(`**${r.symbol}** — ${r.description} (${type}, ${region}) · display: ${r.displaySymbol}`);
|
|
113
|
+
}
|
|
104
114
|
return [{ type: 'text', text: lines.join('\n') }];
|
|
105
115
|
},
|
|
106
116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-symbols.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-symbols.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,2FAA2F;AAC3F,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,wBAAwB,EAAE;IAC1D,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"search-symbols.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-symbols.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,2FAA2F;AAC3F,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,wBAAwB,EAAE;IAC1D,WAAW,EACT,8VAA8V;IAChW,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,GAAG,CAAC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AE,CAAC,CAAC;QAC1F,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACpE,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU;gBACzB,CAAC,CAAC,8BAA8B;gBAChC,CAAC,CAAC,2CAA2C,CAAC;YAChD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC;YACtC,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,CAAC,MAAM,QAAQ,CAAC,CAAC,WAAW,KAAK,IAAI,KAAK,MAAM,gBAAgB,CAAC,CAAC,aAAa,EAAE,CACxF,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Pages a sorted Finnhub response and reports its fetched bounds.
|
|
3
|
+
* @module mcp-server/tools/definitions/window-page
|
|
4
|
+
*/
|
|
5
|
+
import { type Context, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
/** Bounds and continuation for a paged, date-windowed tool response. */
|
|
7
|
+
export declare const windowPageEnrichment: {
|
|
8
|
+
fetchedFrom: z.ZodOptional<z.ZodString>;
|
|
9
|
+
fetchedTo: z.ZodOptional<z.ZodString>;
|
|
10
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
};
|
|
12
|
+
/** Slice the already sorted rows, preserving upstream warnings alongside paging guidance. */
|
|
13
|
+
export declare function pageWindow<T>(rows: T[], input: {
|
|
14
|
+
limit: number;
|
|
15
|
+
offset?: number | undefined;
|
|
16
|
+
}, ctx: Pick<Context, 'enrich'>, coverage?: {
|
|
17
|
+
fetchedFrom: string;
|
|
18
|
+
fetchedTo: string;
|
|
19
|
+
warning?: string;
|
|
20
|
+
}): T[];
|
|
21
|
+
//# sourceMappingURL=window-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-page.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/window-page.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEzD,wEAAwE;AACxE,eAAO,MAAM,oBAAoB;IAC/B,WAAW;IACX,SAAS;IACT,UAAU;CAKX,CAAC;AAEF,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,EAAE,EACT,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EACrD,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC5B,QAAQ,CAAC,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACtE,CAAC,EAAE,CAqBL"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Pages a sorted Finnhub response and reports its fetched bounds.
|
|
3
|
+
* @module mcp-server/tools/definitions/window-page
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
/** Bounds and continuation for a paged, date-windowed tool response. */
|
|
7
|
+
export const windowPageEnrichment = {
|
|
8
|
+
fetchedFrom: z.string().optional().describe('Earliest date or timestamp among all fetched rows.'),
|
|
9
|
+
fetchedTo: z.string().optional().describe('Latest date or timestamp among all fetched rows.'),
|
|
10
|
+
nextOffset: z
|
|
11
|
+
.number()
|
|
12
|
+
.int()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Offset for the next page of fetched rows. Each page refetches upstream data.'),
|
|
15
|
+
};
|
|
16
|
+
/** Slice the already sorted rows, preserving upstream warnings alongside paging guidance. */
|
|
17
|
+
export function pageWindow(rows, input, ctx, coverage) {
|
|
18
|
+
const offset = input.offset ?? 0;
|
|
19
|
+
const page = rows.slice(offset, offset + input.limit);
|
|
20
|
+
ctx.enrich.total(rows.length);
|
|
21
|
+
if (coverage) {
|
|
22
|
+
ctx.enrich({ fetchedFrom: coverage.fetchedFrom, fetchedTo: coverage.fetchedTo });
|
|
23
|
+
}
|
|
24
|
+
const nextOffset = offset + page.length;
|
|
25
|
+
if (nextOffset < rows.length) {
|
|
26
|
+
const continuation = `Use offset ${nextOffset} with the same query to continue through the fetched rows.`;
|
|
27
|
+
ctx.enrich({ nextOffset });
|
|
28
|
+
ctx.enrich.truncated({
|
|
29
|
+
shown: page.length,
|
|
30
|
+
cap: input.limit,
|
|
31
|
+
guidance: coverage?.warning ? `${coverage.warning} ${continuation}` : continuation,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else if (coverage?.warning) {
|
|
35
|
+
ctx.enrich.notice(coverage.warning);
|
|
36
|
+
}
|
|
37
|
+
return page;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=window-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-page.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/window-page.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEzD,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IACjG,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,C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AQ,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Resolves and validates the UTC date bounds passed to Finnhub.
|
|
3
|
+
* @module services/finnhub/date-window
|
|
4
|
+
*/
|
|
5
|
+
/** Resolve empty or omitted bounds relative to today, then validate the effective window. */
|
|
6
|
+
export declare function dateWindow(input: {
|
|
7
|
+
from?: string | undefined;
|
|
8
|
+
to?: string | undefined;
|
|
9
|
+
}, fromDays: number, toDays: number): {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=date-window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-window.d.ts","sourceRoot":"","sources":["../../../src/services/finnhub/date-window.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,6FAA6F;AAC7F,wBAAgB,UAAU,CACxB,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAC7D,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAyB9B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Resolves and validates the UTC date bounds passed to Finnhub.
|
|
3
|
+
* @module services/finnhub/date-window
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { validationError } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
const isoDate = z.iso.date();
|
|
8
|
+
const DAY_MS = 86_400_000;
|
|
9
|
+
/** Resolve empty or omitted bounds relative to today, then validate the effective window. */
|
|
10
|
+
export function dateWindow(input, fromDays, toDays) {
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
const from = input.from || new Date(now + fromDays * DAY_MS).toISOString().slice(0, 10);
|
|
13
|
+
const to = input.to || new Date(now + toDays * DAY_MS).toISOString().slice(0, 10);
|
|
14
|
+
for (const [field, value] of Object.entries({ from, to })) {
|
|
15
|
+
if (!isoDate.safeParse(value).success) {
|
|
16
|
+
throw validationError(`${field} must be a real YYYY-MM-DD date, received ${JSON.stringify(value)}.`, {
|
|
17
|
+
reason: 'invalid_date',
|
|
18
|
+
field,
|
|
19
|
+
value,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (from > to) {
|
|
24
|
+
throw validationError(`Start date ${from} must be on or before end date ${to}.`, {
|
|
25
|
+
reason: 'inverted_date_window',
|
|
26
|
+
from,
|
|
27
|
+
to,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return { from, to };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=date-window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-window.js","sourceRoot":"","sources":["../../../src/services/finnhub/date-window.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAC7B,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CACxB,KAA6D,EAC7D,QAAgB,EAChB,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxF,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAElF,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,eAAe,CACnB,GAAG,KAAK,6CAA6C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAC7E;gBACE,MAAM,EAAE,cAAc;gBACtB,KAAK;gBACL,KAAK;aACN,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,IAAI,GAAG,EAAE,EAAE,CAAC;QACd,MAAM,eAAe,CAAC,cAAc,IAAI,kCAAkC,EAAE,GAAG,EAAE;YAC/E,MAAM,EAAE,sBAAsB;YAC9B,IAAI;YACJ,EAAE;SACH,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -19,8 +19,8 @@ export declare class FinnhubService {
|
|
|
19
19
|
private readonly baseUrl;
|
|
20
20
|
private readonly apiKey;
|
|
21
21
|
constructor();
|
|
22
|
-
/** `GET /search
|
|
23
|
-
search(query: string, ctx: Context): Promise<FinnhubSearchResponse>;
|
|
22
|
+
/** `GET /search` — resolve a name/ticker fragment globally or on one exchange. */
|
|
23
|
+
search(query: string, ctx: Context, exchange?: string): Promise<FinnhubSearchResponse>;
|
|
24
24
|
/** `GET /quote?symbol={symbol}` — real-time price snapshot. */
|
|
25
25
|
quote(symbol: string, ctx: Context): Promise<FinnhubQuote>;
|
|
26
26
|
/** `GET /stock/market-status?exchange={exchange}` — live market-open flag. */
|
|
@@ -29,8 +29,8 @@ export declare class FinnhubService {
|
|
|
29
29
|
profile(symbol: string, ctx: Context): Promise<FinnhubProfile>;
|
|
30
30
|
/** `GET /stock/metric?symbol={symbol}&metric=all` — fundamentals (~100 keys). */
|
|
31
31
|
metrics(symbol: string, ctx: Context): Promise<FinnhubMetricResponse>;
|
|
32
|
-
/** `GET /stock/peers
|
|
33
|
-
peers(symbol: string, ctx: Context): Promise<string[]>;
|
|
32
|
+
/** `GET /stock/peers` — omit grouping for Finnhub's default sub-industry peers. */
|
|
33
|
+
peers(symbol: string, ctx: Context, grouping?: 'industry' | 'sector'): Promise<string[]>;
|
|
34
34
|
/** `GET /stock/earnings?symbol={symbol}` — past quarters, newest first. */
|
|
35
35
|
earnings(symbol: string, ctx: Context): Promise<FinnhubEarning[]>;
|
|
36
36
|
/** `GET /calendar/earnings?from={from}&to={to}&symbol={symbol?}` — upcoming releases window. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finnhub-service.d.ts","sourceRoot":"","sources":["../../../src/services/finnhub/finnhub-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAYpB;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,cAIC;IAED,
|
|
1
|
+
{"version":3,"file":"finnh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AQ,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOvF;IAED,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAEhE;IAED,gGAAgG;IAChG,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,uBAAuB,CAAC,CAOlC;IAED,+DAA+D;IAC/D,WAAW,CACT,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAO/B;IAED,+DAA+D;IAC/D,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAExE;IAED,0FAA0F;IAC1F,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAO9E;IAED;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,OAAO;IAkCf;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;CAUnB;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAErF;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD"}
|
|
@@ -30,9 +30,9 @@ export class FinnhubService {
|
|
|
30
30
|
this.baseUrl = serverConfig.baseUrl.replace(/\/$/, '');
|
|
31
31
|
this.apiKey = serverConfig.apiKey;
|
|
32
32
|
}
|
|
33
|
-
/** `GET /search
|
|
34
|
-
search(query, ctx) {
|
|
35
|
-
return this.request('/search', { q: query }, 'search', ctx);
|
|
33
|
+
/** `GET /search` — resolve a name/ticker fragment globally or on one exchange. */
|
|
34
|
+
search(query, ctx, exchange) {
|
|
35
|
+
return this.request('/search', exchange === undefined ? { q: query } : { q: query, exchange }, 'search', ctx);
|
|
36
36
|
}
|
|
37
37
|
/** `GET /quote?symbol={symbol}` — real-time price snapshot. */
|
|
38
38
|
quote(symbol, ctx) {
|
|
@@ -50,9 +50,9 @@ export class FinnhubService {
|
|
|
50
50
|
metrics(symbol, ctx) {
|
|
51
51
|
return this.request('/stock/metric', { symbol, metric: 'all' }, 'metrics', ctx);
|
|
52
52
|
}
|
|
53
|
-
/** `GET /stock/peers
|
|
54
|
-
peers(symbol, ctx) {
|
|
55
|
-
return this.request('/stock/peers', { symbol }, 'peers', ctx);
|
|
53
|
+
/** `GET /stock/peers` — omit grouping for Finnhub's default sub-industry peers. */
|
|
54
|
+
peers(symbol, ctx, grouping) {
|
|
55
|
+
return this.request('/stock/peers', grouping === undefined ? { symbol } : { symbol, grouping }, 'peers', ctx);
|
|
56
56
|
}
|
|
57
57
|
/** `GET /stock/earnings?symbol={symbol}` — past quarters, newest first. */
|
|
58
58
|
earnings(symbol, ctx) {
|