@stock2trend/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/README.md +300 -0
- package/dist/index.js +95 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# Stock2Trend MCP Server
|
|
2
|
+
|
|
3
|
+
A small [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that lets an
|
|
4
|
+
AI agent — Claude Desktop, Cursor, VS Code, or any MCP-compatible client — use **your**
|
|
5
|
+
Stock2Trend account. Every request is forwarded to Stock2Trend's `agent-gateway` Edge
|
|
6
|
+
Function using your **personal API key**, so your **Pro/Elite plan and daily limits are
|
|
7
|
+
enforced server-side**.
|
|
8
|
+
|
|
9
|
+
> This process stores **no** Stock2Trend or Supabase secrets. It only reads your API key
|
|
10
|
+
> from an environment variable and runs locally on your machine. The key is never logged.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of contents
|
|
15
|
+
|
|
16
|
+
- [How it works](#how-it-works)
|
|
17
|
+
- [Tools](#tools)
|
|
18
|
+
- [Prerequisites](#prerequisites)
|
|
19
|
+
- [1. Get your API key](#1-get-your-api-key)
|
|
20
|
+
- [2. Install & build](#2-install--build)
|
|
21
|
+
- [3. Configure your MCP client](#3-configure-your-mcp-client)
|
|
22
|
+
- [Environment variables](#environment-variables)
|
|
23
|
+
- [Verify it works (no AI client needed)](#verify-it-works-no-ai-client-needed)
|
|
24
|
+
- [Tool reference](#tool-reference)
|
|
25
|
+
- [How plans & limits work](#how-plans--limits-work)
|
|
26
|
+
- [Security best practices](#security-best-practices)
|
|
27
|
+
- [Troubleshooting](#troubleshooting)
|
|
28
|
+
- [Updating & rotating keys](#updating--rotating-keys)
|
|
29
|
+
- [FAQ](#faq)
|
|
30
|
+
- [Advanced: self-hosting the gateway](#advanced-self-hosting-the-gateway)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## How it works
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart LR
|
|
38
|
+
A[AI agent / MCP client] -->|stdio| B[Stock2Trend MCP server<br/>this package]
|
|
39
|
+
B -->|HTTPS + Bearer API key| C[agent-gateway<br/>Supabase Edge Function]
|
|
40
|
+
C --> D{API key valid?<br/>Pro/Elite?<br/>within daily limit?}
|
|
41
|
+
D -->|yes| E[Hot Stocks / Symbols / Options data]
|
|
42
|
+
D -->|no| F[401 / 403 / 429 error]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The MCP server is a thin bridge. **All security decisions happen in the gateway**, not here:
|
|
46
|
+
key validation, plan gating (Pro/Elite only), per-action scopes, and quota consumption.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Tools
|
|
51
|
+
|
|
52
|
+
| Tool | What it does | Consumes quota? |
|
|
53
|
+
|------|--------------|-----------------|
|
|
54
|
+
| `get_hot_stocks` | Latest "Hot Stocks to Watch" (unusual options activity), optionally by price range | No — cached read |
|
|
55
|
+
| `search_symbols` | Find US tickers by company name or keyword | No — read |
|
|
56
|
+
| `analyze_options` | Single-stock options analysis (call/put flow, premium flow, IV, max pain, signals) | **Yes — 1 stock-analysis unit** from your daily plan limit |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Prerequisites
|
|
61
|
+
|
|
62
|
+
- **Node.js 18 or newer** (`node --version` to check)
|
|
63
|
+
- A Stock2Trend **Pro** or **Elite** account (Basic/Free cannot create API keys)
|
|
64
|
+
- A personal **API key** (next section)
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 1. Get your API key
|
|
69
|
+
|
|
70
|
+
1. Sign in to Stock2Trend on the **web** (key management is web-only).
|
|
71
|
+
2. Go to **Settings → Developer**.
|
|
72
|
+
3. Click **Create key**, give it a name (e.g. `Claude desktop`), and **copy the key shown** —
|
|
73
|
+
it looks like `s2t_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`.
|
|
74
|
+
|
|
75
|
+
> ⚠️ The full key is shown **only once**. Store it in a password manager. If you lose it,
|
|
76
|
+
> just **rotate** or **create** a new one from the same screen.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 2. Install & build
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cd packages/mcp-server
|
|
84
|
+
npm install # installs @modelcontextprotocol/sdk + zod
|
|
85
|
+
npm run build # compiles src/ -> dist/index.js
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
After building, the runnable entry point is `dist/index.js`. Note its **absolute path** —
|
|
89
|
+
you'll need it for your client config.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 3. Configure your MCP client
|
|
94
|
+
|
|
95
|
+
In every client you provide two things: the **command** to run this server and your
|
|
96
|
+
**API key** as an environment variable.
|
|
97
|
+
|
|
98
|
+
### Claude Desktop
|
|
99
|
+
|
|
100
|
+
Edit `claude_desktop_config.json`
|
|
101
|
+
(macOS: `~/Library/Application Support/Claude/`, Windows: `%APPDATA%\Claude\`):
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"stock2trend": {
|
|
107
|
+
"command": "node",
|
|
108
|
+
"args": ["/absolute/path/to/packages/mcp-server/dist/index.js"],
|
|
109
|
+
"env": {
|
|
110
|
+
"STOCK2TREND_API_KEY": "s2t_live_your_key_here"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Restart Claude Desktop. You should see the `stock2trend` tools appear.
|
|
118
|
+
|
|
119
|
+
### Cursor
|
|
120
|
+
|
|
121
|
+
Add to `~/.cursor/mcp.json` (or the project's `.cursor/mcp.json`) using the **same shape**
|
|
122
|
+
as above (`command`, `args`, `env`).
|
|
123
|
+
|
|
124
|
+
### VS Code (MCP-enabled extensions)
|
|
125
|
+
|
|
126
|
+
Add to your MCP config (`.vscode/mcp.json` or the extension's settings):
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"servers": {
|
|
131
|
+
"stock2trend": {
|
|
132
|
+
"command": "node",
|
|
133
|
+
"args": ["/absolute/path/to/packages/mcp-server/dist/index.js"],
|
|
134
|
+
"env": { "STOCK2TREND_API_KEY": "s2t_live_your_key_here" }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
> **Windows paths in JSON:** use forward slashes (`C:/Users/you/.../dist/index.js`) or
|
|
141
|
+
> escaped backslashes (`C:\\Users\\you\\...\\dist\\index.js`). A single backslash is invalid JSON.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Environment variables
|
|
146
|
+
|
|
147
|
+
| Variable | Required | Default | Description |
|
|
148
|
+
|----------|----------|---------|-------------|
|
|
149
|
+
| `STOCK2TREND_API_KEY` | **Yes** | — | Your personal key (`s2t_live_…`). The server exits immediately if missing. |
|
|
150
|
+
| `STOCK2TREND_API_URL` | No | Production `agent-gateway` URL | Override only for staging/self-hosted gateways. |
|
|
151
|
+
|
|
152
|
+
You can also create a `.env` from [`.env.example`](.env.example) for local runs, but most
|
|
153
|
+
users set these in the **MCP client config** (`env` block) instead.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Verify it works (no AI client needed)
|
|
158
|
+
|
|
159
|
+
Sanity-check your key and the gateway directly, before wiring up any AI client.
|
|
160
|
+
|
|
161
|
+
**PowerShell:**
|
|
162
|
+
```powershell
|
|
163
|
+
$key = 's2t_live_your_key_here'
|
|
164
|
+
$uri = 'https://fhtslnidlypkdclqjjme.supabase.co/functions/v1/agent-gateway'
|
|
165
|
+
Invoke-RestMethod -Method Post -Uri $uri `
|
|
166
|
+
-Headers @{ Authorization = "Bearer $key" } `
|
|
167
|
+
-ContentType 'application/json' -Body '{"action":"capabilities"}'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**curl:**
|
|
171
|
+
```bash
|
|
172
|
+
curl -s -X POST https://fhtslnidlypkdclqjjme.supabase.co/functions/v1/agent-gateway \
|
|
173
|
+
-H "Authorization: Bearer s2t_live_your_key_here" \
|
|
174
|
+
-H "Content-Type: application/json" \
|
|
175
|
+
-d '{"action":"capabilities"}'
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
A healthy response looks like:
|
|
179
|
+
```json
|
|
180
|
+
{ "success": true, "plan": "pro", "scopes": ["hot_stocks:read","symbols:read","options:read"], "tools": [ ... ] }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
If you get `success: false` or a non-200 status, jump to [Troubleshooting](#troubleshooting).
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Tool reference
|
|
188
|
+
|
|
189
|
+
### `get_hot_stocks`
|
|
190
|
+
| Param | Type | Required | Notes |
|
|
191
|
+
|-------|------|----------|-------|
|
|
192
|
+
| `priceRange` | `"under10" \| "10to50" \| "over50"` | No | Omit to get all three ranges |
|
|
193
|
+
| `limit` | number (1–50) | No | Max stocks per range (default 10) |
|
|
194
|
+
|
|
195
|
+
Returns sanitized top stocks per range: `ticker`, `companyName`, `currentPrice`,
|
|
196
|
+
`priceChangePct1d`, `sector`, `shareVolume`, `optionsVolume`, `heatLabel`, `totalScore`,
|
|
197
|
+
reasons, plus `scanTimestamp`.
|
|
198
|
+
|
|
199
|
+
### `search_symbols`
|
|
200
|
+
| Param | Type | Required |
|
|
201
|
+
|-------|------|----------|
|
|
202
|
+
| `query` | string | Yes |
|
|
203
|
+
|
|
204
|
+
Returns up to 15 matches: `symbol`, `name`, `type`, `region`, `currency`.
|
|
205
|
+
|
|
206
|
+
### `analyze_options` *(consumes 1 stock-analysis unit)*
|
|
207
|
+
| Param | Type | Required |
|
|
208
|
+
|-------|------|----------|
|
|
209
|
+
| `ticker` | string (e.g. `AAPL`) | Yes |
|
|
210
|
+
|
|
211
|
+
Returns analysis (price, call/put flow, premium flow, implied volatility, max pain,
|
|
212
|
+
signals) **and** a `quota` object showing `used` / `limit` for the day.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## How plans & limits work
|
|
217
|
+
|
|
218
|
+
- **Pro/Elite only.** Free/Basic keys are rejected with `403`.
|
|
219
|
+
- **Shared daily budget.** The agent draws from the *same* daily limits as the Stock2Trend
|
|
220
|
+
app. If you've used analyses in the app, the agent has fewer left, and vice-versa.
|
|
221
|
+
- **Reads are cheap.** `get_hot_stocks` and `search_symbols` don't consume your analysis
|
|
222
|
+
quota; only `analyze_options` does (1 unit each).
|
|
223
|
+
- **Resets daily** at **00:00 UTC**. Elite plans are effectively unlimited.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Security best practices
|
|
228
|
+
|
|
229
|
+
- Treat the API key like a password. **Never commit it** to git or paste it in chats.
|
|
230
|
+
- If a key leaks, **revoke** it instantly in **Settings → Developer** — the agent stops working immediately.
|
|
231
|
+
- **Rotate** keys periodically (rotation revokes the old key and issues a new one).
|
|
232
|
+
- This server exposes **only** the three read/analysis tools above. It cannot change your
|
|
233
|
+
account, billing, watchlist, or any data — by design.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Troubleshooting
|
|
238
|
+
|
|
239
|
+
| Symptom | Likely cause | Fix |
|
|
240
|
+
|---------|--------------|-----|
|
|
241
|
+
| Server exits with `FATAL: STOCK2TREND_API_KEY ... required` | Key env var not set | Add `STOCK2TREND_API_KEY` to the client `env` block (or `.env`) |
|
|
242
|
+
| `401 Invalid, expired, or revoked API key` | Wrong/old key, or it was revoked/rotated | Create a fresh key in **Settings → Developer** and update your config |
|
|
243
|
+
| `403 API access requires an active Pro or Elite plan` | Account isn't Pro/Elite (or downgraded/lapsed) | Upgrade/renew, then the same key works |
|
|
244
|
+
| `429 Daily limit reached for stock analyses` | You've hit your plan's daily `analyze_options` limit (shared with the app) | Wait for the 00:00 UTC reset, or upgrade to Elite |
|
|
245
|
+
| `401 { "code": "UNAUTHORIZED_INVALID_JWT_FORMAT", "message": "Invalid JWT" }` | Only when **self-hosting**: the gateway was deployed with JWT verification ON | Redeploy `agent-gateway` with `--no-verify-jwt` (see below) |
|
|
246
|
+
| Tools don't appear in Claude/Cursor | Wrong path, missing build, or client not restarted | Confirm `dist/index.js` exists (run `npm run build`), use an **absolute** path, restart the client |
|
|
247
|
+
| `Error: Cannot find module '@modelcontextprotocol/sdk'` | Dependencies not installed | Run `npm install` in `packages/mcp-server` |
|
|
248
|
+
| `SyntaxError` / unexpected token at startup | Node too old | Use **Node 18+** (`node --version`) |
|
|
249
|
+
| `Network error contacting Stock2Trend` | No internet, or wrong `STOCK2TREND_API_URL` | Check connectivity; unset `STOCK2TREND_API_URL` to use the default |
|
|
250
|
+
| Client shows the server "running" but no output | Normal | The server logs to **stderr**; `stdout` is reserved for the MCP protocol stream |
|
|
251
|
+
| Windows: config fails to load | Single backslashes in JSON path | Use `/` or `\\` in the `args` path |
|
|
252
|
+
|
|
253
|
+
**Where to see logs:** this server writes diagnostics to **stderr** (your MCP client's
|
|
254
|
+
log panel), never to stdout. To debug in a terminal:
|
|
255
|
+
`STOCK2TREND_API_KEY=... node dist/index.js` and watch stderr.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Updating & rotating keys
|
|
260
|
+
|
|
261
|
+
- **Rotate** (recommended periodically): Settings → Developer → **Rotate**. This issues a
|
|
262
|
+
new key and revokes the old one. Update `STOCK2TREND_API_KEY` in your client config.
|
|
263
|
+
- **Update the server**: `git pull`, then `npm install && npm run build` again.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## FAQ
|
|
268
|
+
|
|
269
|
+
**Does the agent see my password or account?** No. It only ever has the API key, which
|
|
270
|
+
grants the three read/analysis tools — nothing else.
|
|
271
|
+
|
|
272
|
+
**Can I run multiple agents?** Yes. Issue a separate key per agent (up to 5 active) so you
|
|
273
|
+
can revoke one without affecting the others.
|
|
274
|
+
|
|
275
|
+
**Is my data shared with the AI provider?** Only the tool results you request are returned
|
|
276
|
+
to your AI client. The MCP server itself sends nothing extra and logs no key.
|
|
277
|
+
|
|
278
|
+
**Why is `analyze_options` sometimes slow?** It runs a live options analysis upstream; a
|
|
279
|
+
few seconds is normal.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Advanced: self-hosting the gateway
|
|
284
|
+
|
|
285
|
+
If you point `STOCK2TREND_API_URL` at your **own** deployment of `agent-gateway`, that
|
|
286
|
+
function must be deployed with JWT verification **disabled**, because it authenticates with
|
|
287
|
+
the API key (not a Supabase JWT):
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
npx supabase functions deploy agent-gateway --project-ref <your-ref> --no-verify-jwt
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Forgetting `--no-verify-jwt` produces the `Invalid JWT` 401 listed in Troubleshooting.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Support
|
|
298
|
+
|
|
299
|
+
Found a bug or have a feature request? Contact Stock2Trend support, or revoke your key and
|
|
300
|
+
open an issue. Never include your API key in a bug report.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Stock2Trend MCP server
|
|
4
|
+
* ----------------------
|
|
5
|
+
* A thin, user-run Model Context Protocol server that exposes a few Stock2Trend
|
|
6
|
+
* capabilities to an AI agent. It forwards every request to the Stock2Trend
|
|
7
|
+
* `agent-gateway` Edge Function using the user's personal API key, so all plan
|
|
8
|
+
* gating and daily limits are enforced server-side by Stock2Trend.
|
|
9
|
+
*
|
|
10
|
+
* This process holds NO Supabase secrets — only the user's API key, read from
|
|
11
|
+
* the STOCK2TREND_API_KEY environment variable. The key is never logged.
|
|
12
|
+
*
|
|
13
|
+
* Environment:
|
|
14
|
+
* STOCK2TREND_API_KEY (required) e.g. s2t_live_...
|
|
15
|
+
* STOCK2TREND_API_URL (optional) full URL of the agent-gateway function.
|
|
16
|
+
* Default: https://<project>.supabase.co/functions/v1/agent-gateway
|
|
17
|
+
*/
|
|
18
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
19
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
const API_KEY = process.env.STOCK2TREND_API_KEY;
|
|
22
|
+
const API_URL = process.env.STOCK2TREND_API_URL ||
|
|
23
|
+
'https://fhtslnidlypkdclqjjme.supabase.co/functions/v1/agent-gateway';
|
|
24
|
+
if (!API_KEY) {
|
|
25
|
+
// Write to stderr (stdout is reserved for the MCP protocol stream).
|
|
26
|
+
console.error('FATAL: STOCK2TREND_API_KEY environment variable is required.');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
async function callGateway(action, params = {}) {
|
|
30
|
+
let resp;
|
|
31
|
+
try {
|
|
32
|
+
resp = await fetch(API_URL, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({ action, ...params }),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return { success: false, error: `Network error contacting Stock2Trend: ${err.message}` };
|
|
43
|
+
}
|
|
44
|
+
const json = (await resp.json().catch(() => ({})));
|
|
45
|
+
if (!resp.ok && json.success === undefined) {
|
|
46
|
+
return { success: false, error: `Stock2Trend returned HTTP ${resp.status}` };
|
|
47
|
+
}
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
function textResult(payload) {
|
|
51
|
+
return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
|
|
52
|
+
}
|
|
53
|
+
function errorResult(message) {
|
|
54
|
+
return { content: [{ type: 'text', text: message }], isError: true };
|
|
55
|
+
}
|
|
56
|
+
const server = new McpServer({
|
|
57
|
+
name: 'stock2trend',
|
|
58
|
+
version: '0.1.0',
|
|
59
|
+
});
|
|
60
|
+
server.tool('get_hot_stocks', 'Get Stock2Trend\'s latest "Hot Stocks to Watch" (unusual options activity). Optionally filter by price range. Read-only; does not consume your daily analysis quota.', {
|
|
61
|
+
priceRange: z.enum(['under10', '10to50', 'over50']).optional().describe('Optional price band filter'),
|
|
62
|
+
limit: z.number().int().min(1).max(50).optional().describe('Max stocks per range (default 10)'),
|
|
63
|
+
}, async ({ priceRange, limit }) => {
|
|
64
|
+
const res = await callGateway('hot_stocks.snapshot', { priceRange, limit });
|
|
65
|
+
if (!res.success)
|
|
66
|
+
return errorResult(res.error || 'Failed to fetch hot stocks');
|
|
67
|
+
return textResult(res.data);
|
|
68
|
+
});
|
|
69
|
+
server.tool('search_symbols', 'Search for US stock ticker symbols by company name or keyword. Read-only; does not consume your daily analysis quota.', {
|
|
70
|
+
query: z.string().min(1).describe('Company name or partial ticker, e.g. "apple" or "NVDA"'),
|
|
71
|
+
}, async ({ query }) => {
|
|
72
|
+
const res = await callGateway('symbols.search', { query });
|
|
73
|
+
if (!res.success)
|
|
74
|
+
return errorResult(res.error || 'Symbol search failed');
|
|
75
|
+
return textResult(res.data);
|
|
76
|
+
});
|
|
77
|
+
server.tool('analyze_options', 'Run Stock2Trend\'s single-stock options analysis for a ticker (call/put flow, premium flow, implied volatility, max pain, signals). Consumes one stock-analysis unit from your daily plan limit.', {
|
|
78
|
+
ticker: z.string().min(1).max(12).describe('US stock ticker, e.g. "AAPL"'),
|
|
79
|
+
}, async ({ ticker }) => {
|
|
80
|
+
const res = await callGateway('options.analyze', { ticker });
|
|
81
|
+
if (!res.success) {
|
|
82
|
+
const quotaNote = res.quota ? ` (quota: ${JSON.stringify(res.quota)})` : '';
|
|
83
|
+
return errorResult((res.error || 'Analysis failed') + quotaNote);
|
|
84
|
+
}
|
|
85
|
+
return textResult({ analysis: res.data, quota: res.quota });
|
|
86
|
+
});
|
|
87
|
+
async function main() {
|
|
88
|
+
const transport = new StdioServerTransport();
|
|
89
|
+
await server.connect(transport);
|
|
90
|
+
console.error('Stock2Trend MCP server running (stdio).');
|
|
91
|
+
}
|
|
92
|
+
main().catch((err) => {
|
|
93
|
+
console.error('Fatal error starting Stock2Trend MCP server:', err);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stock2trend/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Model Context Protocol (MCP) server that lets an AI agent use a Stock2Trend account (Hot Stocks, symbol search, options analysis) with the user's own plan limits.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"stock2trend-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"dev": "tsc -p tsconfig.json --watch"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
25
|
+
"zod": "^3.23.8"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.5.0"
|
|
29
|
+
}
|
|
30
|
+
}
|