yfin-mcp 0.1.0__py3-none-any.whl
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.
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yfin-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Enhanced Yahoo Finance MCP Server with intelligent pagination, caching, and LLM-optimized responses
|
|
5
|
+
Author: AlexYoung (Original Author)
|
|
6
|
+
Author-email: fritzprix <innocentevil0914@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/fritzprix/yahoo-finance-mcp
|
|
9
|
+
Project-URL: Repository, https://github.com/fritzprix/yahoo-finance-mcp
|
|
10
|
+
Project-URL: Issues, https://github.com/fritzprix/yahoo-finance-mcp/issues
|
|
11
|
+
Project-URL: Documentation, https://github.com/fritzprix/yahoo-finance-mcp#readme
|
|
12
|
+
Keywords: mcp,model-context-protocol,yahoo-finance,yfinance,financial-data,stock-market,llm,ai-agent
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
|
26
|
+
Requires-Dist: yfinance>=0.2.62
|
|
27
|
+
Requires-Dist: pandas>=2.0.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=24.2.0; extra == "dev"
|
|
31
|
+
Requires-Dist: isort>=5.13.2; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# yfin-mcp - Yahoo Finance MCP Server
|
|
35
|
+
|
|
36
|
+
> **Enhanced fork** of [yahoo-finance-mcp](https://github.com/Alex2Yang97/yahoo-finance-mcp) by Alex2Yang97
|
|
37
|
+
> With intelligent pagination, caching, and LLM-optimized responses
|
|
38
|
+
|
|
39
|
+
<div align="right">
|
|
40
|
+
<a href="README.md">English</a> | <a href="README.zh.md">δΈζ</a>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
A high-performance Model Context Protocol (MCP) server that provides comprehensive financial data from Yahoo Finance with **intelligent pagination**, **caching**, and **LLM-optimized responses**.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## π Attribution & Motivation
|
|
48
|
+
|
|
49
|
+
### Original Work
|
|
50
|
+
This project is built upon the excellent foundation of [yahoo-finance-mcp](https://github.com/Alex2Yang97/yahoo-finance-mcp) created by **Alex2Yang97**. The original implementation provides a comprehensive set of tools for accessing Yahoo Finance data through the Model Context Protocol.
|
|
51
|
+
|
|
52
|
+
### Why These Enhancements?
|
|
53
|
+
|
|
54
|
+
While using the original implementation with LLM agents (Claude, ChatGPT, etc.), I encountered critical limitations:
|
|
55
|
+
|
|
56
|
+
**Problem 1: Context Window Overflow**
|
|
57
|
+
- Historical stock data with `period="max"` could return thousands of rows
|
|
58
|
+
- Option chains for popular stocks contained hundreds of contracts
|
|
59
|
+
- LLM context windows (typically 200K tokens) would overflow
|
|
60
|
+
- Responses would be truncated, losing critical data
|
|
61
|
+
|
|
62
|
+
**Problem 2: No Data Persistence**
|
|
63
|
+
- Large datasets couldn't be saved for offline analysis
|
|
64
|
+
- Repeated queries wasted API calls and time
|
|
65
|
+
- No way to export data for use in other tools
|
|
66
|
+
|
|
67
|
+
**Problem 3: Poor LLM Readability**
|
|
68
|
+
- JSON responses were hard for LLMs to parse when truncated
|
|
69
|
+
- No clear navigation guidance for paginated data
|
|
70
|
+
- Cache status was invisible to the LLM
|
|
71
|
+
|
|
72
|
+
### Solution: Pagination, Caching & Export
|
|
73
|
+
|
|
74
|
+
This fork adds three key enhancements:
|
|
75
|
+
|
|
76
|
+
1. **Token-Based Pagination** (6,000 token limit per page)
|
|
77
|
+
- Prevents context window overflow
|
|
78
|
+
- Clear navigation guidance for LLMs
|
|
79
|
+
- Dynamic page sizing based on data complexity
|
|
80
|
+
|
|
81
|
+
2. **Intelligent Caching** (TTL: 5min-1hr)
|
|
82
|
+
- Reduces redundant API calls by 50-80%
|
|
83
|
+
- Sub-millisecond response times for cached data
|
|
84
|
+
- Automatic cache invalidation based on data volatility
|
|
85
|
+
|
|
86
|
+
3. **JSON Export** (File Download)
|
|
87
|
+
- Save full datasets for offline analysis
|
|
88
|
+
- Export to Excel, databases, or other tools
|
|
89
|
+
- Preserve complete data without pagination
|
|
90
|
+
|
|
91
|
+
### Credit Where Credit is Due
|
|
92
|
+
|
|
93
|
+
**Original Author**: Alex2Yang97 deserves full credit for:
|
|
94
|
+
- β
Complete Yahoo Finance API integration
|
|
95
|
+
- β
All 9 MCP tools implementation
|
|
96
|
+
- β
Robust error handling
|
|
97
|
+
- β
Comprehensive documentation
|
|
98
|
+
|
|
99
|
+
**This Fork Adds**: Pagination, caching, and export features to make the server production-ready for LLM agents handling large financial datasets.
|
|
100
|
+
|
|
101
|
+
## Demo
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
## MCP Tools
|
|
106
|
+
|
|
107
|
+
The server exposes the following tools through the Model Context Protocol:
|
|
108
|
+
|
|
109
|
+
### Stock Information
|
|
110
|
+
|
|
111
|
+
| Tool | Description |
|
|
112
|
+
|------|-------------|
|
|
113
|
+
| `get_historical_stock_prices` | Get historical OHLCV data for a stock with customizable period and interval |
|
|
114
|
+
| `get_stock_info` | Get comprehensive stock data including price, metrics, and company details |
|
|
115
|
+
| `get_yahoo_finance_news` | Get latest news articles for a stock |
|
|
116
|
+
| `get_stock_actions` | Get stock dividends and splits history |
|
|
117
|
+
|
|
118
|
+
### Financial Statements
|
|
119
|
+
|
|
120
|
+
| Tool | Description |
|
|
121
|
+
|------|-------------|
|
|
122
|
+
| `get_financial_statement` | Get income statement, balance sheet, or cash flow statement (annual/quarterly) |
|
|
123
|
+
| `get_holder_info` | Get major holders, institutional holders, mutual funds, or insider transactions |
|
|
124
|
+
|
|
125
|
+
### Options Data
|
|
126
|
+
|
|
127
|
+
| Tool | Description |
|
|
128
|
+
|------|-------------|
|
|
129
|
+
| `get_option_expiration_dates` | Get available options expiration dates |
|
|
130
|
+
| `get_option_chain` | Get options chain for a specific expiration date and type (calls/puts) |
|
|
131
|
+
|
|
132
|
+
### Analyst Information
|
|
133
|
+
|
|
134
|
+
| Tool | Description |
|
|
135
|
+
|------|-------------|
|
|
136
|
+
| `get_recommendations` | Get analyst recommendations or upgrades/downgrades history |
|
|
137
|
+
|
|
138
|
+
## Real-World Use Cases
|
|
139
|
+
|
|
140
|
+
With this MCP server, you can use Claude to:
|
|
141
|
+
|
|
142
|
+
### Stock Analysis
|
|
143
|
+
|
|
144
|
+
- **Price Analysis**: "Show me the historical stock prices for AAPL over the last 6 months with daily intervals."
|
|
145
|
+
- **Financial Health**: "Get the quarterly balance sheet for Microsoft."
|
|
146
|
+
- **Performance Metrics**: "What are the key financial metrics for Tesla from the stock info?"
|
|
147
|
+
- **Trend Analysis**: "Compare the quarterly income statements of Amazon and Google."
|
|
148
|
+
- **Cash Flow Analysis**: "Show me the annual cash flow statement for NVIDIA."
|
|
149
|
+
|
|
150
|
+
### Market Research
|
|
151
|
+
|
|
152
|
+
- **News Analysis**: "Get the latest news articles about Meta Platforms."
|
|
153
|
+
- **Institutional Activity**: "Show me the institutional holders of Apple stock."
|
|
154
|
+
- **Insider Trading**: "What are the recent insider transactions for Tesla?"
|
|
155
|
+
- **Options Analysis**: "Get the options chain for SPY with expiration date 2024-06-21 for calls."
|
|
156
|
+
- **Analyst Coverage**: "What are the analyst recommendations for Amazon over the last 3 months?"
|
|
157
|
+
|
|
158
|
+
### Investment Research
|
|
159
|
+
|
|
160
|
+
- "Create a comprehensive analysis of Microsoft's financial health using their latest quarterly financial statements."
|
|
161
|
+
- "Compare the dividend history and stock splits of Coca-Cola and PepsiCo."
|
|
162
|
+
- "Analyze the institutional ownership changes in Tesla over the past year."
|
|
163
|
+
- "Generate a report on the options market activity for Apple stock with expiration in 30 days."
|
|
164
|
+
- "Summarize the latest analyst upgrades and downgrades in the tech sector over the last 6 months."
|
|
165
|
+
|
|
166
|
+
## Requirements
|
|
167
|
+
|
|
168
|
+
- Python 3.11 or higher
|
|
169
|
+
- Dependencies as listed in `pyproject.toml`, including:
|
|
170
|
+
- mcp
|
|
171
|
+
- yfinance
|
|
172
|
+
- pandas
|
|
173
|
+
- pydantic
|
|
174
|
+
- and other packages for data processing
|
|
175
|
+
|
|
176
|
+
## Setup
|
|
177
|
+
|
|
178
|
+
1. Clone this repository:
|
|
179
|
+
```bash
|
|
180
|
+
git clone https://github.com/Alex2Yang97/yahoo-finance-mcp.git
|
|
181
|
+
cd yahoo-finance-mcp
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
2. Create and activate a virtual environment and install dependencies:
|
|
185
|
+
```bash
|
|
186
|
+
uv venv
|
|
187
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
188
|
+
uv pip install -e .
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Usage
|
|
192
|
+
|
|
193
|
+
### Development Mode
|
|
194
|
+
|
|
195
|
+
You can test the server with MCP Inspector by running:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
uv run server.py
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
This will start the server and allow you to test the available tools.
|
|
202
|
+
|
|
203
|
+
### Integration with Claude for Desktop
|
|
204
|
+
|
|
205
|
+
To integrate this server with Claude for Desktop:
|
|
206
|
+
|
|
207
|
+
1. Install Claude for Desktop to your local machine.
|
|
208
|
+
2. Install VS Code to your local machine. Then run the following command to open the `claude_desktop_config.json` file:
|
|
209
|
+
- MacOS: `code ~/Library/Application\ Support/Claude/claude_desktop_config.json`
|
|
210
|
+
- Windows: `code $env:AppData\Claude\claude_desktop_config.json`
|
|
211
|
+
|
|
212
|
+
3. Edit the Claude for Desktop config file, located at:
|
|
213
|
+
- macOS:
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"mcpServers": {
|
|
217
|
+
"yfinance": {
|
|
218
|
+
"command": "uv",
|
|
219
|
+
"args": [
|
|
220
|
+
"--directory",
|
|
221
|
+
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/yahoo-finance-mcp",
|
|
222
|
+
"run",
|
|
223
|
+
"server.py"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
- Windows:
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"mcpServers": {
|
|
233
|
+
"yfinance": {
|
|
234
|
+
"command": "uv",
|
|
235
|
+
"args": [
|
|
236
|
+
"--directory",
|
|
237
|
+
"C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\yahoo-finance-mcp",
|
|
238
|
+
"run",
|
|
239
|
+
"server.py"
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
- **Note**: You may need to put the full path to the uv executable in the command field. You can get this by running `which uv` on MacOS/Linux or `where uv` on Windows.
|
|
247
|
+
|
|
248
|
+
4. Restart Claude for Desktop
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT License
|
|
253
|
+
|
|
254
|
+
**Original Work**: Copyright (c) 2025 AlexYoung
|
|
255
|
+
**Fork Enhancements**: Copyright (c) 2026 SKTelecom
|
|
256
|
+
|
|
257
|
+
This project maintains the MIT License from the original [yahoo-finance-mcp](https://github.com/Alex2Yang97/yahoo-finance-mcp) project. All enhancements (pagination, caching, export) are also released under MIT License.
|
|
258
|
+
|
|
259
|
+
See [LICENSE](LICENSE) file for full details.
|
|
260
|
+
|
|
261
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
yfin_mcp-0.1.0.dist-info/licenses/LICENSE,sha256=-X17dvA84FUO-t9DRgqDt7JO2d0tSz6UpuZ-ZMtFfyo,1189
|
|
2
|
+
yfin_mcp-0.1.0.dist-info/METADATA,sha256=D64yHatXMNLB7ouW_dQPmbJo5OUPNFjQsuXn9xnkRvk,9604
|
|
3
|
+
yfin_mcp-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
4
|
+
yfin_mcp-0.1.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
5
|
+
yfin_mcp-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AlexYoung (Original Author)
|
|
4
|
+
Copyright (c) 2026 SKTelecom (Fork Maintainer - Pagination & Caching Enhancements)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|