mcp-financex 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/README.md +819 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/index.d.ts +21 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +36 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/market-summary.d.ts +30 -0
- package/dist/resources/market-summary.d.ts.map +1 -0
- package/dist/resources/market-summary.js +44 -0
- package/dist/resources/market-summary.js.map +1 -0
- package/dist/resources/watchlist.d.ts +34 -0
- package/dist/resources/watchlist.d.ts.map +1 -0
- package/dist/resources/watchlist.js +71 -0
- package/dist/resources/watchlist.js.map +1 -0
- package/dist/server.d.ts +32 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +142 -0
- package/dist/server.js.map +1 -0
- package/dist/services/cache.d.ts +105 -0
- package/dist/services/cache.d.ts.map +1 -0
- package/dist/services/cache.js +208 -0
- package/dist/services/cache.js.map +1 -0
- package/dist/services/greeks.d.ts +40 -0
- package/dist/services/greeks.d.ts.map +1 -0
- package/dist/services/greeks.js +181 -0
- package/dist/services/greeks.js.map +1 -0
- package/dist/services/indicators.d.ts +62 -0
- package/dist/services/indicators.d.ts.map +1 -0
- package/dist/services/indicators.js +325 -0
- package/dist/services/indicators.js.map +1 -0
- package/dist/services/options.d.ts +46 -0
- package/dist/services/options.d.ts.map +1 -0
- package/dist/services/options.js +367 -0
- package/dist/services/options.js.map +1 -0
- package/dist/services/strategy.d.ts +35 -0
- package/dist/services/strategy.d.ts.map +1 -0
- package/dist/services/strategy.js +233 -0
- package/dist/services/strategy.js.map +1 -0
- package/dist/services/yahoo-finance.d.ts +54 -0
- package/dist/services/yahoo-finance.d.ts.map +1 -0
- package/dist/services/yahoo-finance.js +276 -0
- package/dist/services/yahoo-finance.js.map +1 -0
- package/dist/tools/historical.d.ts +43 -0
- package/dist/tools/historical.d.ts.map +1 -0
- package/dist/tools/historical.js +60 -0
- package/dist/tools/historical.js.map +1 -0
- package/dist/tools/index.d.ts +60 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/indicators.d.ts +312 -0
- package/dist/tools/indicators.d.ts.map +1 -0
- package/dist/tools/indicators.js +71 -0
- package/dist/tools/indicators.js.map +1 -0
- package/dist/tools/news.d.ts +35 -0
- package/dist/tools/news.d.ts.map +1 -0
- package/dist/tools/news.js +47 -0
- package/dist/tools/news.js.map +1 -0
- package/dist/tools/options.d.ts +327 -0
- package/dist/tools/options.d.ts.map +1 -0
- package/dist/tools/options.js +494 -0
- package/dist/tools/options.js.map +1 -0
- package/dist/tools/quote.d.ts +56 -0
- package/dist/tools/quote.d.ts.map +1 -0
- package/dist/tools/quote.js +83 -0
- package/dist/tools/quote.js.map +1 -0
- package/dist/tools/search.d.ts +35 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +47 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types/indicators.d.ts +144 -0
- package/dist/types/indicators.d.ts.map +1 -0
- package/dist/types/indicators.js +5 -0
- package/dist/types/indicators.js.map +1 -0
- package/dist/types/market-data.d.ts +112 -0
- package/dist/types/market-data.d.ts.map +1 -0
- package/dist/types/market-data.js +5 -0
- package/dist/types/market-data.js.map +1 -0
- package/dist/types/options.d.ts +215 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +5 -0
- package/dist/types/options.js.map +1 -0
- package/dist/utils/error-handler.d.ts +49 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +183 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/validators.d.ts +126 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +152 -0
- package/dist/utils/validators.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
# MCP FinanceX
|
|
2
|
+
|
|
3
|
+
[](https://github.com/xerktech/mcp-financex/actions/workflows/pr-checks.yml)
|
|
4
|
+
[](https://github.com/xerktech/mcp-financex/actions/workflows/publish.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/mcp-financex)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
A comprehensive Model Context Protocol (MCP) server for real-time stock, cryptocurrency, and **options trading** analysis using Yahoo Finance data. Provides tools for price quotes, historical data, technical indicators, market news, options chains, Greeks calculation, and advanced options strategy analysis.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
### Stock & Crypto Analysis
|
|
13
|
+
- **Real-time Price Quotes**: Get current prices, changes, volume, and market data for stocks and cryptocurrencies
|
|
14
|
+
- **Historical Data**: Retrieve OHLCV (Open, High, Low, Close, Volume) data with multiple time intervals
|
|
15
|
+
- **Technical Indicators**: Calculate RSI, MACD, SMA, EMA, Bollinger Bands, and Stochastic oscillators
|
|
16
|
+
- **Market News**: Fetch recent news articles for specific symbols or general market news
|
|
17
|
+
- **Symbol Search**: Find ticker symbols by company name or keyword
|
|
18
|
+
- **Batch Operations**: Fetch multiple quotes efficiently in a single request
|
|
19
|
+
- **Market Overview**: Access major market indices and trending stocks
|
|
20
|
+
- **Watchlist Management**: Track favorite symbols with notes and alerts
|
|
21
|
+
|
|
22
|
+
### Options Trading (NEW!)
|
|
23
|
+
- **Options Chains**: Complete options data with strikes, premiums, volume, open interest, and IV
|
|
24
|
+
- **Greeks Calculator**: Delta, Gamma, Theta, Vega, Rho using Black-Scholes model
|
|
25
|
+
- **Earnings Calendar**: Critical dates for volatility planning
|
|
26
|
+
- **Dividend Information**: Ex-dividend dates affecting options pricing
|
|
27
|
+
- **Historical Volatility**: Compare realized volatility with implied volatility
|
|
28
|
+
- **Implied Volatility Analysis**: IV rank, percentile, and term structure
|
|
29
|
+
- **Max Pain Calculator**: Find the pin price where most options expire worthless
|
|
30
|
+
- **Strategy Analyzer**: Analyze complex spreads, condors, butterflies with P&L charts
|
|
31
|
+
|
|
32
|
+
### Technical Features
|
|
33
|
+
- **Smart Caching**: Intelligent caching with market hours awareness to minimize API calls
|
|
34
|
+
- **Black-Scholes Pricing**: Accurate Greeks and theoretical option prices
|
|
35
|
+
- **No API Keys Required**: Free Yahoo Finance data (respects rate limits)
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Prerequisites
|
|
40
|
+
|
|
41
|
+
- Node.js (v18 or later)
|
|
42
|
+
- npm or yarn
|
|
43
|
+
|
|
44
|
+
### Setup
|
|
45
|
+
|
|
46
|
+
1. Clone the repository:
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/xerktech/mcp-financex.git
|
|
49
|
+
cd mcp-financex
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Install dependencies:
|
|
53
|
+
```bash
|
|
54
|
+
npm install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
3. Build the project:
|
|
58
|
+
```bash
|
|
59
|
+
npm run build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
4. (Optional) Create a `.env` file for custom configuration:
|
|
63
|
+
```bash
|
|
64
|
+
cp .env.example .env
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Running the Server
|
|
70
|
+
|
|
71
|
+
Development mode (with auto-reload):
|
|
72
|
+
```bash
|
|
73
|
+
npm run dev
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Production mode:
|
|
77
|
+
```bash
|
|
78
|
+
npm start
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Configuration with Claude Desktop
|
|
82
|
+
|
|
83
|
+
Add the server to your Claude Desktop configuration file:
|
|
84
|
+
|
|
85
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
86
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
87
|
+
|
|
88
|
+
#### Option 1: Use npx (Recommended - No Installation Required)
|
|
89
|
+
|
|
90
|
+
Once published to npm, users can run it directly without installation:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"finance": {
|
|
96
|
+
"command": "npx",
|
|
97
|
+
"args": ["-y", "mcp-financex"]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Option 2: Use from GitHub (Before npm publish)
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"mcpServers": {
|
|
108
|
+
"finance": {
|
|
109
|
+
"command": "npx",
|
|
110
|
+
"args": ["-y", "github:xerktech/mcp-financex"]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Option 3: Local Installation
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"mcpServers": {
|
|
121
|
+
"finance": {
|
|
122
|
+
"command": "node",
|
|
123
|
+
"args": ["/path/to/mcp-financex/dist/index.js"]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Available Tools
|
|
130
|
+
|
|
131
|
+
### 1. get_quote
|
|
132
|
+
|
|
133
|
+
Get real-time price quote for a stock or cryptocurrency.
|
|
134
|
+
|
|
135
|
+
**Input:**
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"symbol": "AAPL",
|
|
139
|
+
"fields": ["regularMarketPrice", "marketCap"] // Optional
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Example:**
|
|
144
|
+
```
|
|
145
|
+
Get the current price of Apple stock (AAPL)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Output:**
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"symbol": "AAPL",
|
|
152
|
+
"regularMarketPrice": 178.50,
|
|
153
|
+
"regularMarketChange": 2.35,
|
|
154
|
+
"regularMarketChangePercent": 1.33,
|
|
155
|
+
"regularMarketVolume": 52438900,
|
|
156
|
+
"marketCap": 2800000000000,
|
|
157
|
+
"currency": "USD",
|
|
158
|
+
"exchangeName": "NASDAQ",
|
|
159
|
+
"quoteType": "EQUITY"
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 2. get_quote_batch
|
|
164
|
+
|
|
165
|
+
Get quotes for multiple symbols efficiently.
|
|
166
|
+
|
|
167
|
+
**Input:**
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"symbols": ["AAPL", "MSFT", "BTC-USD", "GOOGL"]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Example:**
|
|
175
|
+
```
|
|
176
|
+
Get current prices for Apple, Microsoft, Bitcoin, and Google
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 3. get_historical_data
|
|
180
|
+
|
|
181
|
+
Retrieve historical OHLCV data.
|
|
182
|
+
|
|
183
|
+
**Input:**
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"symbol": "BTC-USD",
|
|
187
|
+
"period1": "1mo",
|
|
188
|
+
"interval": "1d"
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Example:**
|
|
193
|
+
```
|
|
194
|
+
Get the last month of daily price data for Bitcoin
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Supported Intervals:**
|
|
198
|
+
- `1m`, `5m`, `15m`, `30m` - Intraday (limited history)
|
|
199
|
+
- `1h` - Hourly
|
|
200
|
+
- `1d` - Daily
|
|
201
|
+
- `1wk` - Weekly
|
|
202
|
+
- `1mo` - Monthly
|
|
203
|
+
|
|
204
|
+
### 4. calculate_indicator
|
|
205
|
+
|
|
206
|
+
Calculate technical indicators on price data.
|
|
207
|
+
|
|
208
|
+
**Input:**
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"symbol": "AAPL",
|
|
212
|
+
"indicator": "rsi",
|
|
213
|
+
"period": 14,
|
|
214
|
+
"interval": "1d"
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Example:**
|
|
219
|
+
```
|
|
220
|
+
Calculate the RSI for Apple stock over the last 14 days
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Supported Indicators:**
|
|
224
|
+
|
|
225
|
+
- **RSI** (Relative Strength Index): Momentum oscillator, identifies overbought/oversold conditions
|
|
226
|
+
- **MACD** (Moving Average Convergence Divergence): Trend following indicator
|
|
227
|
+
- **SMA** (Simple Moving Average): Average price over period
|
|
228
|
+
- **EMA** (Exponential Moving Average): Weighted average giving more importance to recent prices
|
|
229
|
+
- **Bollinger Bands**: Volatility indicator with upper/lower bands
|
|
230
|
+
- **Stochastic**: Momentum indicator comparing closing price to price range
|
|
231
|
+
|
|
232
|
+
### 5. search_ticker
|
|
233
|
+
|
|
234
|
+
Search for ticker symbols by company name or keyword.
|
|
235
|
+
|
|
236
|
+
**Input:**
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"query": "Tesla",
|
|
240
|
+
"limit": 10
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Example:**
|
|
245
|
+
```
|
|
246
|
+
Search for Tesla's ticker symbol
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### 6. get_market_news
|
|
250
|
+
|
|
251
|
+
Retrieve recent news articles.
|
|
252
|
+
|
|
253
|
+
**Input:**
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"symbol": "AAPL",
|
|
257
|
+
"limit": 10
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Example:**
|
|
262
|
+
```
|
|
263
|
+
Get the latest news about Apple
|
|
264
|
+
Get general market news (omit symbol)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Options Trading Tools
|
|
268
|
+
|
|
269
|
+
### 7. get_options_chain
|
|
270
|
+
|
|
271
|
+
Get complete options chain data with all available strikes, calls, and puts.
|
|
272
|
+
|
|
273
|
+
**Input:**
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"symbol": "AAPL",
|
|
277
|
+
"expirationDate": "2024-06-21" // Optional
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Example:**
|
|
282
|
+
```
|
|
283
|
+
Show me the options chain for Apple
|
|
284
|
+
Get options for TSLA expiring June 21, 2024
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**Output:** Calls and puts with strikes, premiums, volume, open interest, implied volatility, bid/ask spreads.
|
|
288
|
+
|
|
289
|
+
### 8. calculate_greeks
|
|
290
|
+
|
|
291
|
+
Calculate option Greeks (Delta, Gamma, Theta, Vega, Rho) using Black-Scholes model.
|
|
292
|
+
|
|
293
|
+
**Input:**
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"symbol": "AAPL",
|
|
297
|
+
"strike": 180,
|
|
298
|
+
"expirationDate": "2024-06-21",
|
|
299
|
+
"optionType": "call"
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Example:**
|
|
304
|
+
```
|
|
305
|
+
Calculate Greeks for AAPL $180 call expiring June 21
|
|
306
|
+
What are the Greeks for a TSLA $250 put?
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Greeks Explained:**
|
|
310
|
+
- **Delta (0-1 for calls, -1-0 for puts)**: Price sensitivity - how much the option price changes per $1 move in stock
|
|
311
|
+
- **Gamma**: Rate of delta change - how quickly delta changes as stock moves
|
|
312
|
+
- **Theta**: Time decay - how much value the option loses per day
|
|
313
|
+
- **Vega**: Volatility sensitivity - impact of 1% change in implied volatility
|
|
314
|
+
- **Rho**: Interest rate sensitivity - impact of 1% change in rates
|
|
315
|
+
|
|
316
|
+
### 9. get_earnings_calendar
|
|
317
|
+
|
|
318
|
+
Get upcoming earnings dates and historical earnings data.
|
|
319
|
+
|
|
320
|
+
**Input:**
|
|
321
|
+
```json
|
|
322
|
+
{
|
|
323
|
+
"symbol": "AAPL",
|
|
324
|
+
"daysAhead": 30 // Optional
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Example:**
|
|
329
|
+
```
|
|
330
|
+
When is Apple's next earnings date?
|
|
331
|
+
Show me upcoming earnings for TSLA
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Why it matters:** Earnings announcements cause volatility spikes, significantly impacting options prices. Options traders often avoid holding positions through earnings or specifically trade earnings volatility.
|
|
335
|
+
|
|
336
|
+
### 10. get_dividend_info
|
|
337
|
+
|
|
338
|
+
Get comprehensive dividend information including ex-dividend dates.
|
|
339
|
+
|
|
340
|
+
**Input:**
|
|
341
|
+
```json
|
|
342
|
+
{
|
|
343
|
+
"symbol": "AAPL"
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Example:**
|
|
348
|
+
```
|
|
349
|
+
What's Apple's dividend yield and ex-dividend date?
|
|
350
|
+
Get dividend information for MSFT
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Why it matters:** Ex-dividend dates affect options pricing, especially for calls. Stock price typically drops by the dividend amount on ex-div date.
|
|
354
|
+
|
|
355
|
+
### 11. calculate_historical_volatility
|
|
356
|
+
|
|
357
|
+
Calculate historical (realized) volatility for multiple periods.
|
|
358
|
+
|
|
359
|
+
**Input:**
|
|
360
|
+
```json
|
|
361
|
+
{
|
|
362
|
+
"symbol": "AAPL",
|
|
363
|
+
"periods": [10, 20, 30, 60, 90] // Days
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Example:**
|
|
368
|
+
```
|
|
369
|
+
Calculate 30-day historical volatility for TSLA
|
|
370
|
+
Show me historical volatility trends for AAPL
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Why it matters:** Compare historical volatility (HV) with implied volatility (IV) to identify overpriced or underpriced options. High IV relative to HV suggests expensive options (good for selling), while low IV relative to HV suggests cheap options (good for buying).
|
|
374
|
+
|
|
375
|
+
### 12. calculate_max_pain
|
|
376
|
+
|
|
377
|
+
Calculate the max pain price where most options expire worthless.
|
|
378
|
+
|
|
379
|
+
**Input:**
|
|
380
|
+
```json
|
|
381
|
+
{
|
|
382
|
+
"symbol": "AAPL",
|
|
383
|
+
"expirationDate": "2024-06-21" // Optional
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Example:**
|
|
388
|
+
```
|
|
389
|
+
What's the max pain for AAPL options?
|
|
390
|
+
Calculate max pain for next week's SPY expiration
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Theory:** Max pain theory suggests prices gravitate toward the strike where option buyers lose the most money (and option writers profit the most) as expiration approaches.
|
|
394
|
+
|
|
395
|
+
### 13. get_implied_volatility
|
|
396
|
+
|
|
397
|
+
Get implied volatility data and compare with historical volatility.
|
|
398
|
+
|
|
399
|
+
**Input:**
|
|
400
|
+
```json
|
|
401
|
+
{
|
|
402
|
+
"symbol": "AAPL"
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Example:**
|
|
407
|
+
```
|
|
408
|
+
What's the current IV for Tesla options?
|
|
409
|
+
Show me implied volatility by expiration for AAPL
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**Analysis provided:**
|
|
413
|
+
- Current ATM IV
|
|
414
|
+
- IV vs HV comparison
|
|
415
|
+
- IV by expiration (term structure)
|
|
416
|
+
- High/low IV environment assessment
|
|
417
|
+
|
|
418
|
+
### 14. analyze_options_strategy
|
|
419
|
+
|
|
420
|
+
Analyze complex options strategies with P&L calculations, Greeks, and risk metrics.
|
|
421
|
+
|
|
422
|
+
**Input:**
|
|
423
|
+
```json
|
|
424
|
+
{
|
|
425
|
+
"symbol": "AAPL",
|
|
426
|
+
"strategy": "iron_condor",
|
|
427
|
+
"legs": [
|
|
428
|
+
{"strike": 170, "optionType": "put", "action": "buy", "quantity": 1},
|
|
429
|
+
{"strike": 175, "optionType": "put", "action": "sell", "quantity": 1},
|
|
430
|
+
{"strike": 185, "optionType": "call", "action": "sell", "quantity": 1},
|
|
431
|
+
{"strike": 190, "optionType": "call", "action": "buy", "quantity": 1}
|
|
432
|
+
],
|
|
433
|
+
"expirationDate": "2024-06-21"
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**Supported Strategies:**
|
|
438
|
+
- Single options: call, put
|
|
439
|
+
- Stock + option: covered_call, protective_put
|
|
440
|
+
- Vertical spreads: bull_call_spread, bear_put_spread, bull_put_spread, bear_call_spread
|
|
441
|
+
- Volatility: long_straddle, short_straddle, long_strangle, short_strangle
|
|
442
|
+
- Advanced: iron_condor, iron_butterfly, butterfly_spread, calendar_spread, diagonal_spread
|
|
443
|
+
|
|
444
|
+
**Example:**
|
|
445
|
+
```
|
|
446
|
+
Analyze an iron condor on SPY with strikes 170/175/185/190
|
|
447
|
+
What's the risk/reward for a bull call spread on AAPL $175/$180?
|
|
448
|
+
Show me P&L chart for a covered call on TSLA at $250 strike
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
**Output:**
|
|
452
|
+
- Max profit & max loss
|
|
453
|
+
- Break-even points
|
|
454
|
+
- Net premium/debit
|
|
455
|
+
- Combined Greeks for entire position
|
|
456
|
+
- P&L chart (profit/loss at various prices)
|
|
457
|
+
- Risk/reward ratio
|
|
458
|
+
|
|
459
|
+
## Available Resources
|
|
460
|
+
|
|
461
|
+
### watchlist://default
|
|
462
|
+
|
|
463
|
+
Access your default watchlist of tracked symbols.
|
|
464
|
+
|
|
465
|
+
**Example:**
|
|
466
|
+
```
|
|
467
|
+
Show me my watchlist
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### market://summary
|
|
471
|
+
|
|
472
|
+
Get real-time summary of major market indices (S&P 500, Dow Jones, NASDAQ, VIX).
|
|
473
|
+
|
|
474
|
+
**Example:**
|
|
475
|
+
```
|
|
476
|
+
What's the market doing today?
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### market://trending
|
|
480
|
+
|
|
481
|
+
Get trending and most active stocks.
|
|
482
|
+
|
|
483
|
+
**Example:**
|
|
484
|
+
```
|
|
485
|
+
What stocks are trending?
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
## Example Use Cases
|
|
489
|
+
|
|
490
|
+
### Investment Analysis
|
|
491
|
+
```
|
|
492
|
+
1. Get current price of Tesla (TSLA)
|
|
493
|
+
2. Show me the last 6 months of daily data for TSLA
|
|
494
|
+
3. Calculate the 50-day moving average for TSLA
|
|
495
|
+
4. Calculate RSI for TSLA
|
|
496
|
+
5. Get latest news about Tesla
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Crypto Tracking
|
|
500
|
+
```
|
|
501
|
+
1. Get current prices for BTC-USD, ETH-USD, and ADA-USD
|
|
502
|
+
2. Show me Bitcoin's price history for the last week with hourly intervals
|
|
503
|
+
3. Calculate MACD for Ethereum
|
|
504
|
+
4. What's the market summary?
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### Technical Analysis
|
|
508
|
+
```
|
|
509
|
+
1. Calculate Bollinger Bands for Apple stock
|
|
510
|
+
2. Show me the RSI for MSFT
|
|
511
|
+
3. Calculate the 20-day and 50-day moving averages for GOOGL
|
|
512
|
+
4. Get stochastic oscillator for SPY
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Market Research
|
|
516
|
+
```
|
|
517
|
+
1. Search for companies in the electric vehicle sector
|
|
518
|
+
2. Get quotes for the top results
|
|
519
|
+
3. Compare their market caps and P/E ratios
|
|
520
|
+
4. Get news for each company
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### Options Trading - Pre-Earnings Analysis
|
|
524
|
+
```
|
|
525
|
+
1. When is Apple's next earnings date?
|
|
526
|
+
2. Show me the options chain for AAPL
|
|
527
|
+
3. What's the current implied volatility for AAPL?
|
|
528
|
+
4. Calculate historical volatility for comparison
|
|
529
|
+
5. Find options with high IV to potentially sell premium
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### Options Trading - Strategy Building
|
|
533
|
+
```
|
|
534
|
+
1. Show me TSLA options expiring next month
|
|
535
|
+
2. Calculate Greeks for $250 call
|
|
536
|
+
3. Analyze an iron condor strategy on TSLA
|
|
537
|
+
4. What's the max profit and max loss?
|
|
538
|
+
5. Show me the P&L chart
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### Options Trading - Risk Management
|
|
542
|
+
```
|
|
543
|
+
1. Get the Greeks for my AAPL $180 call position
|
|
544
|
+
2. What's my delta exposure?
|
|
545
|
+
3. How much am I losing to time decay (theta)?
|
|
546
|
+
4. Calculate max pain for this expiration
|
|
547
|
+
5. Should I hedge with a protective put?
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### Options Trading - Volatility Analysis
|
|
551
|
+
```
|
|
552
|
+
1. Compare IV vs HV for SPY
|
|
553
|
+
2. Is this a high or low volatility environment?
|
|
554
|
+
3. Show me IV by expiration (term structure)
|
|
555
|
+
4. Find opportunities where IV is elevated
|
|
556
|
+
5. Calculate historical volatility for the past 30 days
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
## Technical Details
|
|
560
|
+
|
|
561
|
+
### Data Source
|
|
562
|
+
|
|
563
|
+
All data is sourced from Yahoo Finance via the `yahoo-finance2` library. Yahoo Finance provides:
|
|
564
|
+
- Real-time quotes (with 15-minute delay for some markets)
|
|
565
|
+
- Historical data going back many years
|
|
566
|
+
- Cryptocurrency data (BTC-USD, ETH-USD, etc.)
|
|
567
|
+
- No API key required
|
|
568
|
+
- Free for personal and educational use
|
|
569
|
+
|
|
570
|
+
### Caching Strategy
|
|
571
|
+
|
|
572
|
+
The server implements intelligent caching to minimize API calls and improve performance:
|
|
573
|
+
|
|
574
|
+
- **Quotes**: 5 seconds (adjusts based on market hours)
|
|
575
|
+
- **Historical Data**: 1 hour during market hours, 24 hours after hours
|
|
576
|
+
- **News**: 5 minutes
|
|
577
|
+
- **Search Results**: 1 hour
|
|
578
|
+
- **Technical Indicators**: 5 minutes
|
|
579
|
+
- **Market Summary**: 1 minute
|
|
580
|
+
|
|
581
|
+
Cache TTLs automatically extend during weekends and after market hours to reduce unnecessary API calls.
|
|
582
|
+
|
|
583
|
+
### Error Handling
|
|
584
|
+
|
|
585
|
+
The server provides clear, actionable error messages:
|
|
586
|
+
|
|
587
|
+
- **Invalid Symbol** (404): Symbol not found, check ticker
|
|
588
|
+
- **Validation Error** (400): Invalid input parameters
|
|
589
|
+
- **Rate Limit** (429): Too many requests, try again later
|
|
590
|
+
- **Network Error** (502): Connection issues
|
|
591
|
+
- **Timeout** (504): Request took too long
|
|
592
|
+
|
|
593
|
+
### Technical Indicators Library
|
|
594
|
+
|
|
595
|
+
Uses the `technicalindicators` library for accurate, battle-tested calculations. Supports:
|
|
596
|
+
- RSI with overbought/oversold signals
|
|
597
|
+
- MACD with bullish/bearish crossover detection
|
|
598
|
+
- Multiple moving average types
|
|
599
|
+
- Bollinger Bands with bandwidth and %B calculations
|
|
600
|
+
- Stochastic oscillator
|
|
601
|
+
|
|
602
|
+
## CI/CD & Automation
|
|
603
|
+
|
|
604
|
+
This project uses GitHub Actions for continuous integration and deployment:
|
|
605
|
+
|
|
606
|
+
### Automated Workflows
|
|
607
|
+
|
|
608
|
+
1. **PR Quality Checks** - Runs on every pull request
|
|
609
|
+
- Security scanning (npm audit, Trivy, TruffleHog)
|
|
610
|
+
- Code quality checks (ESLint, formatting)
|
|
611
|
+
- Build verification
|
|
612
|
+
- Tests across multiple Node.js versions (18.x, 20.x, 22.x)
|
|
613
|
+
- Dependency review
|
|
614
|
+
|
|
615
|
+
2. **Automatic Publishing** - Runs on merge to main
|
|
616
|
+
- Auto version bump
|
|
617
|
+
- npm registry publication with provenance
|
|
618
|
+
- GitHub release creation
|
|
619
|
+
- Package artifact upload
|
|
620
|
+
|
|
621
|
+
### Setup for Contributors
|
|
622
|
+
|
|
623
|
+
See [`.github/workflows/README.md`](.github/workflows/README.md) for detailed workflow documentation.
|
|
624
|
+
|
|
625
|
+
**Required Secrets (for maintainers):**
|
|
626
|
+
- `NPM_TOKEN` - For publishing to npm registry (requires 2FA bypass or automation token)
|
|
627
|
+
|
|
628
|
+
## Development
|
|
629
|
+
|
|
630
|
+
### Project Structure
|
|
631
|
+
|
|
632
|
+
```
|
|
633
|
+
mcp-financex/
|
|
634
|
+
├── src/
|
|
635
|
+
│ ├── index.ts # Entry point
|
|
636
|
+
│ ├── server.ts # MCP server setup
|
|
637
|
+
│ ├── tools/ # MCP tool implementations
|
|
638
|
+
│ ├── resources/ # MCP resource implementations
|
|
639
|
+
│ ├── services/ # Core services (Yahoo Finance, cache, indicators)
|
|
640
|
+
│ ├── types/ # TypeScript type definitions
|
|
641
|
+
│ └── utils/ # Utilities (error handling, validation)
|
|
642
|
+
├── tests/ # Test files
|
|
643
|
+
├── package.json
|
|
644
|
+
├── tsconfig.json
|
|
645
|
+
└── README.md
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Scripts
|
|
649
|
+
|
|
650
|
+
- `npm run build` - Compile TypeScript to JavaScript
|
|
651
|
+
- `npm run dev` - Run in development mode with auto-reload
|
|
652
|
+
- `npm start` - Run compiled server
|
|
653
|
+
- `npm test` - Run tests
|
|
654
|
+
- `npm run lint` - Run ESLint
|
|
655
|
+
- `npm run format` - Format code with Prettier
|
|
656
|
+
|
|
657
|
+
### Testing
|
|
658
|
+
|
|
659
|
+
Run the test suite:
|
|
660
|
+
```bash
|
|
661
|
+
npm test
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
Run tests in watch mode:
|
|
665
|
+
```bash
|
|
666
|
+
npm run test:watch
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
Generate coverage report:
|
|
670
|
+
```bash
|
|
671
|
+
npm run test:coverage
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
### Environment Variables
|
|
675
|
+
|
|
676
|
+
Configuration options (optional, defaults provided):
|
|
677
|
+
|
|
678
|
+
```bash
|
|
679
|
+
# Server Configuration
|
|
680
|
+
NODE_ENV=development
|
|
681
|
+
LOG_LEVEL=info
|
|
682
|
+
|
|
683
|
+
# Cache Configuration (in seconds)
|
|
684
|
+
CACHE_DEFAULT_TTL=300
|
|
685
|
+
CACHE_QUOTE_TTL=5
|
|
686
|
+
CACHE_HISTORICAL_TTL=3600
|
|
687
|
+
CACHE_NEWS_TTL=300
|
|
688
|
+
CACHE_SEARCH_TTL=3600
|
|
689
|
+
CACHE_INDICATOR_TTL=300
|
|
690
|
+
|
|
691
|
+
# Yahoo Finance Configuration
|
|
692
|
+
YAHOO_FINANCE_TIMEOUT=10000
|
|
693
|
+
YAHOO_FINANCE_RETRY_ATTEMPTS=3
|
|
694
|
+
YAHOO_FINANCE_RETRY_DELAY=1000
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
## Limitations
|
|
698
|
+
|
|
699
|
+
- **Rate Limiting**: Yahoo Finance has rate limits. The server implements caching and retry logic to mitigate this.
|
|
700
|
+
- **Real-time Data**: Some quotes may have a 15-minute delay depending on the exchange.
|
|
701
|
+
- **Intraday Data**: Intraday intervals (1m, 5m, etc.) have limited historical data (typically 7 days).
|
|
702
|
+
- **Crypto Coverage**: Primarily supports major cryptocurrencies paired with USD (BTC-USD, ETH-USD, etc.).
|
|
703
|
+
- **No Authentication**: Yahoo Finance data is public and doesn't require authentication, but usage should comply with Yahoo's terms of service.
|
|
704
|
+
|
|
705
|
+
## Future Enhancements
|
|
706
|
+
|
|
707
|
+
Planned features for future releases:
|
|
708
|
+
|
|
709
|
+
- Portfolio tracking and P&L calculations
|
|
710
|
+
- Price alerts and notifications
|
|
711
|
+
- Backtesting capabilities
|
|
712
|
+
- More technical indicators (Ichimoku, Fibonacci, etc.)
|
|
713
|
+
- Options data and Greeks calculations
|
|
714
|
+
- Comparison tools for multiple stocks
|
|
715
|
+
- Export to CSV/JSON
|
|
716
|
+
- Redis caching for multi-instance deployments
|
|
717
|
+
- WebSocket streaming for real-time updates
|
|
718
|
+
|
|
719
|
+
## Troubleshooting
|
|
720
|
+
|
|
721
|
+
### "Symbol not found" Error
|
|
722
|
+
Make sure you're using the correct ticker symbol format:
|
|
723
|
+
- Stocks: `AAPL`, `MSFT`, `GOOGL`
|
|
724
|
+
- Crypto: `BTC-USD`, `ETH-USD` (not `BTC` alone)
|
|
725
|
+
- Indices: `^GSPC` (S&P 500), `^DJI` (Dow Jones)
|
|
726
|
+
|
|
727
|
+
### "Rate limit exceeded" Error
|
|
728
|
+
The server is making too many requests to Yahoo Finance. The built-in caching should prevent this, but if it occurs:
|
|
729
|
+
- Wait a few minutes before retrying
|
|
730
|
+
- Reduce the frequency of requests
|
|
731
|
+
- Check cache configuration
|
|
732
|
+
|
|
733
|
+
### Connection Issues
|
|
734
|
+
Ensure you have a stable internet connection. The server will automatically retry failed requests up to 3 times with exponential backoff.
|
|
735
|
+
|
|
736
|
+
## Publishing to npm
|
|
737
|
+
|
|
738
|
+
To make this package available for external deployment (so users can run it with `npx` without installation):
|
|
739
|
+
|
|
740
|
+
### First-time setup:
|
|
741
|
+
|
|
742
|
+
1. **Create an npm account** (if you don't have one):
|
|
743
|
+
```bash
|
|
744
|
+
npm adduser
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
2. **Update package.json** with your GitHub repository URL:
|
|
748
|
+
```json
|
|
749
|
+
"repository": {
|
|
750
|
+
"type": "git",
|
|
751
|
+
"url": "git+https://github.com/xerktech/mcp-financex.git"
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
3. **Build and publish**:
|
|
756
|
+
```bash
|
|
757
|
+
npm run build
|
|
758
|
+
npm publish
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
### For updates:
|
|
762
|
+
|
|
763
|
+
1. **Update version** in package.json:
|
|
764
|
+
```bash
|
|
765
|
+
npm version patch # 1.0.0 -> 1.0.1
|
|
766
|
+
npm version minor # 1.0.0 -> 1.1.0
|
|
767
|
+
npm version major # 1.0.0 -> 2.0.0
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
2. **Publish**:
|
|
771
|
+
```bash
|
|
772
|
+
npm publish
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
Once published, users can use it in their Claude Desktop config:
|
|
776
|
+
```json
|
|
777
|
+
{
|
|
778
|
+
"mcpServers": {
|
|
779
|
+
"finance": {
|
|
780
|
+
"command": "npx",
|
|
781
|
+
"args": ["-y", "mcp-financex"]
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
This is similar to how the Alpha Vantage MCP works with `uvx` - users don't need to install anything locally!
|
|
788
|
+
|
|
789
|
+
## Contributing
|
|
790
|
+
|
|
791
|
+
Contributions are welcome! Please:
|
|
792
|
+
|
|
793
|
+
1. Fork the repository
|
|
794
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
795
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
796
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
797
|
+
5. Open a Pull Request
|
|
798
|
+
|
|
799
|
+
Please ensure:
|
|
800
|
+
- Code follows the existing style (use `npm run format`)
|
|
801
|
+
- Tests pass (`npm test`)
|
|
802
|
+
- New features include tests
|
|
803
|
+
- Documentation is updated
|
|
804
|
+
|
|
805
|
+
## License
|
|
806
|
+
|
|
807
|
+
MIT License - see LICENSE file for details
|
|
808
|
+
|
|
809
|
+
## Acknowledgments
|
|
810
|
+
|
|
811
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/) by Anthropic
|
|
812
|
+
- [yahoo-finance2](https://github.com/gadicc/yahoo-finance2) for Yahoo Finance API access
|
|
813
|
+
- [technicalindicators](https://github.com/anandanand84/technicalindicators) for technical analysis calculations
|
|
814
|
+
|
|
815
|
+
## Disclaimer
|
|
816
|
+
|
|
817
|
+
This software is provided for educational and informational purposes only. It is not intended as financial advice. Always do your own research and consult with a qualified financial advisor before making investment decisions. The authors are not responsible for any financial losses incurred through the use of this software.
|
|
818
|
+
|
|
819
|
+
Yahoo Finance data is subject to Yahoo's terms of service. This project is not affiliated with or endorsed by Yahoo.
|