@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.
- package/AGENTS.md +376 -0
- package/CLAUDE.md +376 -0
- package/Dockerfile +121 -0
- package/LICENSE +201 -0
- package/README.md +314 -0
- package/changelog/0.1.x/0.1.0.md +22 -0
- package/changelog/template.md +127 -0
- package/dist/config/server-config.d.ts +25 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +37 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/index.d.ts +12 -0
- package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/index.js +8 -0
- package/dist/mcp-server/resources/definitions/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/news-categories.resource.d.ts +16 -0
- package/dist/mcp-server/resources/definitions/news-categories.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/news-categories.resource.js +45 -0
- package/dist/mcp-server/resources/definitions/news-categories.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-company.tool.d.ts +51 -0
- package/dist/mcp-server/tools/definitions/get-company.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-company.tool.js +191 -0
- package/dist/mcp-server/tools/definitions/get-company.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-earnings.tool.d.ts +59 -0
- package/dist/mcp-server/tools/definitions/get-earnings.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-earnings.tool.js +201 -0
- package/dist/mcp-server/tools/definitions/get-earnings.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-news.tool.d.ts +55 -0
- package/dist/mcp-server/tools/definitions/get-news.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-news.tool.js +160 -0
- package/dist/mcp-server/tools/definitions/get-news.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-quote.tool.d.ts +35 -0
- package/dist/mcp-server/tools/definitions/get-quote.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-quote.tool.js +132 -0
- package/dist/mcp-server/tools/definitions/get-quote.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.d.ts +38 -0
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.js +110 -0
- package/dist/mcp-server/tools/definitions/get-recommendations.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +209 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +20 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-symbols.tool.d.ts +26 -0
- package/dist/mcp-server/tools/definitions/search-symbols.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-symbols.tool.js +101 -0
- package/dist/mcp-server/tools/definitions/search-symbols.tool.js.map +1 -0
- package/dist/services/finnhub/finnhub-service.d.ts +77 -0
- package/dist/services/finnhub/finnhub-service.d.ts.map +1 -0
- package/dist/services/finnhub/finnhub-service.js +148 -0
- package/dist/services/finnhub/finnhub-service.js.map +1 -0
- package/dist/services/finnhub/types.d.ts +147 -0
- package/dist/services/finnhub/types.d.ts.map +1 -0
- package/dist/services/finnhub/types.js +9 -0
- package/dist/services/finnhub/types.js.map +1 -0
- package/package.json +85 -0
- package/server.json +125 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-specific configuration for finnhub-mcp-server.
|
|
3
|
+
* Lazy-parsed Zod schema, separate from the framework's core config. Maps the
|
|
4
|
+
* server's domain env vars (`FINNHUB_API_KEY`, `FINNHUB_BASE_URL`) so a missing
|
|
5
|
+
* or invalid value fails loudly at startup, naming the variable.
|
|
6
|
+
* @module config/server-config
|
|
7
|
+
*/
|
|
8
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
/**
|
|
10
|
+
* Domain configuration schema. `apiKey` is required — the server cannot reach
|
|
11
|
+
* Finnhub without it. `baseUrl` is overridable for local testing or a proxy.
|
|
12
|
+
*/
|
|
13
|
+
declare const ServerConfigSchema: z.ZodObject<{
|
|
14
|
+
apiKey: z.ZodString;
|
|
15
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type ServerConfig = z.infer<typeof ServerConfigSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* Lazily parse and cache the server configuration. Reads env vars via the
|
|
20
|
+
* framework's `parseEnvConfig` so a validation failure names the variable
|
|
21
|
+
* (`FINNHUB_API_KEY`) rather than the schema path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getServerConfig(): ServerConfig;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=server-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C;;;GAGG;AACH,QAAA,MAAM,kBAAkB;;;iBAWtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAM9C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-specific configuration for finnhub-mcp-server.
|
|
3
|
+
* Lazy-parsed Zod schema, separate from the framework's core config. Maps the
|
|
4
|
+
* server's domain env vars (`FINNHUB_API_KEY`, `FINNHUB_BASE_URL`) so a missing
|
|
5
|
+
* or invalid value fails loudly at startup, naming the variable.
|
|
6
|
+
* @module config/server-config
|
|
7
|
+
*/
|
|
8
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
|
|
10
|
+
/**
|
|
11
|
+
* Domain configuration schema. `apiKey` is required — the server cannot reach
|
|
12
|
+
* Finnhub without it. `baseUrl` is overridable for local testing or a proxy.
|
|
13
|
+
*/
|
|
14
|
+
const ServerConfigSchema = z.object({
|
|
15
|
+
apiKey: z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.describe('Finnhub API key from https://finnhub.io/register. Required — server fails to start without it. Free tier: 60 req/min, US real-time.'),
|
|
19
|
+
baseUrl: z
|
|
20
|
+
.string()
|
|
21
|
+
.default('https://finnhub.io/api/v1')
|
|
22
|
+
.describe('Finnhub REST API base URL. Override for local testing or a proxy.'),
|
|
23
|
+
});
|
|
24
|
+
let _config;
|
|
25
|
+
/**
|
|
26
|
+
* Lazily parse and cache the server configuration. Reads env vars via the
|
|
27
|
+
* framework's `parseEnvConfig` so a validation failure names the variable
|
|
28
|
+
* (`FINNHUB_API_KEY`) rather than the schema path.
|
|
29
|
+
*/
|
|
30
|
+
export function getServerConfig() {
|
|
31
|
+
_config ??= parseEnvConfig(ServerConfigSchema, {
|
|
32
|
+
apiKey: 'FINNHUB_API_KEY',
|
|
33
|
+
baseUrl: 'FINNHUB_BASE_URL',
|
|
34
|
+
});
|
|
35
|
+
return _config;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=server-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,qIAAqI,CACtI;IACH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,OAAO,CAAC,2BAA2B,CAAC;SACpC,QAAQ,CAAC,mEAAmE,CAAC;CACjF,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,MAAM,EAAE,iBAAiB;QACzB,OAAO,EAAE,kBAAkB;KAC5B,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview finnhub-mcp-server MCP server entry point. Wires the Finnhub
|
|
4
|
+
* service into `setup()` and registers the tool + resource surface.
|
|
5
|
+
* @module index
|
|
6
|
+
*/
|
|
7
|
+
import { createApp } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { allResourceDefinitions } from './mcp-server/resources/definitions/index.js';
|
|
9
|
+
import { allToolDefinitions } from './mcp-server/tools/definitions/index.js';
|
|
10
|
+
import { initFinnhubService } from './services/finnhub/finnhub-service.js';
|
|
11
|
+
await createApp({
|
|
12
|
+
name: 'finnhub-mcp-server',
|
|
13
|
+
title: 'finnhub-mcp-server',
|
|
14
|
+
tools: allToolDefinitions,
|
|
15
|
+
resources: allResourceDefinitions,
|
|
16
|
+
instructions: 'Real-time US-equity market data via Finnhub. Start from a company name: finnhub_search_symbols resolves it to a US ticker, then finnhub_get_quote / _company / _earnings / _news / _recommendations work from that symbol. Free tier is US equities only — international symbols (exchange-suffixed like ".TO") return a clear not_us_or_paid error. Quotes report whether the price is live or the prior close via priceIsLive.',
|
|
17
|
+
setup(core) {
|
|
18
|
+
initFinnhubService(core.config, core.storage);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,sBAAsB;IACjC,YAAY,EACV,kaAAka;IACpa,KAAK,CAAC,IAAI;QACR,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel collecting all resource definitions into
|
|
3
|
+
* `allResourceDefinitions` for `createApp()`.
|
|
4
|
+
* @module mcp-server/resources/definitions/index
|
|
5
|
+
*/
|
|
6
|
+
export declare const allResourceDefinitions: import("@cyanheads/mcp-ts-core").ResourceDefinition<import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
7
|
+
categories: import("zod").ZodArray<import("zod").ZodObject<{
|
|
8
|
+
id: import("zod").ZodString;
|
|
9
|
+
description: import("zod").ZodString;
|
|
10
|
+
}, import("zod/v4/core").$strip>>;
|
|
11
|
+
}, import("zod/v4/core").$strip>, undefined>[];
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,sBAAsB;;;;;8CAA2B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel collecting all resource definitions into
|
|
3
|
+
* `allResourceDefinitions` for `createApp()`.
|
|
4
|
+
* @module mcp-server/resources/definitions/index
|
|
5
|
+
*/
|
|
6
|
+
import { newsCategoriesResource } from './news-categories.resource.js';
|
|
7
|
+
export const allResourceDefinitions = [newsCategoriesResource];
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview finnhub://news-categories — the four valid market-news
|
|
3
|
+
* categories with one-line descriptions. A static reference an agent reads
|
|
4
|
+
* before calling finnhub_get_news in `market` mode. Bounded (4 entries) and
|
|
5
|
+
* fully mirrored by the `category` enum's describe(), so this is a convenience
|
|
6
|
+
* mirror, not a required path.
|
|
7
|
+
* @module mcp-server/resources/definitions/news-categories.resource
|
|
8
|
+
*/
|
|
9
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
10
|
+
export declare const newsCategoriesResource: import("@cyanheads/mcp-ts-core").ResourceDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
categories: z.ZodArray<z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
description: z.ZodString;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>, undefined>;
|
|
16
|
+
//# sourceMappingURL=news-categories.resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"news-categories.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/news-categories.resource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAY,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAUrD,eAAO,MAAM,sBAAsB;;;;;6BAgCjC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview finnhub://news-categories — the four valid market-news
|
|
3
|
+
* categories with one-line descriptions. A static reference an agent reads
|
|
4
|
+
* before calling finnhub_get_news in `market` mode. Bounded (4 entries) and
|
|
5
|
+
* fully mirrored by the `category` enum's describe(), so this is a convenience
|
|
6
|
+
* mirror, not a required path.
|
|
7
|
+
* @module mcp-server/resources/definitions/news-categories.resource
|
|
8
|
+
*/
|
|
9
|
+
import { resource, z } from '@cyanheads/mcp-ts-core';
|
|
10
|
+
/** The four free-tier market-news categories Finnhub's `/news` endpoint accepts. */
|
|
11
|
+
const CATEGORIES = [
|
|
12
|
+
{ id: 'general', description: 'Top general market and business headlines.' },
|
|
13
|
+
{ id: 'forex', description: 'Foreign-exchange and currency market news.' },
|
|
14
|
+
{ id: 'crypto', description: 'Cryptocurrency and digital-asset news.' },
|
|
15
|
+
{ id: 'merger', description: 'Mergers, acquisitions, and corporate deal news.' },
|
|
16
|
+
];
|
|
17
|
+
export const newsCategoriesResource = resource('finnhub://news-categories', {
|
|
18
|
+
name: 'finnhub-news-categories',
|
|
19
|
+
description: 'The four valid market-news categories (general, forex, crypto, merger) with one-line descriptions. Use when selecting the category for finnhub_get_news in market mode.',
|
|
20
|
+
mimeType: 'application/json',
|
|
21
|
+
params: z.object({}),
|
|
22
|
+
output: z.object({
|
|
23
|
+
categories: z
|
|
24
|
+
.array(z
|
|
25
|
+
.object({
|
|
26
|
+
id: z.string().describe('Category value to pass as finnhub_get_news `category`.'),
|
|
27
|
+
description: z.string().describe('What the category covers.'),
|
|
28
|
+
})
|
|
29
|
+
.describe('A single market-news category.'))
|
|
30
|
+
.describe('The four supported market-news categories.'),
|
|
31
|
+
}),
|
|
32
|
+
handler() {
|
|
33
|
+
return { categories: CATEGORIES.map((c) => ({ ...c })) };
|
|
34
|
+
},
|
|
35
|
+
list: () => ({
|
|
36
|
+
resources: [
|
|
37
|
+
{
|
|
38
|
+
uri: 'finnhub://news-categories',
|
|
39
|
+
name: 'finnhub-news-categories',
|
|
40
|
+
mimeType: 'application/json',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=news-categories.resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"news-categories.resource.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/news-categories.resource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAErD,oFAAoF;AACpF,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,4CAA4C,EAAE;IAC5E,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,4CAA4C,EAAE;IAC1E,EAAE,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,wCAAwC,EAAE;IACvE,EAAE,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;CACxE,CAAC;AAEX,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,2BAA2B,EAAE;IAC1E,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EACT,yKAAyK;IAC3K,QAAQ,EAAE,kBAAkB;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,UAAU,EAAE,CAAC;aACV,KAAK,CACJ,CAAC;aACE,MAAM,CAAC;YACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;YACjF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;SAC9D,CAAC;aACD,QAAQ,CAAC,gCAAgC,CAAC,CAC9C;aACA,QAAQ,CAAC,4CAA4C,CAAC;KAC1D,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAC3D,CAAC;IAED,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QACX,SAAS,EAAE;YACT;gBACE,GAAG,EAAE,2BAA2B;gBAChC,IAAI,EAAE,yBAAyB;gBAC/B,QAAQ,EAAE,kBAAkB;aAC7B;SACF;KACF,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview finnhub_get_company — full company context for one US symbol in
|
|
3
|
+
* a single call: profile, headline fundamentals, and sector peers. Combines
|
|
4
|
+
* three endpoints so "tell me about Apple" needs one tool call, not three. The
|
|
5
|
+
* profile is the spine (drives errors); metrics and peers degrade to partial.
|
|
6
|
+
* @module mcp-server/tools/definitions/get-company.tool
|
|
7
|
+
*/
|
|
8
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
10
|
+
export declare const getCompany: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
11
|
+
symbol: z.ZodString;
|
|
12
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
13
|
+
symbol: z.ZodString;
|
|
14
|
+
profile: z.ZodObject<{
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
exchange: z.ZodString;
|
|
17
|
+
industry: z.ZodString;
|
|
18
|
+
country: z.ZodString;
|
|
19
|
+
currency: z.ZodString;
|
|
20
|
+
marketCapitalization: z.ZodNullable<z.ZodNumber>;
|
|
21
|
+
shareOutstanding: z.ZodNullable<z.ZodNumber>;
|
|
22
|
+
ipo: z.ZodNullable<z.ZodString>;
|
|
23
|
+
weburl: z.ZodNullable<z.ZodString>;
|
|
24
|
+
logo: z.ZodNullable<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
fundamentals: z.ZodObject<{
|
|
27
|
+
peTTM: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
epsTTM: z.ZodNullable<z.ZodNumber>;
|
|
29
|
+
week52High: z.ZodNullable<z.ZodNumber>;
|
|
30
|
+
week52Low: z.ZodNullable<z.ZodNumber>;
|
|
31
|
+
beta: z.ZodNullable<z.ZodNumber>;
|
|
32
|
+
dividendYieldTTM: z.ZodNullable<z.ZodNumber>;
|
|
33
|
+
netProfitMarginTTM: z.ZodNullable<z.ZodNumber>;
|
|
34
|
+
grossMarginTTM: z.ZodNullable<z.ZodNumber>;
|
|
35
|
+
revenueGrowthTTMYoy: z.ZodNullable<z.ZodNumber>;
|
|
36
|
+
roeTTM: z.ZodNullable<z.ZodNumber>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
peers: z.ZodArray<z.ZodString>;
|
|
39
|
+
partial: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
}, z.core.$strip>, readonly [{
|
|
41
|
+
readonly reason: "symbol_not_found";
|
|
42
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
43
|
+
readonly when: "/stock/profile2 returned an empty object for the symbol.";
|
|
44
|
+
readonly recovery: "Verify the ticker, or call finnhub_search_symbols to resolve the company name first.";
|
|
45
|
+
}, {
|
|
46
|
+
readonly reason: "not_us_or_paid";
|
|
47
|
+
readonly code: JsonRpcErrorCode.Forbidden;
|
|
48
|
+
readonly when: "Upstream HTTP 403 — international or paid-only symbol.";
|
|
49
|
+
readonly recovery: "Free tier is US equities only; international symbols need a paid Finnhub plan. Try the company's US listing.";
|
|
50
|
+
}], undefined>;
|
|
51
|
+
//# sourceMappingURL=get-company.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-company.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-company.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAU3E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2MrB,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview finnhub_get_company — full company context for one US symbol in
|
|
3
|
+
* a single call: profile, headline fundamentals, and sector peers. Combines
|
|
4
|
+
* three endpoints so "tell me about Apple" needs one tool call, not three. The
|
|
5
|
+
* profile is the spine (drives errors); metrics and peers degrade to partial.
|
|
6
|
+
* @module mcp-server/tools/definitions/get-company.tool
|
|
7
|
+
*/
|
|
8
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
10
|
+
import { getFinnhubService } from '../../../services/finnhub/finnhub-service.js';
|
|
11
|
+
/** Pick a numeric metric, preserving absence as null (never zero-filled). */
|
|
12
|
+
function metricNum(metric, key) {
|
|
13
|
+
const value = metric?.[key];
|
|
14
|
+
return typeof value === 'number' ? value : null;
|
|
15
|
+
}
|
|
16
|
+
export const getCompany = tool('finnhub_get_company', {
|
|
17
|
+
description: 'Full company context for one US symbol in a single call: profile (name, exchange, industry, country, market cap, shares outstanding, IPO date, website, logo), headline fundamentals (P/E, EPS, 52-week range, beta, dividend yield, margins, growth), and sector peers. Combines three endpoints so "tell me about Apple" needs one tool call, not three. Resolve a company name with finnhub_search_symbols first. International symbols are not on the free tier.',
|
|
18
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
19
|
+
input: z.object({
|
|
20
|
+
symbol: z
|
|
21
|
+
.string()
|
|
22
|
+
.min(1)
|
|
23
|
+
.describe('US stock ticker (e.g., "AAPL"). Resolve a company name with finnhub_search_symbols first. International symbols are not on the free tier.'),
|
|
24
|
+
}),
|
|
25
|
+
output: z.object({
|
|
26
|
+
symbol: z.string().describe('The symbol queried (echo of input).'),
|
|
27
|
+
profile: z
|
|
28
|
+
.object({
|
|
29
|
+
name: z.string().describe('Company name.'),
|
|
30
|
+
exchange: z.string().describe('Listing exchange (e.g., "NASDAQ NMS - GLOBAL MARKET").'),
|
|
31
|
+
industry: z.string().describe('Finnhub industry classification.'),
|
|
32
|
+
country: z.string().describe('Country code (e.g., "US").'),
|
|
33
|
+
currency: z.string().describe('Reporting currency.'),
|
|
34
|
+
marketCapitalization: z
|
|
35
|
+
.number()
|
|
36
|
+
.nullable()
|
|
37
|
+
.describe('Market cap in millions of `currency`. Null when omitted.'),
|
|
38
|
+
shareOutstanding: z
|
|
39
|
+
.number()
|
|
40
|
+
.nullable()
|
|
41
|
+
.describe('Shares outstanding in millions. Null when omitted.'),
|
|
42
|
+
ipo: z.string().nullable().describe('IPO date (YYYY-MM-DD). Null when omitted.'),
|
|
43
|
+
weburl: z.string().nullable().describe('Company website. Null when omitted.'),
|
|
44
|
+
logo: z.string().nullable().describe('Logo image URL. Null when omitted.'),
|
|
45
|
+
})
|
|
46
|
+
.describe('Company profile: name, exchange, industry, country, currency, market cap, shares, IPO date, website, and logo.'),
|
|
47
|
+
fundamentals: z
|
|
48
|
+
.object({
|
|
49
|
+
peTTM: z.number().nullable().describe('Price/earnings, trailing twelve months.'),
|
|
50
|
+
epsTTM: z.number().nullable().describe('Earnings per share, TTM.'),
|
|
51
|
+
week52High: z.number().nullable().describe('52-week high price.'),
|
|
52
|
+
week52Low: z.number().nullable().describe('52-week low price.'),
|
|
53
|
+
beta: z.number().nullable().describe('Beta vs. the market.'),
|
|
54
|
+
dividendYieldTTM: z.number().nullable().describe('Current dividend yield %, TTM.'),
|
|
55
|
+
netProfitMarginTTM: z.number().nullable().describe('Net profit margin %, TTM.'),
|
|
56
|
+
grossMarginTTM: z.number().nullable().describe('Gross margin %, TTM.'),
|
|
57
|
+
revenueGrowthTTMYoy: z.number().nullable().describe('Revenue growth % YoY, TTM.'),
|
|
58
|
+
roeTTM: z.number().nullable().describe('Return on equity %, TTM.'),
|
|
59
|
+
})
|
|
60
|
+
.describe('Curated headline fundamentals: P/E, EPS, 52-week range, beta, dividend yield, margins, and growth. Every field nullable — Finnhub omits metrics for thinly-covered names.'),
|
|
61
|
+
peers: z
|
|
62
|
+
.array(z.string())
|
|
63
|
+
.describe('Sector peer symbols from Finnhub (includes the queried symbol). Empty when none.'),
|
|
64
|
+
partial: z
|
|
65
|
+
.array(z.string())
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('Names of the sub-fetches that failed (e.g., ["metrics"]) when the call partially degraded. Absent on a full success.'),
|
|
68
|
+
}),
|
|
69
|
+
errors: [
|
|
70
|
+
{
|
|
71
|
+
reason: 'symbol_not_found',
|
|
72
|
+
code: JsonRpcErrorCode.NotFound,
|
|
73
|
+
when: '/stock/profile2 returned an empty object for the symbol.',
|
|
74
|
+
recovery: 'Verify the ticker, or call finnhub_search_symbols to resolve the company name first.',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
reason: 'not_us_or_paid',
|
|
78
|
+
code: JsonRpcErrorCode.Forbidden,
|
|
79
|
+
when: 'Upstream HTTP 403 — international or paid-only symbol.',
|
|
80
|
+
recovery: "Free tier is US equities only; international symbols need a paid Finnhub plan. Try the company's US listing.",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
async handler(input, ctx) {
|
|
84
|
+
const service = getFinnhubService();
|
|
85
|
+
const [profileResult, metricsResult, peersResult] = await Promise.allSettled([
|
|
86
|
+
service.profile(input.symbol, ctx),
|
|
87
|
+
service.metrics(input.symbol, ctx),
|
|
88
|
+
service.peers(input.symbol, ctx),
|
|
89
|
+
]);
|
|
90
|
+
// Profile leg drives errors.
|
|
91
|
+
if (profileResult.status === 'rejected') {
|
|
92
|
+
const err = profileResult.reason;
|
|
93
|
+
if (err instanceof McpError && err.code === JsonRpcErrorCode.Forbidden) {
|
|
94
|
+
throw ctx.fail('not_us_or_paid', undefined, {
|
|
95
|
+
symbol: input.symbol,
|
|
96
|
+
...ctx.recoveryFor('not_us_or_paid'),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
const rawProfile = profileResult.value;
|
|
102
|
+
// Unknown symbol → empty object. Presence of name/ticker marks a real profile.
|
|
103
|
+
if (!rawProfile.name && !rawProfile.ticker) {
|
|
104
|
+
throw ctx.fail('symbol_not_found', `No profile for symbol "${input.symbol}".`, {
|
|
105
|
+
symbol: input.symbol,
|
|
106
|
+
...ctx.recoveryFor('symbol_not_found'),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const partial = [];
|
|
110
|
+
const metric = metricsResult.status === 'fulfilled' ? metricsResult.value.metric : undefined;
|
|
111
|
+
if (metricsResult.status === 'rejected')
|
|
112
|
+
partial.push('metrics');
|
|
113
|
+
const peers = peersResult.status === 'fulfilled' ? peersResult.value : [];
|
|
114
|
+
if (peersResult.status === 'rejected')
|
|
115
|
+
partial.push('peers');
|
|
116
|
+
const profile = {
|
|
117
|
+
name: rawProfile.name ?? '',
|
|
118
|
+
exchange: rawProfile.exchange ?? '',
|
|
119
|
+
industry: rawProfile.finnhubIndustry ?? '',
|
|
120
|
+
country: rawProfile.country ?? '',
|
|
121
|
+
currency: rawProfile.currency ?? '',
|
|
122
|
+
marketCapitalization: rawProfile.marketCapitalization ?? null,
|
|
123
|
+
shareOutstanding: rawProfile.shareOutstanding ?? null,
|
|
124
|
+
ipo: rawProfile.ipo ?? null,
|
|
125
|
+
weburl: rawProfile.weburl ?? null,
|
|
126
|
+
logo: rawProfile.logo ?? null,
|
|
127
|
+
};
|
|
128
|
+
const fundamentals = {
|
|
129
|
+
peTTM: metricNum(metric, 'peTTM'),
|
|
130
|
+
epsTTM: metricNum(metric, 'epsTTM'),
|
|
131
|
+
week52High: metricNum(metric, '52WeekHigh'),
|
|
132
|
+
week52Low: metricNum(metric, '52WeekLow'),
|
|
133
|
+
beta: metricNum(metric, 'beta'),
|
|
134
|
+
dividendYieldTTM: metricNum(metric, 'currentDividendYieldTTM'),
|
|
135
|
+
netProfitMarginTTM: metricNum(metric, 'netProfitMarginTTM'),
|
|
136
|
+
grossMarginTTM: metricNum(metric, 'grossMarginTTM'),
|
|
137
|
+
revenueGrowthTTMYoy: metricNum(metric, 'revenueGrowthTTMYoy'),
|
|
138
|
+
roeTTM: metricNum(metric, 'roeTTM'),
|
|
139
|
+
};
|
|
140
|
+
ctx.log.info('Company context assembled', {
|
|
141
|
+
symbol: input.symbol,
|
|
142
|
+
partial,
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
symbol: input.symbol,
|
|
146
|
+
profile,
|
|
147
|
+
fundamentals,
|
|
148
|
+
peers,
|
|
149
|
+
...(partial.length > 0 && { partial }),
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
format: (result) => {
|
|
153
|
+
const p = result.profile;
|
|
154
|
+
const lines = [
|
|
155
|
+
`## ${p.name || result.symbol} (${result.symbol})`,
|
|
156
|
+
`**Exchange:** ${p.exchange || 'Not available'} | **Industry:** ${p.industry || 'Not available'} | **Country:** ${p.country || 'Not available'}`,
|
|
157
|
+
];
|
|
158
|
+
const mcap = p.marketCapitalization == null ? 'Not available' : `${p.marketCapitalization}M ${p.currency}`;
|
|
159
|
+
lines.push(`**Market cap:** ${mcap} | **Shares out:** ${p.shareOutstanding == null ? 'Not available' : `${p.shareOutstanding}M`} | **Currency:** ${p.currency || 'Not available'}`);
|
|
160
|
+
lines.push(`**IPO:** ${p.ipo ?? 'Not available'} | **Website:** ${p.weburl ?? 'Not available'} | **Logo:** ${p.logo ?? 'Not available'}`);
|
|
161
|
+
const f = result.fundamentals;
|
|
162
|
+
const rows = [
|
|
163
|
+
['P/E (TTM)', f.peTTM, ''],
|
|
164
|
+
['EPS (TTM)', f.epsTTM, ''],
|
|
165
|
+
['52-week high', f.week52High, ''],
|
|
166
|
+
['52-week low', f.week52Low, ''],
|
|
167
|
+
['Beta', f.beta, ''],
|
|
168
|
+
['Dividend yield (TTM)', f.dividendYieldTTM, '%'],
|
|
169
|
+
['Net profit margin (TTM)', f.netProfitMarginTTM, '%'],
|
|
170
|
+
['Gross margin (TTM)', f.grossMarginTTM, '%'],
|
|
171
|
+
['Revenue growth YoY (TTM)', f.revenueGrowthTTMYoy, '%'],
|
|
172
|
+
['Return on equity (TTM)', f.roeTTM, '%'],
|
|
173
|
+
];
|
|
174
|
+
const present = rows.filter(([, v]) => v != null);
|
|
175
|
+
if (present.length > 0) {
|
|
176
|
+
lines.push('\n**Fundamentals:**');
|
|
177
|
+
for (const [label, value, unit] of present) {
|
|
178
|
+
lines.push(`- ${label}: ${value}${unit}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
lines.push('\n**Fundamentals:** Not available (thinly covered).');
|
|
183
|
+
}
|
|
184
|
+
lines.push(`\n**Peers:** ${result.peers.length > 0 ? result.peers.join(', ') : 'None'}`);
|
|
185
|
+
if (result.partial && result.partial.length > 0) {
|
|
186
|
+
lines.push(`\n⚠ partial: ${result.partial.join(', ')} unavailable`);
|
|
187
|
+
}
|
|
188
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=get-company.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-company.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-company.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,6EAA6E;AAC7E,SAAS,SAAS,CAAC,MAAuC,EAAE,GAAW;IACrE,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,EAAE;IACpD,WAAW,EACT,scAAsc;IACxc,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,2IAA2I,CAC5I;KACJ,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;QAClE,OAAO,EAAE,CAAC;aACP,MAAM,CAAC;YACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;YAC1C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,C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KAAK,KAAK,KAAK,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QACpE,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAEzF,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtE,CAAC;QAED,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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview finnhub_get_earnings — earnings in two modes. `history`: a
|
|
3
|
+
* symbol's past quarters with actual-vs-estimate surprises. `calendar`:
|
|
4
|
+
* market-wide upcoming releases in a date window. Mode-consolidated because both
|
|
5
|
+
* are the same noun (earnings) from two angles.
|
|
6
|
+
* @module mcp-server/tools/definitions/get-earnings.tool
|
|
7
|
+
*/
|
|
8
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
10
|
+
export declare const getEarnings: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
11
|
+
mode: z.ZodEnum<{
|
|
12
|
+
history: "history";
|
|
13
|
+
calendar: "calendar";
|
|
14
|
+
}>;
|
|
15
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
16
|
+
from: z.ZodOptional<z.ZodString>;
|
|
17
|
+
to: z.ZodOptional<z.ZodString>;
|
|
18
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
mode: z.ZodEnum<{
|
|
21
|
+
history: "history";
|
|
22
|
+
calendar: "calendar";
|
|
23
|
+
}>;
|
|
24
|
+
history: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
period: z.ZodString;
|
|
26
|
+
year: z.ZodNumber;
|
|
27
|
+
quarter: z.ZodNumber;
|
|
28
|
+
actualEPS: z.ZodNullable<z.ZodNumber>;
|
|
29
|
+
estimateEPS: z.ZodNullable<z.ZodNumber>;
|
|
30
|
+
surprise: z.ZodNullable<z.ZodNumber>;
|
|
31
|
+
surprisePercent: z.ZodNullable<z.ZodNumber>;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
calendar: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
|
+
symbol: z.ZodString;
|
|
35
|
+
date: z.ZodString;
|
|
36
|
+
hour: z.ZodString;
|
|
37
|
+
epsEstimate: z.ZodNullable<z.ZodNumber>;
|
|
38
|
+
revenueEstimate: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
year: z.ZodNumber;
|
|
40
|
+
quarter: z.ZodNumber;
|
|
41
|
+
}, z.core.$strip>>>;
|
|
42
|
+
}, z.core.$strip>, readonly [{
|
|
43
|
+
readonly reason: "missing_symbol";
|
|
44
|
+
readonly code: JsonRpcErrorCode.InvalidParams;
|
|
45
|
+
readonly when: "mode 'history' was requested without a symbol.";
|
|
46
|
+
readonly recovery: "Provide a `symbol` for history mode, or switch to mode: calendar for the market-wide upcoming-releases feed.";
|
|
47
|
+
}, {
|
|
48
|
+
readonly reason: "not_us_or_paid";
|
|
49
|
+
readonly code: JsonRpcErrorCode.Forbidden;
|
|
50
|
+
readonly when: "Upstream HTTP 403 on the symbol.";
|
|
51
|
+
readonly recovery: "Free tier is US equities only; use a US symbol or a paid plan.";
|
|
52
|
+
}], {
|
|
53
|
+
readonly totalCount: z.ZodNumber;
|
|
54
|
+
readonly truncated: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
readonly shown: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
readonly cap: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}>;
|
|
59
|
+
//# sourceMappingURL=get-earnings.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-earnings.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-earnings.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAQ3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmOtB,CAAC"}
|