deepviews-mcp 1.0.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/LICENSE +190 -0
- package/README.md +103 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +8 -0
- package/dist/tools.js +828 -0
- package/dist/tools.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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 the 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 the 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 any 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
|
+
Copyright 2026 DeepViews
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# DeepViews MCP Server
|
|
2
|
+
|
|
3
|
+
Free financial data MCP server for Claude Code and any MCP-compatible AI client. Access company analysis, DCF valuation, comparable companies, industry benchmarks, stock screening, and news sentiment -- **no API key required**.
|
|
4
|
+
|
|
5
|
+
A free alternative to paid financial data MCP integrations like FactSet ($20-80K/year) and S&P Capital IQ ($25-100K/year).
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
### Option 1: npx (no install)
|
|
10
|
+
|
|
11
|
+
Add to your MCP settings:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"deepviews": {
|
|
17
|
+
"command": "npx",
|
|
18
|
+
"args": ["-y", "deepviews-mcp"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Option 2: Global install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g deepviews-mcp
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then add to your MCP settings:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"deepviews": {
|
|
36
|
+
"command": "deepviews-mcp"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Option 3: Claude Code Plugin
|
|
43
|
+
|
|
44
|
+
If available in the Claude Code plugin directory:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
/plugin install deepviews@claude-plugins-official
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Available Tools
|
|
51
|
+
|
|
52
|
+
| Tool | Description | Data Source |
|
|
53
|
+
|------|-------------|-------------|
|
|
54
|
+
| `analyze_company` | Comprehensive financial analysis: valuation ratios, income statement, balance sheet, cash flow, profitability margins | SEC EDGAR + Polygon.io |
|
|
55
|
+
| `calculate_dcf` | DCF valuation with sensitivity matrix, reverse DCF, and margin of safety | SEC EDGAR + Polygon.io + DeepViews |
|
|
56
|
+
| `get_comparables` | Comparable company analysis: target vs 10 closest peers by market cap, 8 metrics each | SEC EDGAR + Polygon.io |
|
|
57
|
+
| `get_industry_benchmarks` | Peer comparison with P25/P50/P75 for P/E, P/B, EV/EBITDA, margins, ROE, D/E across 10 metrics | SEC EDGAR + Polygon.io |
|
|
58
|
+
| `get_analyst_ratings` | Estimated consensus rating, price targets, and rating distribution (DeepViews estimate) | Polygon.io + DeepViews |
|
|
59
|
+
| `screen_stocks` | Filter stocks by sector, industry, P/E, P/B, EV/EBITDA, ROE, D/E, market cap, revenue | SEC EDGAR + Polygon.io |
|
|
60
|
+
| `get_news_sentiment` | 30-day news sentiment score, trend, and article breakdown | Polygon.io News API |
|
|
61
|
+
|
|
62
|
+
## Example Usage
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
> Analyze Apple's financials and tell me how it compares to peers
|
|
66
|
+
|
|
67
|
+
> Calculate a DCF for MSFT with 12% growth rate and 10% WACC
|
|
68
|
+
|
|
69
|
+
> Show me NVDA's comparable companies in the semiconductor industry
|
|
70
|
+
|
|
71
|
+
> Screen for technology stocks with P/E under 25 and ROE above 20%
|
|
72
|
+
|
|
73
|
+
> What's the news sentiment around TSLA right now?
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Data Coverage
|
|
77
|
+
|
|
78
|
+
- **US-listed equities**: All companies filing with SEC EDGAR (10-K, 10-Q)
|
|
79
|
+
- **Market data**: Real-time prices and market caps via Polygon.io
|
|
80
|
+
- **Financial statements**: Up to 4 years of annual data
|
|
81
|
+
- **Comparable companies**: SIC-based peers sorted by market cap proximity
|
|
82
|
+
- **Industry benchmarks**: SIC-code based peer groups with hybrid EDGAR/Polygon metrics
|
|
83
|
+
- **News**: 30-day rolling window, up to 50 articles per ticker
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
| Variable | Default | Description |
|
|
88
|
+
|----------|---------|-------------|
|
|
89
|
+
| `DEEPVIEWS_API_URL` | `https://www.deepviews.dev` | Base URL for API calls. Override for local development. |
|
|
90
|
+
|
|
91
|
+
## Data Sources & Attribution
|
|
92
|
+
|
|
93
|
+
- **SEC EDGAR** -- Financial statements, peer groupings, SIC classifications
|
|
94
|
+
- **Polygon.io** -- Market caps, stock prices, news articles, company metadata
|
|
95
|
+
- **DeepViews** -- DCF calculations, analyst rating estimates, sentiment analysis, comparable company analysis
|
|
96
|
+
|
|
97
|
+
## Rate Limits
|
|
98
|
+
|
|
99
|
+
The DeepViews API enforces rate limiting (60 requests/minute). The MCP server respects these limits. If you receive a rate limit error, wait a moment and retry.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* DeepViews MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Free financial data MCP server for Claude Code.
|
|
6
|
+
* Wraps DeepViews Terminal API routes as MCP tools for company analysis,
|
|
7
|
+
* DCF valuation, industry benchmarks, stock screening, and sentiment.
|
|
8
|
+
*
|
|
9
|
+
* Transport: stdio (for Claude Code integration)
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* DeepViews MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Free financial data MCP server for Claude Code.
|
|
6
|
+
* Wraps DeepViews Terminal API routes as MCP tools for company analysis,
|
|
7
|
+
* DCF valuation, industry benchmarks, stock screening, and sentiment.
|
|
8
|
+
*
|
|
9
|
+
* Transport: stdio (for Claude Code integration)
|
|
10
|
+
*/
|
|
11
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
12
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
|
+
import { registerTools } from "./tools.js";
|
|
14
|
+
const SERVER_NAME = "deepviews-terminal";
|
|
15
|
+
const SERVER_VERSION = "1.0.0";
|
|
16
|
+
async function main() {
|
|
17
|
+
const server = new Server({
|
|
18
|
+
name: SERVER_NAME,
|
|
19
|
+
version: SERVER_VERSION,
|
|
20
|
+
}, {
|
|
21
|
+
capabilities: {
|
|
22
|
+
tools: {},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
// Register all tool definitions and handlers
|
|
26
|
+
registerTools(server);
|
|
27
|
+
// Connect via stdio transport
|
|
28
|
+
const transport = new StdioServerTransport();
|
|
29
|
+
await server.connect(transport);
|
|
30
|
+
// Graceful shutdown
|
|
31
|
+
process.on("SIGINT", async () => {
|
|
32
|
+
await server.close();
|
|
33
|
+
process.exit(0);
|
|
34
|
+
});
|
|
35
|
+
process.on("SIGTERM", async () => {
|
|
36
|
+
await server.close();
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
main().catch((error) => {
|
|
41
|
+
console.error("Fatal error starting DeepViews MCP server:", error);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2C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|
4
|
+
* Tool definitions and handlers that wrap DeepViews Terminal API routes.
|
|
5
|
+
* Each tool calls the production API and formats the response as readable text.
|
|
6
|
+
*/
|
|
7
|
+
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
|
+
export declare function registerTools(server: Server): void;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepViews MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Tool definitions and handlers that wrap DeepViews Terminal API routes.
|
|
5
|
+
* Each tool calls the production API and formats the response as readable text.
|
|
6
|
+
*/
|
|
7
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Configuration
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const BASE_URL = process.env.DEEPVIEWS_API_URL || "https://www.deepviews.dev";
|
|
12
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
13
|
+
const USER_AGENT = "DeepViews-MCP/1.0";
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// HTTP helper
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
async function callApi(path, options) {
|
|
18
|
+
const controller = new AbortController();
|
|
19
|
+
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
20
|
+
try {
|
|
21
|
+
const fetchOptions = {
|
|
22
|
+
method: options?.method ?? "GET",
|
|
23
|
+
signal: controller.signal,
|
|
24
|
+
headers: {
|
|
25
|
+
"User-Agent": USER_AGENT,
|
|
26
|
+
...(options?.body ? { "Content-Type": "application/json" } : {}),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
if (options?.body) {
|
|
30
|
+
fetchOptions.body = JSON.stringify(options.body);
|
|
31
|
+
}
|
|
32
|
+
const response = await fetch(`${BASE_URL}${path}`, fetchOptions);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const text = await response.text().catch(() => "");
|
|
35
|
+
throw new Error(`API error ${response.status}: ${text}`);
|
|
36
|
+
}
|
|
37
|
+
return await response.json();
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
clearTimeout(timeoutId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Formatting helpers
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
function fmt(value, decimals = 2) {
|
|
47
|
+
if (value === null || value === undefined || !isFinite(value))
|
|
48
|
+
return "N/A";
|
|
49
|
+
return value.toFixed(decimals);
|
|
50
|
+
}
|
|
51
|
+
function fmtPct(value) {
|
|
52
|
+
if (value === null || value === undefined || !isFinite(value))
|
|
53
|
+
return "N/A";
|
|
54
|
+
return `${(value * 100).toFixed(1)}%`;
|
|
55
|
+
}
|
|
56
|
+
function fmtMoney(value) {
|
|
57
|
+
if (value === null || value === undefined || !isFinite(value))
|
|
58
|
+
return "N/A";
|
|
59
|
+
const abs = Math.abs(value);
|
|
60
|
+
const sign = value < 0 ? "-" : "";
|
|
61
|
+
if (abs >= 1e12)
|
|
62
|
+
return `${sign}$${(abs / 1e12).toFixed(2)}T`;
|
|
63
|
+
if (abs >= 1e9)
|
|
64
|
+
return `${sign}$${(abs / 1e9).toFixed(2)}B`;
|
|
65
|
+
if (abs >= 1e6)
|
|
66
|
+
return `${sign}$${(abs / 1e6).toFixed(1)}M`;
|
|
67
|
+
if (abs >= 1e3)
|
|
68
|
+
return `${sign}$${(abs / 1e3).toFixed(1)}K`;
|
|
69
|
+
return `${sign}$${abs.toFixed(2)}`;
|
|
70
|
+
}
|
|
71
|
+
function fmtPrice(value) {
|
|
72
|
+
if (value === null || value === undefined || !isFinite(value))
|
|
73
|
+
return "N/A";
|
|
74
|
+
return `$${value.toFixed(2)}`;
|
|
75
|
+
}
|
|
76
|
+
function safeNum(v) {
|
|
77
|
+
if (v === null || v === undefined)
|
|
78
|
+
return null;
|
|
79
|
+
const n = typeof v === "string" ? parseFloat(v) : v;
|
|
80
|
+
return isFinite(n) ? n : null;
|
|
81
|
+
}
|
|
82
|
+
function line(label, value) {
|
|
83
|
+
return ` ${label.padEnd(28)} ${value}`;
|
|
84
|
+
}
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Tool definitions
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
const TOOL_DEFINITIONS = [
|
|
89
|
+
{
|
|
90
|
+
name: "analyze_company",
|
|
91
|
+
description: "Get comprehensive financial analysis for a company including valuation ratios, financial statements, and key metrics. Data sourced from SEC EDGAR filings and Polygon.io market data.",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
ticker: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "Stock ticker symbol (e.g., AAPL, MSFT, GOOGL)",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ["ticker"],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "calculate_dcf",
|
|
105
|
+
description: "Calculate Discounted Cash Flow valuation with sensitivity analysis and reverse DCF. Returns fair value per share, margin of safety, projected FCFs, and a WACC vs terminal growth sensitivity matrix.",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: {
|
|
109
|
+
ticker: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Stock ticker symbol (e.g., AAPL, MSFT)",
|
|
112
|
+
},
|
|
113
|
+
growth_rate: {
|
|
114
|
+
type: "number",
|
|
115
|
+
description: "Annual FCF growth rate during projection period (decimal, e.g., 0.10 for 10%). Defaults to historical FCF CAGR or 8%.",
|
|
116
|
+
},
|
|
117
|
+
terminal_growth: {
|
|
118
|
+
type: "number",
|
|
119
|
+
description: "Perpetual growth rate after projection period (decimal, e.g., 0.025 for 2.5%). Default: 0.025.",
|
|
120
|
+
},
|
|
121
|
+
wacc: {
|
|
122
|
+
type: "number",
|
|
123
|
+
description: "Weighted Average Cost of Capital (decimal, e.g., 0.10 for 10%). Default: computed via CAPM.",
|
|
124
|
+
},
|
|
125
|
+
projection_years: {
|
|
126
|
+
type: "number",
|
|
127
|
+
description: "Number of years to project FCF (5-20). Default: 10.",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ["ticker"],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "get_industry_benchmarks",
|
|
135
|
+
description: "Get industry benchmark data comparing a company against its sector peers. Returns 25th/50th/75th percentile for P/E, P/B, P/S, EV/EBITDA, margins, ROE, current ratio, and debt-to-equity. Data from SEC EDGAR filings with Polygon.io market caps.",
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: {
|
|
139
|
+
ticker: {
|
|
140
|
+
type: "string",
|
|
141
|
+
description: "Stock ticker symbol (e.g., AAPL, MSFT)",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
required: ["ticker"],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "get_analyst_ratings",
|
|
149
|
+
description: "Get estimated analyst consensus ratings, price targets, and recommendation distribution for a company. Note: ratings are DeepViews estimates derived from valuation metrics, not real analyst data.",
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
ticker: {
|
|
154
|
+
type: "string",
|
|
155
|
+
description: "Stock ticker symbol (e.g., AAPL, MSFT)",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
required: ["ticker"],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "screen_stocks",
|
|
163
|
+
description: "Screen stocks by sector, industry, and financial metrics. Filter by P/E, P/B, EV/EBITDA, ROE, debt-to-equity, market cap, and revenue. Returns matching companies with full financial profiles.",
|
|
164
|
+
inputSchema: {
|
|
165
|
+
type: "object",
|
|
166
|
+
properties: {
|
|
167
|
+
sector: {
|
|
168
|
+
type: "string",
|
|
169
|
+
description: 'GICS sector name (e.g., "Technology", "Healthcare", "Financial Services", "Energy", "Industrials", "Consumer Cyclical", "Consumer Defensive", "Communication Services", "Utilities", "Real Estate", "Basic Materials")',
|
|
170
|
+
},
|
|
171
|
+
industry: {
|
|
172
|
+
type: "string",
|
|
173
|
+
description: "Industry within the sector (optional)",
|
|
174
|
+
},
|
|
175
|
+
pe_min: {
|
|
176
|
+
type: "number",
|
|
177
|
+
description: "Minimum P/E ratio",
|
|
178
|
+
},
|
|
179
|
+
pe_max: {
|
|
180
|
+
type: "number",
|
|
181
|
+
description: "Maximum P/E ratio",
|
|
182
|
+
},
|
|
183
|
+
pb_min: {
|
|
184
|
+
type: "number",
|
|
185
|
+
description: "Minimum P/B ratio",
|
|
186
|
+
},
|
|
187
|
+
pb_max: {
|
|
188
|
+
type: "number",
|
|
189
|
+
description: "Maximum P/B ratio",
|
|
190
|
+
},
|
|
191
|
+
eveb_min: {
|
|
192
|
+
type: "number",
|
|
193
|
+
description: "Minimum EV/EBITDA",
|
|
194
|
+
},
|
|
195
|
+
eveb_max: {
|
|
196
|
+
type: "number",
|
|
197
|
+
description: "Maximum EV/EBITDA",
|
|
198
|
+
},
|
|
199
|
+
roe_min: {
|
|
200
|
+
type: "number",
|
|
201
|
+
description: "Minimum Return on Equity (decimal, e.g., 0.15 for 15%)",
|
|
202
|
+
},
|
|
203
|
+
roe_max: {
|
|
204
|
+
type: "number",
|
|
205
|
+
description: "Maximum Return on Equity (decimal)",
|
|
206
|
+
},
|
|
207
|
+
de_min: {
|
|
208
|
+
type: "number",
|
|
209
|
+
description: "Minimum Debt-to-Equity ratio",
|
|
210
|
+
},
|
|
211
|
+
de_max: {
|
|
212
|
+
type: "number",
|
|
213
|
+
description: "Maximum Debt-to-Equity ratio",
|
|
214
|
+
},
|
|
215
|
+
mc_min: {
|
|
216
|
+
type: "number",
|
|
217
|
+
description: "Minimum market cap in dollars (e.g., 1000000000 for $1B)",
|
|
218
|
+
},
|
|
219
|
+
mc_max: {
|
|
220
|
+
type: "number",
|
|
221
|
+
description: "Maximum market cap in dollars",
|
|
222
|
+
},
|
|
223
|
+
rev_min: {
|
|
224
|
+
type: "number",
|
|
225
|
+
description: "Minimum revenue in dollars",
|
|
226
|
+
},
|
|
227
|
+
rev_max: {
|
|
228
|
+
type: "number",
|
|
229
|
+
description: "Maximum revenue in dollars",
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
required: ["sector"],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "get_news_sentiment",
|
|
237
|
+
description: "Get aggregated news sentiment analysis for a company over the last 30 days. Returns sentiment score (-100 to +100), label, trend, and article count breakdown. Powered by Polygon.io news API.",
|
|
238
|
+
inputSchema: {
|
|
239
|
+
type: "object",
|
|
240
|
+
properties: {
|
|
241
|
+
ticker: {
|
|
242
|
+
type: "string",
|
|
243
|
+
description: "Stock ticker symbol (e.g., AAPL, MSFT)",
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
required: ["ticker"],
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "get_comparables",
|
|
251
|
+
description: "Get comparable company analysis showing a target company vs its closest peers by market cap. Returns per-company metrics (P/E, P/B, P/S, EV/EBITDA, Gross Margin, Net Margin, ROE, D/E) with group statistics. Data from SEC EDGAR filings + Polygon.io market caps.",
|
|
252
|
+
inputSchema: {
|
|
253
|
+
type: "object",
|
|
254
|
+
properties: {
|
|
255
|
+
ticker: {
|
|
256
|
+
type: "string",
|
|
257
|
+
description: "Stock ticker symbol (e.g., AAPL, MSFT)",
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
required: ["ticker"],
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
];
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
// Tool handlers
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
async function handleAnalyzeCompany(ticker) {
|
|
268
|
+
const data = (await callApi(`/api/company/${encodeURIComponent(ticker)}`));
|
|
269
|
+
const name = data.name || ticker.toUpperCase();
|
|
270
|
+
const m = data.metrics || {};
|
|
271
|
+
const fin = data.financials || {};
|
|
272
|
+
// Latest income statement
|
|
273
|
+
const latestIS = fin.incomeStatement?.[0] || {};
|
|
274
|
+
const latestBS = fin.balanceSheet?.[0] || {};
|
|
275
|
+
const latestCF = fin.cashFlow?.[0] || {};
|
|
276
|
+
const lines = [
|
|
277
|
+
`=== ${name} (${ticker.toUpperCase()}) ===`,
|
|
278
|
+
`Data Source: SEC EDGAR + Polygon.io`,
|
|
279
|
+
"",
|
|
280
|
+
"--- Valuation Metrics ---",
|
|
281
|
+
line("Market Cap", fmtMoney(safeNum(m.marketCap))),
|
|
282
|
+
line("Enterprise Value", fmtMoney(safeNum(m.enterpriseValue))),
|
|
283
|
+
line("Trailing P/E", fmt(safeNum(m.trailingPE))),
|
|
284
|
+
line("Forward P/E", fmt(safeNum(m.forwardPE))),
|
|
285
|
+
line("Price/Book", fmt(safeNum(m.priceToBook))),
|
|
286
|
+
line("Price/Sales", fmt(safeNum(m.priceToSales))),
|
|
287
|
+
line("EV/EBITDA", fmt(safeNum(m.evToEbitda ?? m.enterpriseToEbitda))),
|
|
288
|
+
line("EV/Sales", fmt(safeNum(m.evToSales ?? m.enterpriseToRevenue))),
|
|
289
|
+
line("Price/FCF", fmt(safeNum(m.priceToFcf))),
|
|
290
|
+
line("Dividend Yield", fmtPct(safeNum(m.dividendYield))),
|
|
291
|
+
line("Beta", fmt(safeNum(m.beta))),
|
|
292
|
+
"",
|
|
293
|
+
"--- Latest Income Statement ---",
|
|
294
|
+
line("Revenue", fmtMoney(safeNum(latestIS.Revenue ?? latestIS.Revenues))),
|
|
295
|
+
line("Gross Profit", fmtMoney(safeNum(latestIS.GrossProfit))),
|
|
296
|
+
line("Operating Income", fmtMoney(safeNum(latestIS.OperatingIncome ?? latestIS.OperatingIncomeLoss))),
|
|
297
|
+
line("Net Income", fmtMoney(safeNum(latestIS.NetIncome ?? latestIS.NetIncomeLoss))),
|
|
298
|
+
line("EPS", fmt(safeNum(latestIS.EarningsPerShare ?? latestIS.EarningsPerShareDiluted ?? m.eps))),
|
|
299
|
+
];
|
|
300
|
+
// Compute margins if we have revenue
|
|
301
|
+
const rev = safeNum(latestIS.Revenue ?? latestIS.Revenues);
|
|
302
|
+
const gp = safeNum(latestIS.GrossProfit);
|
|
303
|
+
const oi = safeNum(latestIS.OperatingIncome ?? latestIS.OperatingIncomeLoss);
|
|
304
|
+
const ni = safeNum(latestIS.NetIncome ?? latestIS.NetIncomeLoss);
|
|
305
|
+
if (rev && rev > 0) {
|
|
306
|
+
lines.push("");
|
|
307
|
+
lines.push("--- Profitability ---");
|
|
308
|
+
if (gp !== null)
|
|
309
|
+
lines.push(line("Gross Margin", fmtPct(gp / rev)));
|
|
310
|
+
if (oi !== null)
|
|
311
|
+
lines.push(line("Operating Margin", fmtPct(oi / rev)));
|
|
312
|
+
if (ni !== null)
|
|
313
|
+
lines.push(line("Net Margin", fmtPct(ni / rev)));
|
|
314
|
+
}
|
|
315
|
+
lines.push("");
|
|
316
|
+
lines.push("--- Balance Sheet ---");
|
|
317
|
+
lines.push(line("Total Assets", fmtMoney(safeNum(latestBS.TotalAssets ?? latestBS.Assets))));
|
|
318
|
+
lines.push(line("Total Equity", fmtMoney(safeNum(latestBS.TotalEquity ?? latestBS.StockholdersEquity))));
|
|
319
|
+
lines.push(line("Total Debt", fmtMoney(safeNum(latestBS.TotalDebt ?? latestBS.LongTermDebt))));
|
|
320
|
+
lines.push(line("Cash & Equivalents", fmtMoney(safeNum(latestBS.CashAndEquivalents ?? latestBS.Cash))));
|
|
321
|
+
const equity = safeNum(latestBS.TotalEquity ?? latestBS.StockholdersEquity);
|
|
322
|
+
const debt = safeNum(latestBS.TotalDebt ?? latestBS.LongTermDebt);
|
|
323
|
+
if (equity && equity > 0 && debt !== null) {
|
|
324
|
+
lines.push(line("Debt/Equity", fmt(debt / equity)));
|
|
325
|
+
}
|
|
326
|
+
if (equity && equity > 0 && ni !== null) {
|
|
327
|
+
lines.push(line("Return on Equity", fmtPct(ni / equity)));
|
|
328
|
+
}
|
|
329
|
+
lines.push("");
|
|
330
|
+
lines.push("--- Cash Flow ---");
|
|
331
|
+
lines.push(line("Operating Cash Flow", fmtMoney(safeNum(latestCF.OperatingCashFlow ?? latestCF.NetCashFromOperating))));
|
|
332
|
+
lines.push(line("Capital Expenditure", fmtMoney(safeNum(latestCF.CapitalExpenditure ?? latestCF.CapitalExpenditures))));
|
|
333
|
+
lines.push(line("Free Cash Flow", fmtMoney(safeNum(latestCF.FreeCashFlow))));
|
|
334
|
+
if (data.currentPrice) {
|
|
335
|
+
lines.push("");
|
|
336
|
+
lines.push(line("Current Price", fmtPrice(data.currentPrice)));
|
|
337
|
+
}
|
|
338
|
+
if (m.sector) {
|
|
339
|
+
lines.push(line("Sector", m.sector));
|
|
340
|
+
}
|
|
341
|
+
return lines.join("\n");
|
|
342
|
+
}
|
|
343
|
+
async function handleCalculateDcf(args) {
|
|
344
|
+
const ticker = args.ticker.toUpperCase();
|
|
345
|
+
// Step 1: Fetch company data to get FCF, net debt, shares outstanding, price
|
|
346
|
+
const data = (await callApi(`/api/company/${encodeURIComponent(ticker)}`));
|
|
347
|
+
const name = data.name || ticker;
|
|
348
|
+
const m = data.metrics || {};
|
|
349
|
+
const fin = data.financials || {};
|
|
350
|
+
const latestCF = fin.cashFlow?.[0] || {};
|
|
351
|
+
const latestBS = fin.balanceSheet?.[0] || {};
|
|
352
|
+
const currentPrice = safeNum(data.currentPrice) ?? 0;
|
|
353
|
+
const marketCap = safeNum(m.marketCap) ?? 0;
|
|
354
|
+
// Extract FCF
|
|
355
|
+
const baseFCF = safeNum(latestCF.FreeCashFlow);
|
|
356
|
+
if (!baseFCF || baseFCF <= 0) {
|
|
357
|
+
return [
|
|
358
|
+
`=== DCF Valuation: ${name} (${ticker}) ===`,
|
|
359
|
+
"",
|
|
360
|
+
`Unable to perform DCF analysis: Free Cash Flow is ${baseFCF === null ? "not available" : fmtMoney(baseFCF)}.`,
|
|
361
|
+
"DCF requires positive free cash flow as the base for projections.",
|
|
362
|
+
"",
|
|
363
|
+
`Current Price: ${fmtPrice(currentPrice)}`,
|
|
364
|
+
`Market Cap: ${fmtMoney(marketCap)}`,
|
|
365
|
+
].join("\n");
|
|
366
|
+
}
|
|
367
|
+
// Extract balance sheet items
|
|
368
|
+
const totalDebt = safeNum(latestBS.TotalDebt ?? latestBS.LongTermDebt) ?? 0;
|
|
369
|
+
const cash = safeNum(latestBS.CashAndEquivalents ?? latestBS.Cash ?? latestBS.CashAndShortTermInvestments) ?? 0;
|
|
370
|
+
const netDebt = totalDebt - cash;
|
|
371
|
+
// Shares outstanding (derive from market cap / price)
|
|
372
|
+
const sharesOutstanding = currentPrice > 0 && marketCap > 0
|
|
373
|
+
? marketCap / currentPrice
|
|
374
|
+
: safeNum(m.sharesOutstanding) ?? 0;
|
|
375
|
+
if (sharesOutstanding <= 0) {
|
|
376
|
+
return `Unable to perform DCF: cannot determine shares outstanding for ${ticker}.`;
|
|
377
|
+
}
|
|
378
|
+
// Defaults
|
|
379
|
+
const projectionYears = args.projection_years ?? 10;
|
|
380
|
+
const terminalGrowth = args.terminal_growth ?? 0.025;
|
|
381
|
+
// Compute WACC via CAPM if not provided
|
|
382
|
+
let wacc = args.wacc;
|
|
383
|
+
if (wacc === undefined) {
|
|
384
|
+
const beta = safeNum(m.beta) ?? 1.0;
|
|
385
|
+
const riskFreeRate = 0.0425;
|
|
386
|
+
const erp = 0.055;
|
|
387
|
+
const costOfEquity = riskFreeRate + beta * erp;
|
|
388
|
+
const costOfDebt = 0.05 * (1 - 0.21); // 5% pre-tax, 21% tax
|
|
389
|
+
const equityWeight = marketCap > 0 ? marketCap / (marketCap + totalDebt) : 0.8;
|
|
390
|
+
wacc = equityWeight * costOfEquity + (1 - equityWeight) * costOfDebt;
|
|
391
|
+
}
|
|
392
|
+
// Growth rate: use provided or default 8%
|
|
393
|
+
const growthRate = args.growth_rate ?? 0.08;
|
|
394
|
+
// Run DCF calculation inline (mirrors lib/dcf.ts logic)
|
|
395
|
+
function runDCF(base, growth, termGrowth, disc, years, nd, shares) {
|
|
396
|
+
const projections = [];
|
|
397
|
+
let currentFCF = base;
|
|
398
|
+
let totalPV = 0;
|
|
399
|
+
for (let i = 1; i <= years; i++) {
|
|
400
|
+
currentFCF = currentFCF * (1 + growth);
|
|
401
|
+
const df = 1 / Math.pow(1 + disc, i);
|
|
402
|
+
const pv = currentFCF * df;
|
|
403
|
+
projections.push({ year: i, fcf: currentFCF, pv });
|
|
404
|
+
totalPV += pv;
|
|
405
|
+
}
|
|
406
|
+
const finalFCF = projections[projections.length - 1]?.fcf ?? base;
|
|
407
|
+
const tv = disc > termGrowth
|
|
408
|
+
? (finalFCF * (1 + termGrowth)) / (disc - termGrowth)
|
|
409
|
+
: 0;
|
|
410
|
+
const pvTV = tv / Math.pow(1 + disc, years);
|
|
411
|
+
const ev = totalPV + pvTV;
|
|
412
|
+
const eqVal = ev - nd;
|
|
413
|
+
const fv = shares > 0 ? eqVal / shares : 0;
|
|
414
|
+
return {
|
|
415
|
+
projections,
|
|
416
|
+
terminalValue: tv,
|
|
417
|
+
pvTerminal: pvTV,
|
|
418
|
+
enterpriseValue: ev,
|
|
419
|
+
equityValue: eqVal,
|
|
420
|
+
fairValue: fv,
|
|
421
|
+
totalPVofFCFs: totalPV,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
const dcf = runDCF(baseFCF, growthRate, terminalGrowth, wacc, projectionYears, netDebt, sharesOutstanding);
|
|
425
|
+
// Margin of safety
|
|
426
|
+
const mos = dcf.fairValue > 0
|
|
427
|
+
? ((dcf.fairValue - currentPrice) / dcf.fairValue) * 100
|
|
428
|
+
: 0;
|
|
429
|
+
// Reverse DCF (implied growth rate)
|
|
430
|
+
let impliedGrowth = 0;
|
|
431
|
+
let converged = false;
|
|
432
|
+
if (baseFCF > 0 && wacc > terminalGrowth && sharesOutstanding > 0 && currentPrice > 0) {
|
|
433
|
+
let lo = -0.2;
|
|
434
|
+
let hi = 0.6;
|
|
435
|
+
for (let i = 0; i < 100; i++) {
|
|
436
|
+
const mid = (lo + hi) / 2;
|
|
437
|
+
const res = runDCF(baseFCF, mid, terminalGrowth, wacc, projectionYears, netDebt, sharesOutstanding);
|
|
438
|
+
const diff = res.fairValue - currentPrice;
|
|
439
|
+
if (Math.abs(diff) < 0.01) {
|
|
440
|
+
converged = true;
|
|
441
|
+
impliedGrowth = mid;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
if (diff > 0)
|
|
445
|
+
hi = mid;
|
|
446
|
+
else
|
|
447
|
+
lo = mid;
|
|
448
|
+
impliedGrowth = mid;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// Sensitivity matrix (5x5: WACC x Terminal Growth)
|
|
452
|
+
const waccStep = 0.005;
|
|
453
|
+
const growthStep = 0.005;
|
|
454
|
+
const waccValues = [];
|
|
455
|
+
const tgValues = [];
|
|
456
|
+
for (let i = -2; i <= 2; i++) {
|
|
457
|
+
waccValues.push(wacc + i * waccStep);
|
|
458
|
+
tgValues.push(terminalGrowth + i * growthStep);
|
|
459
|
+
}
|
|
460
|
+
const sensitivityRows = [];
|
|
461
|
+
// Header
|
|
462
|
+
const header = " TG \\ WACC " +
|
|
463
|
+
waccValues.map((w) => `${(w * 100).toFixed(1)}%`.padStart(9)).join("");
|
|
464
|
+
sensitivityRows.push(header);
|
|
465
|
+
sensitivityRows.push(" " + "-".repeat(header.length - 2));
|
|
466
|
+
for (const tg of tgValues) {
|
|
467
|
+
const cells = [];
|
|
468
|
+
for (const w of waccValues) {
|
|
469
|
+
if (w <= tg) {
|
|
470
|
+
cells.push("N/A".padStart(9));
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
const res = runDCF(baseFCF, growthRate, tg, w, projectionYears, netDebt, sharesOutstanding);
|
|
474
|
+
cells.push(fmtPrice(res.fairValue).padStart(9));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
sensitivityRows.push(` ${(tg * 100).toFixed(1)}%`.padEnd(13) + cells.join(""));
|
|
478
|
+
}
|
|
479
|
+
// Build output
|
|
480
|
+
const lines = [
|
|
481
|
+
`=== DCF Valuation: ${name} (${ticker}) ===`,
|
|
482
|
+
`Data Source: SEC EDGAR + Polygon.io | DeepViews Calculation`,
|
|
483
|
+
"",
|
|
484
|
+
"--- Inputs ---",
|
|
485
|
+
line("Base Free Cash Flow", fmtMoney(baseFCF)),
|
|
486
|
+
line("Growth Rate", fmtPct(growthRate)),
|
|
487
|
+
line("Terminal Growth Rate", fmtPct(terminalGrowth)),
|
|
488
|
+
line("WACC (Discount Rate)", fmtPct(wacc)),
|
|
489
|
+
line("Projection Period", `${projectionYears} years`),
|
|
490
|
+
line("Net Debt", fmtMoney(netDebt)),
|
|
491
|
+
line("Shares Outstanding", `${(sharesOutstanding / 1e6).toFixed(1)}M`),
|
|
492
|
+
"",
|
|
493
|
+
"--- Results ---",
|
|
494
|
+
line("Fair Value / Share", fmtPrice(dcf.fairValue)),
|
|
495
|
+
line("Current Price", fmtPrice(currentPrice)),
|
|
496
|
+
line("Margin of Safety", `${mos.toFixed(1)}%`),
|
|
497
|
+
line("Verdict", mos > 25
|
|
498
|
+
? "UNDERVALUED (>25% margin of safety)"
|
|
499
|
+
: mos > 0
|
|
500
|
+
? "SLIGHTLY UNDERVALUED"
|
|
501
|
+
: mos > -15
|
|
502
|
+
? "FAIRLY VALUED"
|
|
503
|
+
: "OVERVALUED"),
|
|
504
|
+
"",
|
|
505
|
+
line("PV of Projected FCFs", fmtMoney(dcf.totalPVofFCFs)),
|
|
506
|
+
line("Terminal Value", fmtMoney(dcf.terminalValue)),
|
|
507
|
+
line("PV of Terminal Value", fmtMoney(dcf.pvTerminal)),
|
|
508
|
+
line("Enterprise Value", fmtMoney(dcf.enterpriseValue)),
|
|
509
|
+
line("Equity Value", fmtMoney(dcf.equityValue)),
|
|
510
|
+
"",
|
|
511
|
+
"--- Reverse DCF ---",
|
|
512
|
+
line("Implied Growth Rate", converged ? fmtPct(impliedGrowth) : "Did not converge"),
|
|
513
|
+
line("Interpretation", converged
|
|
514
|
+
? `Market is pricing in ${(impliedGrowth * 100).toFixed(1)}% annual FCF growth`
|
|
515
|
+
: "Could not determine implied growth"),
|
|
516
|
+
"",
|
|
517
|
+
"--- FCF Projections ---",
|
|
518
|
+
];
|
|
519
|
+
for (const p of dcf.projections) {
|
|
520
|
+
lines.push(` Year ${String(p.year).padStart(2)}: FCF ${fmtMoney(p.fcf).padStart(10)} | PV ${fmtMoney(p.pv).padStart(10)}`);
|
|
521
|
+
}
|
|
522
|
+
lines.push("");
|
|
523
|
+
lines.push("--- Sensitivity Analysis (Fair Value / Share) ---");
|
|
524
|
+
lines.push(...sensitivityRows);
|
|
525
|
+
return lines.join("\n");
|
|
526
|
+
}
|
|
527
|
+
async function handleGetIndustryBenchmarks(ticker) {
|
|
528
|
+
const data = (await callApi(`/api/industry-benchmarks/${encodeURIComponent(ticker)}`));
|
|
529
|
+
const sector = data.sector || "Unknown";
|
|
530
|
+
const peerCount = data.peerCount ?? 0;
|
|
531
|
+
const metrics = data.metrics || {};
|
|
532
|
+
const source = data.dataSource || "unknown";
|
|
533
|
+
const lines = [
|
|
534
|
+
`=== Industry Benchmarks: ${ticker.toUpperCase()} ===`,
|
|
535
|
+
`Sector: ${sector}`,
|
|
536
|
+
`Peer Count: ${peerCount} companies`,
|
|
537
|
+
`Data Source: ${source === "edgar_hybrid" ? "SEC EDGAR + Polygon.io" : source}`,
|
|
538
|
+
"",
|
|
539
|
+
" Metric P25 Median P75",
|
|
540
|
+
" " + "-".repeat(65),
|
|
541
|
+
];
|
|
542
|
+
const metricLabels = {
|
|
543
|
+
peRatio: "P/E Ratio",
|
|
544
|
+
pbRatio: "P/B Ratio",
|
|
545
|
+
psRatio: "P/S Ratio",
|
|
546
|
+
evEbitda: "EV/EBITDA",
|
|
547
|
+
grossMargin: "Gross Margin",
|
|
548
|
+
operatingMargin: "Operating Margin",
|
|
549
|
+
netMargin: "Net Margin",
|
|
550
|
+
roe: "Return on Equity",
|
|
551
|
+
currentRatio: "Current Ratio",
|
|
552
|
+
debtToEquity: "Debt/Equity",
|
|
553
|
+
};
|
|
554
|
+
const isMargin = (key) => ["grossMargin", "operatingMargin", "netMargin", "roe"].includes(key);
|
|
555
|
+
for (const [key, label] of Object.entries(metricLabels)) {
|
|
556
|
+
const m = metrics[key];
|
|
557
|
+
if (!m)
|
|
558
|
+
continue;
|
|
559
|
+
const formatter = isMargin(key) ? fmtPct : (v) => fmt(v);
|
|
560
|
+
lines.push(` ${label.padEnd(28)} ${formatter(m.p25).padStart(9)} ${formatter(m.median).padStart(9)} ${formatter(m.p75).padStart(9)}`);
|
|
561
|
+
}
|
|
562
|
+
return lines.join("\n");
|
|
563
|
+
}
|
|
564
|
+
async function handleGetAnalystRatings(ticker) {
|
|
565
|
+
const data = (await callApi(`/api/analyst-ratings/${encodeURIComponent(ticker)}`));
|
|
566
|
+
const consensus = data.consensus || "N/A";
|
|
567
|
+
const ratings = data.ratings || {};
|
|
568
|
+
const pt = data.priceTarget || {};
|
|
569
|
+
const total = data.totalAnalysts ?? 0;
|
|
570
|
+
const lines = [
|
|
571
|
+
`=== Analyst Ratings: ${ticker.toUpperCase()} ===`,
|
|
572
|
+
`Note: DeepViews Estimate (derived from valuation metrics, not real analyst data)`,
|
|
573
|
+
"",
|
|
574
|
+
line("Consensus", consensus),
|
|
575
|
+
line("Total Analysts (est.)", String(total)),
|
|
576
|
+
"",
|
|
577
|
+
"--- Rating Distribution ---",
|
|
578
|
+
line("Strong Buy", String(ratings.strongBuy ?? 0)),
|
|
579
|
+
line("Buy", String(ratings.buy ?? 0)),
|
|
580
|
+
line("Hold", String(ratings.hold ?? 0)),
|
|
581
|
+
line("Sell", String(ratings.sell ?? 0)),
|
|
582
|
+
line("Strong Sell", String(ratings.strongSell ?? 0)),
|
|
583
|
+
"",
|
|
584
|
+
"--- Price Target ---",
|
|
585
|
+
line("Current Price", fmtPrice(safeNum(pt.current))),
|
|
586
|
+
line("Target Low", fmtPrice(safeNum(pt.low))),
|
|
587
|
+
line("Target Average", fmtPrice(safeNum(pt.average))),
|
|
588
|
+
line("Target High", fmtPrice(safeNum(pt.high))),
|
|
589
|
+
];
|
|
590
|
+
if (pt.current && pt.average) {
|
|
591
|
+
const upside = ((pt.average - pt.current) / pt.current) * 100;
|
|
592
|
+
lines.push(line("Implied Upside", `${upside.toFixed(1)}%`));
|
|
593
|
+
}
|
|
594
|
+
return lines.join("\n");
|
|
595
|
+
}
|
|
596
|
+
async function handleScreenStocks(args) {
|
|
597
|
+
const params = new URLSearchParams();
|
|
598
|
+
params.set("sector", String(args.sector));
|
|
599
|
+
params.set("screen", "true");
|
|
600
|
+
params.set("get_companies", "true");
|
|
601
|
+
// Map tool params to API query params
|
|
602
|
+
const filterMap = {
|
|
603
|
+
industry: "industry",
|
|
604
|
+
pe_min: "pe_min",
|
|
605
|
+
pe_max: "pe_max",
|
|
606
|
+
pb_min: "pb_min",
|
|
607
|
+
pb_max: "pb_max",
|
|
608
|
+
eveb_min: "eveb_min",
|
|
609
|
+
eveb_max: "eveb_max",
|
|
610
|
+
roe_min: "roe_min",
|
|
611
|
+
roe_max: "roe_max",
|
|
612
|
+
de_min: "de_min",
|
|
613
|
+
de_max: "de_max",
|
|
614
|
+
mc_min: "mc_min",
|
|
615
|
+
mc_max: "mc_max",
|
|
616
|
+
rev_min: "rev_min",
|
|
617
|
+
rev_max: "rev_max",
|
|
618
|
+
};
|
|
619
|
+
for (const [toolKey, apiKey] of Object.entries(filterMap)) {
|
|
620
|
+
if (args[toolKey] !== undefined && args[toolKey] !== null) {
|
|
621
|
+
params.set(apiKey, String(args[toolKey]));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const data = (await callApi(`/api/industry?${params.toString()}`));
|
|
625
|
+
const companies = data.companies || [];
|
|
626
|
+
const filteredCount = data.filtered_count ?? companies.length;
|
|
627
|
+
const totalCount = data.total_count ?? filteredCount;
|
|
628
|
+
const metrics = data.metrics || {};
|
|
629
|
+
const lines = [
|
|
630
|
+
`=== Stock Screener Results ===`,
|
|
631
|
+
`Sector: ${args.sector}${args.industry ? ` > ${args.industry}` : ""}`,
|
|
632
|
+
`Matched: ${filteredCount} of ${totalCount} companies`,
|
|
633
|
+
`Data Source: SEC EDGAR + Polygon.io`,
|
|
634
|
+
"",
|
|
635
|
+
];
|
|
636
|
+
// Show active filters
|
|
637
|
+
const activeFilters = [];
|
|
638
|
+
if (args.pe_min !== undefined || args.pe_max !== undefined)
|
|
639
|
+
activeFilters.push(`P/E: ${args.pe_min ?? "*"}-${args.pe_max ?? "*"}`);
|
|
640
|
+
if (args.pb_min !== undefined || args.pb_max !== undefined)
|
|
641
|
+
activeFilters.push(`P/B: ${args.pb_min ?? "*"}-${args.pb_max ?? "*"}`);
|
|
642
|
+
if (args.eveb_min !== undefined || args.eveb_max !== undefined)
|
|
643
|
+
activeFilters.push(`EV/EBITDA: ${args.eveb_min ?? "*"}-${args.eveb_max ?? "*"}`);
|
|
644
|
+
if (args.roe_min !== undefined || args.roe_max !== undefined)
|
|
645
|
+
activeFilters.push(`ROE: ${args.roe_min ?? "*"}-${args.roe_max ?? "*"}`);
|
|
646
|
+
if (args.mc_min !== undefined || args.mc_max !== undefined)
|
|
647
|
+
activeFilters.push(`Market Cap: ${fmtMoney(safeNum(args.mc_min))}-${fmtMoney(safeNum(args.mc_max))}`);
|
|
648
|
+
if (activeFilters.length > 0) {
|
|
649
|
+
lines.push(`Filters: ${activeFilters.join(" | ")}`);
|
|
650
|
+
lines.push("");
|
|
651
|
+
}
|
|
652
|
+
if (companies.length === 0) {
|
|
653
|
+
lines.push("No companies matched your screening criteria.");
|
|
654
|
+
return lines.join("\n");
|
|
655
|
+
}
|
|
656
|
+
// Sector-level stats
|
|
657
|
+
if (metrics.pe_ratio || metrics.return_on_equity) {
|
|
658
|
+
lines.push("--- Sector Statistics ---");
|
|
659
|
+
if (metrics.pe_ratio)
|
|
660
|
+
lines.push(line("P/E (median)", fmt(metrics.pe_ratio.median)));
|
|
661
|
+
if (metrics.ev_to_ebitda)
|
|
662
|
+
lines.push(line("EV/EBITDA (median)", fmt(metrics.ev_to_ebitda.median)));
|
|
663
|
+
if (metrics.return_on_equity)
|
|
664
|
+
lines.push(line("ROE (median)", fmtPct(metrics.return_on_equity.median)));
|
|
665
|
+
lines.push("");
|
|
666
|
+
}
|
|
667
|
+
// Company table (top 25)
|
|
668
|
+
const displayCompanies = companies.slice(0, 25);
|
|
669
|
+
lines.push(`--- Companies (showing ${displayCompanies.length} of ${filteredCount}) ---`);
|
|
670
|
+
lines.push("");
|
|
671
|
+
lines.push(` ${"Ticker".padEnd(8)} ${"Name".padEnd(30)} ${"Mkt Cap".padStart(12)} ${"P/E".padStart(8)} ${"P/B".padStart(8)} ${"ROE".padStart(8)} ${"D/E".padStart(8)}`);
|
|
672
|
+
lines.push(" " + "-".repeat(90));
|
|
673
|
+
for (const co of displayCompanies) {
|
|
674
|
+
const mul = co.multiples || {};
|
|
675
|
+
lines.push(` ${(co.ticker || "").padEnd(8)} ${(co.name || "").substring(0, 30).padEnd(30)} ${fmtMoney(safeNum(co.market_cap)).padStart(12)} ${fmt(safeNum(mul.pe_ratio)).padStart(8)} ${fmt(safeNum(mul.price_to_book)).padStart(8)} ${fmtPct(safeNum(mul.return_on_equity)).padStart(8)} ${fmt(safeNum(mul.debt_to_equity)).padStart(8)}`);
|
|
676
|
+
}
|
|
677
|
+
if (filteredCount > 25) {
|
|
678
|
+
lines.push("");
|
|
679
|
+
lines.push(` ... and ${filteredCount - 25} more companies. Refine your filters to narrow results.`);
|
|
680
|
+
}
|
|
681
|
+
return lines.join("\n");
|
|
682
|
+
}
|
|
683
|
+
async function handleGetNewsSentiment(ticker) {
|
|
684
|
+
const data = (await callApi(`/api/news-sentiment/${encodeURIComponent(ticker)}`));
|
|
685
|
+
const score = data.score ?? 0;
|
|
686
|
+
const normalized = data.normalized ?? "5.0";
|
|
687
|
+
const label = data.label ?? "neutral";
|
|
688
|
+
const pct = data.percentage || { positive: 0, neutral: 100, negative: 0 };
|
|
689
|
+
const trend = data.trend ?? "stable";
|
|
690
|
+
const articleCount = data.articleCount ?? 0;
|
|
691
|
+
const timeframe = data.timeframe ?? "Last 30 days";
|
|
692
|
+
// Sentiment bar visualization
|
|
693
|
+
const barWidth = 40;
|
|
694
|
+
const posBar = Math.round((pct.positive / 100) * barWidth);
|
|
695
|
+
const negBar = Math.round((pct.negative / 100) * barWidth);
|
|
696
|
+
const neuBar = barWidth - posBar - negBar;
|
|
697
|
+
const sentimentBar = "[" +
|
|
698
|
+
"+".repeat(posBar) +
|
|
699
|
+
"=".repeat(Math.max(0, neuBar)) +
|
|
700
|
+
"-".repeat(negBar) +
|
|
701
|
+
"]";
|
|
702
|
+
const lines = [
|
|
703
|
+
`=== News Sentiment: ${ticker.toUpperCase()} ===`,
|
|
704
|
+
`Timeframe: ${timeframe}`,
|
|
705
|
+
`Data Source: Polygon.io News API`,
|
|
706
|
+
"",
|
|
707
|
+
line("Sentiment", `${label.toUpperCase()} (${score}/100)`),
|
|
708
|
+
line("Normalized Score", `${normalized}/10`),
|
|
709
|
+
line("Trend", trend),
|
|
710
|
+
line("Articles Analyzed", String(articleCount)),
|
|
711
|
+
"",
|
|
712
|
+
"--- Sentiment Distribution ---",
|
|
713
|
+
line("Positive", `${pct.positive}%`),
|
|
714
|
+
line("Neutral", `${pct.neutral}%`),
|
|
715
|
+
line("Negative", `${pct.negative}%`),
|
|
716
|
+
"",
|
|
717
|
+
` ${sentimentBar}`,
|
|
718
|
+
` ${"Positive".padEnd(barWidth / 2)}${"Negative".padStart(barWidth / 2)}`,
|
|
719
|
+
];
|
|
720
|
+
if (articleCount === 0) {
|
|
721
|
+
lines.push("");
|
|
722
|
+
lines.push(" No recent news articles found for this ticker.");
|
|
723
|
+
}
|
|
724
|
+
return lines.join("\n");
|
|
725
|
+
}
|
|
726
|
+
async function handleGetComparables(ticker) {
|
|
727
|
+
const data = (await callApi(`/api/comparables/${encodeURIComponent(ticker)}`));
|
|
728
|
+
const target = data.target || {};
|
|
729
|
+
const peers = data.peers || [];
|
|
730
|
+
const stats = data.groupStats || {};
|
|
731
|
+
const sector = stats.sector || "Unknown";
|
|
732
|
+
const peerCount = stats.peerCount ?? peers.length;
|
|
733
|
+
const medians = stats.medians || {};
|
|
734
|
+
const tm = target.metrics || {};
|
|
735
|
+
const lines = [
|
|
736
|
+
`=== Comparable Companies: ${ticker.toUpperCase()} ===`,
|
|
737
|
+
`Sector: ${sector}`,
|
|
738
|
+
`Peer Count: ${peerCount} companies`,
|
|
739
|
+
`Data Source: SEC EDGAR + Polygon.io`,
|
|
740
|
+
"",
|
|
741
|
+
"--- Target ---",
|
|
742
|
+
` ${target.ticker || ticker.toUpperCase()} (${target.name || ticker.toUpperCase()})`,
|
|
743
|
+
` Market Cap: ${fmtMoney(safeNum(target.marketCap))}`,
|
|
744
|
+
` P/E: ${fmt(safeNum(tm.peRatio))} P/B: ${fmt(safeNum(tm.pbRatio))} EV/EBITDA: ${fmt(safeNum(tm.evEbitda))}`,
|
|
745
|
+
` Gross Margin: ${fmtPct(safeNum(tm.grossMargin))} Net Margin: ${fmtPct(safeNum(tm.netMargin))} ROE: ${fmtPct(safeNum(tm.roe))} D/E: ${fmt(safeNum(tm.debtToEquity))}`,
|
|
746
|
+
"",
|
|
747
|
+
];
|
|
748
|
+
if (peers.length > 0) {
|
|
749
|
+
lines.push("--- Peers (by market cap proximity) ---");
|
|
750
|
+
lines.push(` ${"Ticker".padEnd(9)}${"Name".padEnd(31)}${"Mkt Cap".padStart(12)} ${"P/E".padStart(7)} ${"P/B".padStart(7)} ${"EV/EBITDA".padStart(9)} ${"Gross%".padStart(7)} ${"Net%".padStart(7)} ${"ROE%".padStart(7)} ${"D/E".padStart(7)}`);
|
|
751
|
+
lines.push(` ${"-------".padEnd(9)}${"---".padEnd(31)}${"-------".padStart(12)} ${"----".padStart(7)} ${"----".padStart(7)} ${"---------".padStart(9)} ${"------".padStart(7)} ${"------".padStart(7)} ${"------".padStart(7)} ${"-----".padStart(7)}`);
|
|
752
|
+
for (const peer of peers) {
|
|
753
|
+
const pm = peer.metrics || {};
|
|
754
|
+
lines.push(` ${(peer.ticker || "").padEnd(9)}${(peer.name || "").substring(0, 30).padEnd(31)}${fmtMoney(safeNum(peer.marketCap)).padStart(12)} ${fmt(safeNum(pm.peRatio)).padStart(7)} ${fmt(safeNum(pm.pbRatio)).padStart(7)} ${fmt(safeNum(pm.evEbitda)).padStart(9)} ${fmtPct(safeNum(pm.grossMargin)).padStart(7)} ${fmtPct(safeNum(pm.netMargin)).padStart(7)} ${fmtPct(safeNum(pm.roe)).padStart(7)} ${fmt(safeNum(pm.debtToEquity)).padStart(7)}`);
|
|
755
|
+
}
|
|
756
|
+
lines.push("");
|
|
757
|
+
}
|
|
758
|
+
lines.push("--- Group Statistics (Medians) ---");
|
|
759
|
+
lines.push(` P/E: ${fmt(safeNum(medians.peRatio))} P/B: ${fmt(safeNum(medians.pbRatio))} EV/EBITDA: ${fmt(safeNum(medians.evEbitda))}`);
|
|
760
|
+
lines.push(` Gross Margin: ${fmtPct(safeNum(medians.grossMargin))} Net Margin: ${fmtPct(safeNum(medians.netMargin))} ROE: ${fmtPct(safeNum(medians.roe))} D/E: ${fmt(safeNum(medians.debtToEquity))}`);
|
|
761
|
+
return lines.join("\n");
|
|
762
|
+
}
|
|
763
|
+
// ---------------------------------------------------------------------------
|
|
764
|
+
// Tool dispatch
|
|
765
|
+
// ---------------------------------------------------------------------------
|
|
766
|
+
async function handleToolCall(name, args) {
|
|
767
|
+
switch (name) {
|
|
768
|
+
case "analyze_company":
|
|
769
|
+
return handleAnalyzeCompany(String(args.ticker));
|
|
770
|
+
case "calculate_dcf":
|
|
771
|
+
return handleCalculateDcf({
|
|
772
|
+
ticker: String(args.ticker),
|
|
773
|
+
growth_rate: args.growth_rate,
|
|
774
|
+
terminal_growth: args.terminal_growth,
|
|
775
|
+
wacc: args.wacc,
|
|
776
|
+
projection_years: args.projection_years,
|
|
777
|
+
});
|
|
778
|
+
case "get_industry_benchmarks":
|
|
779
|
+
return handleGetIndustryBenchmarks(String(args.ticker));
|
|
780
|
+
case "get_analyst_ratings":
|
|
781
|
+
return handleGetAnalystRatings(String(args.ticker));
|
|
782
|
+
case "screen_stocks":
|
|
783
|
+
return handleScreenStocks(args);
|
|
784
|
+
case "get_news_sentiment":
|
|
785
|
+
return handleGetNewsSentiment(String(args.ticker));
|
|
786
|
+
case "get_comparables":
|
|
787
|
+
return handleGetComparables(String(args.ticker));
|
|
788
|
+
default:
|
|
789
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
// ---------------------------------------------------------------------------
|
|
793
|
+
// Registration
|
|
794
|
+
// ---------------------------------------------------------------------------
|
|
795
|
+
export function registerTools(server) {
|
|
796
|
+
// List available tools
|
|
797
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
798
|
+
tools: TOOL_DEFINITIONS,
|
|
799
|
+
}));
|
|
800
|
+
// Handle tool calls
|
|
801
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
802
|
+
const { name, arguments: args } = request.params;
|
|
803
|
+
try {
|
|
804
|
+
const result = await handleToolCall(name, (args ?? {}));
|
|
805
|
+
return {
|
|
806
|
+
content: [
|
|
807
|
+
{
|
|
808
|
+
type: "text",
|
|
809
|
+
text: result,
|
|
810
|
+
},
|
|
811
|
+
],
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
catch (error) {
|
|
815
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
816
|
+
return {
|
|
817
|
+
content: [
|
|
818
|
+
{
|
|
819
|
+
type: "text",
|
|
820
|
+
text: `Error: ${message}`,
|
|
821
|
+
},
|
|
822
|
+
],
|
|
823
|
+
isError: true,
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,2BAA2B,CAAC;AAC/D,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAEvC,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,KAAK,UAAU,OAAO,CACpB,IAAY,EACZ,OAA6C;IAE7C,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAE3E,IAAI,CAAC;QACH,MAAM,YAAY,GAAgB;YAChC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;YAChC,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,OAAO,EAAE;gBACP,YAAY,EAAE,UAAU;gBACxB,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACjE;SACF,CAAC;QACF,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;YAClB,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,QAAQ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GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC,CAAC;YACnF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,MAAM;qBACb;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,UAAU,OAAO,EAAE;qBAC1B;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepviews-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"mcpName": "io.github.rswcf/deepviews",
|
|
5
|
+
"description": "Free financial data MCP server — company analysis, DCF valuation, comparable companies, industry benchmarks, stock screening, and news sentiment. No API key required. Powered by SEC EDGAR + Polygon.io.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"deepviews-mcp": "dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"dev": "tsx src/index.ts"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"mcp",
|
|
25
|
+
"model-context-protocol",
|
|
26
|
+
"claude",
|
|
27
|
+
"finance",
|
|
28
|
+
"stock",
|
|
29
|
+
"valuation",
|
|
30
|
+
"dcf",
|
|
31
|
+
"sec-edgar",
|
|
32
|
+
"polygon",
|
|
33
|
+
"financial-analysis",
|
|
34
|
+
"comparable-companies",
|
|
35
|
+
"industry-benchmarks"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/Rswcf/v0-valuation-tool.git",
|
|
40
|
+
"directory": "deepviews-plugin"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://www.deepviews.dev",
|
|
43
|
+
"author": "DeepViews <contact@deepviews.dev>",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"typescript": "^5.5.0",
|
|
49
|
+
"tsx": "^4.0.0"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|