yfin-mcp 0.1.0__tar.gz

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.
yfin_mcp-0.1.0/LICENSE ADDED
@@ -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,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
+ ![MCP Demo](assets/demo.gif)
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,228 @@
1
+ # yfin-mcp - Yahoo Finance MCP Server
2
+
3
+ > **Enhanced fork** of [yahoo-finance-mcp](https://github.com/Alex2Yang97/yahoo-finance-mcp) by Alex2Yang97
4
+ > With intelligent pagination, caching, and LLM-optimized responses
5
+
6
+ <div align="right">
7
+ <a href="README.md">English</a> | <a href="README.zh.md">δΈ­ζ–‡</a>
8
+ </div>
9
+
10
+ A high-performance Model Context Protocol (MCP) server that provides comprehensive financial data from Yahoo Finance with **intelligent pagination**, **caching**, and **LLM-optimized responses**.
11
+
12
+ ---
13
+
14
+ ## πŸ™ Attribution & Motivation
15
+
16
+ ### Original Work
17
+ 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.
18
+
19
+ ### Why These Enhancements?
20
+
21
+ While using the original implementation with LLM agents (Claude, ChatGPT, etc.), I encountered critical limitations:
22
+
23
+ **Problem 1: Context Window Overflow**
24
+ - Historical stock data with `period="max"` could return thousands of rows
25
+ - Option chains for popular stocks contained hundreds of contracts
26
+ - LLM context windows (typically 200K tokens) would overflow
27
+ - Responses would be truncated, losing critical data
28
+
29
+ **Problem 2: No Data Persistence**
30
+ - Large datasets couldn't be saved for offline analysis
31
+ - Repeated queries wasted API calls and time
32
+ - No way to export data for use in other tools
33
+
34
+ **Problem 3: Poor LLM Readability**
35
+ - JSON responses were hard for LLMs to parse when truncated
36
+ - No clear navigation guidance for paginated data
37
+ - Cache status was invisible to the LLM
38
+
39
+ ### Solution: Pagination, Caching & Export
40
+
41
+ This fork adds three key enhancements:
42
+
43
+ 1. **Token-Based Pagination** (6,000 token limit per page)
44
+ - Prevents context window overflow
45
+ - Clear navigation guidance for LLMs
46
+ - Dynamic page sizing based on data complexity
47
+
48
+ 2. **Intelligent Caching** (TTL: 5min-1hr)
49
+ - Reduces redundant API calls by 50-80%
50
+ - Sub-millisecond response times for cached data
51
+ - Automatic cache invalidation based on data volatility
52
+
53
+ 3. **JSON Export** (File Download)
54
+ - Save full datasets for offline analysis
55
+ - Export to Excel, databases, or other tools
56
+ - Preserve complete data without pagination
57
+
58
+ ### Credit Where Credit is Due
59
+
60
+ **Original Author**: Alex2Yang97 deserves full credit for:
61
+ - βœ… Complete Yahoo Finance API integration
62
+ - βœ… All 9 MCP tools implementation
63
+ - βœ… Robust error handling
64
+ - βœ… Comprehensive documentation
65
+
66
+ **This Fork Adds**: Pagination, caching, and export features to make the server production-ready for LLM agents handling large financial datasets.
67
+
68
+ ## Demo
69
+
70
+ ![MCP Demo](assets/demo.gif)
71
+
72
+ ## MCP Tools
73
+
74
+ The server exposes the following tools through the Model Context Protocol:
75
+
76
+ ### Stock Information
77
+
78
+ | Tool | Description |
79
+ |------|-------------|
80
+ | `get_historical_stock_prices` | Get historical OHLCV data for a stock with customizable period and interval |
81
+ | `get_stock_info` | Get comprehensive stock data including price, metrics, and company details |
82
+ | `get_yahoo_finance_news` | Get latest news articles for a stock |
83
+ | `get_stock_actions` | Get stock dividends and splits history |
84
+
85
+ ### Financial Statements
86
+
87
+ | Tool | Description |
88
+ |------|-------------|
89
+ | `get_financial_statement` | Get income statement, balance sheet, or cash flow statement (annual/quarterly) |
90
+ | `get_holder_info` | Get major holders, institutional holders, mutual funds, or insider transactions |
91
+
92
+ ### Options Data
93
+
94
+ | Tool | Description |
95
+ |------|-------------|
96
+ | `get_option_expiration_dates` | Get available options expiration dates |
97
+ | `get_option_chain` | Get options chain for a specific expiration date and type (calls/puts) |
98
+
99
+ ### Analyst Information
100
+
101
+ | Tool | Description |
102
+ |------|-------------|
103
+ | `get_recommendations` | Get analyst recommendations or upgrades/downgrades history |
104
+
105
+ ## Real-World Use Cases
106
+
107
+ With this MCP server, you can use Claude to:
108
+
109
+ ### Stock Analysis
110
+
111
+ - **Price Analysis**: "Show me the historical stock prices for AAPL over the last 6 months with daily intervals."
112
+ - **Financial Health**: "Get the quarterly balance sheet for Microsoft."
113
+ - **Performance Metrics**: "What are the key financial metrics for Tesla from the stock info?"
114
+ - **Trend Analysis**: "Compare the quarterly income statements of Amazon and Google."
115
+ - **Cash Flow Analysis**: "Show me the annual cash flow statement for NVIDIA."
116
+
117
+ ### Market Research
118
+
119
+ - **News Analysis**: "Get the latest news articles about Meta Platforms."
120
+ - **Institutional Activity**: "Show me the institutional holders of Apple stock."
121
+ - **Insider Trading**: "What are the recent insider transactions for Tesla?"
122
+ - **Options Analysis**: "Get the options chain for SPY with expiration date 2024-06-21 for calls."
123
+ - **Analyst Coverage**: "What are the analyst recommendations for Amazon over the last 3 months?"
124
+
125
+ ### Investment Research
126
+
127
+ - "Create a comprehensive analysis of Microsoft's financial health using their latest quarterly financial statements."
128
+ - "Compare the dividend history and stock splits of Coca-Cola and PepsiCo."
129
+ - "Analyze the institutional ownership changes in Tesla over the past year."
130
+ - "Generate a report on the options market activity for Apple stock with expiration in 30 days."
131
+ - "Summarize the latest analyst upgrades and downgrades in the tech sector over the last 6 months."
132
+
133
+ ## Requirements
134
+
135
+ - Python 3.11 or higher
136
+ - Dependencies as listed in `pyproject.toml`, including:
137
+ - mcp
138
+ - yfinance
139
+ - pandas
140
+ - pydantic
141
+ - and other packages for data processing
142
+
143
+ ## Setup
144
+
145
+ 1. Clone this repository:
146
+ ```bash
147
+ git clone https://github.com/Alex2Yang97/yahoo-finance-mcp.git
148
+ cd yahoo-finance-mcp
149
+ ```
150
+
151
+ 2. Create and activate a virtual environment and install dependencies:
152
+ ```bash
153
+ uv venv
154
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
155
+ uv pip install -e .
156
+ ```
157
+
158
+ ## Usage
159
+
160
+ ### Development Mode
161
+
162
+ You can test the server with MCP Inspector by running:
163
+
164
+ ```bash
165
+ uv run server.py
166
+ ```
167
+
168
+ This will start the server and allow you to test the available tools.
169
+
170
+ ### Integration with Claude for Desktop
171
+
172
+ To integrate this server with Claude for Desktop:
173
+
174
+ 1. Install Claude for Desktop to your local machine.
175
+ 2. Install VS Code to your local machine. Then run the following command to open the `claude_desktop_config.json` file:
176
+ - MacOS: `code ~/Library/Application\ Support/Claude/claude_desktop_config.json`
177
+ - Windows: `code $env:AppData\Claude\claude_desktop_config.json`
178
+
179
+ 3. Edit the Claude for Desktop config file, located at:
180
+ - macOS:
181
+ ```json
182
+ {
183
+ "mcpServers": {
184
+ "yfinance": {
185
+ "command": "uv",
186
+ "args": [
187
+ "--directory",
188
+ "/ABSOLUTE/PATH/TO/PARENT/FOLDER/yahoo-finance-mcp",
189
+ "run",
190
+ "server.py"
191
+ ]
192
+ }
193
+ }
194
+ }
195
+ ```
196
+ - Windows:
197
+ ```json
198
+ {
199
+ "mcpServers": {
200
+ "yfinance": {
201
+ "command": "uv",
202
+ "args": [
203
+ "--directory",
204
+ "C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\yahoo-finance-mcp",
205
+ "run",
206
+ "server.py"
207
+ ]
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ - **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.
214
+
215
+ 4. Restart Claude for Desktop
216
+
217
+ ## License
218
+
219
+ MIT License
220
+
221
+ **Original Work**: Copyright (c) 2025 AlexYoung
222
+ **Fork Enhancements**: Copyright (c) 2026 SKTelecom
223
+
224
+ 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.
225
+
226
+ See [LICENSE](LICENSE) file for full details.
227
+
228
+
@@ -0,0 +1,90 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "yfin-mcp"
7
+ version = "0.1.0"
8
+ description = "Enhanced Yahoo Finance MCP Server with intelligent pagination, caching, and LLM-optimized responses"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "fritzprix", email = "innocentevil0914@gmail.com"},
14
+ {name = "AlexYoung (Original Author)"}
15
+ ]
16
+ keywords = [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "yahoo-finance",
20
+ "yfinance",
21
+ "financial-data",
22
+ "stock-market",
23
+ "llm",
24
+ "ai-agent"
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Intended Audience :: Developers",
29
+ "Intended Audience :: Financial and Insurance Industry",
30
+ "License :: OSI Approved :: MIT License",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Topic :: Office/Business :: Financial",
35
+ "Topic :: Software Development :: Libraries :: Python Modules",
36
+ ]
37
+ dependencies = [
38
+ "mcp[cli]>=1.6.0",
39
+ "yfinance>=0.2.62",
40
+ "pandas>=2.0.0",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/fritzprix/yahoo-finance-mcp"
45
+ Repository = "https://github.com/fritzprix/yahoo-finance-mcp"
46
+ Issues = "https://github.com/fritzprix/yahoo-finance-mcp/issues"
47
+ Documentation = "https://github.com/fritzprix/yahoo-finance-mcp#readme"
48
+
49
+ [project.optional-dependencies]
50
+ dev = [
51
+ "pre-commit>=3.6.0",
52
+ "black>=24.2.0",
53
+ "isort>=5.13.2",
54
+ ]
55
+
56
+ [tool.black]
57
+ line-length = 100
58
+ target-version = ['py311']
59
+ include = '\.pyi?$'
60
+
61
+ [tool.isort]
62
+ profile = "black"
63
+ multi_line_output = 3
64
+ include_trailing_comma = true
65
+ force_grid_wrap = 0
66
+ use_parentheses = true
67
+ line_length = 100
68
+
69
+ [tool.flake8]
70
+ max-line-length = 88
71
+ extend-ignore = ["E203"]
72
+ exclude = [".git", "__pycache__", "build", "dist", ".venv"]
73
+
74
+ [tool.mypy]
75
+ python_version = "3.11"
76
+ warn_return_any = true
77
+ warn_unused_configs = true
78
+ disallow_untyped_defs = true
79
+ disallow_incomplete_defs = true
80
+ check_untyped_defs = true
81
+ disallow_untyped_decorators = true
82
+ no_implicit_optional = true
83
+ warn_redundant_casts = true
84
+ warn_unused_ignores = true
85
+ warn_no_return = true
86
+ warn_unreachable = true
87
+
88
+ [tool.bandit]
89
+ exclude_dirs = ["tests"]
90
+ test = ["B101", "B102", "B103", "B104", "B105", "B106", "B107", "B108", "B110", "B112", "B201", "B301", "B302", "B303", "B304", "B305", "B306", "B307", "B308", "B309", "B310", "B311", "B312", "B313", "B314", "B315", "B316", "B317", "B318", "B319", "B320", "B321", "B323", "B324", "B325", "B401", "B402", "B403", "B404", "B405", "B406", "B407", "B408", "B409", "B410", "B411", "B412", "B413", "B501", "B502", "B503", "B504", "B505", "B506", "B507", "B508", "B509", "B601", "B602", "B603", "B604", "B605", "B606", "B607", "B608", "B609", "B610", "B611", "B612", "B613", "B614", "B615", "B616", "B617", "B618", "B619", "B620", "B621", "B622", "B623", "B624", "B625", "B626", "B627", "B628", "B629", "B630", "B631", "B632", "B633", "B634", "B635", "B636", "B637", "B638", "B639", "B640", "B641", "B642", "B643", "B644", "B645", "B646", "B647", "B648", "B649", "B650", "B651", "B652", "B653", "B654", "B655", "B656", "B657", "B658", "B659", "B660", "B661", "B662", "B663", "B664", "B665", "B666", "B667", "B668", "B669", "B670", "B671", "B672", "B673", "B674", "B675", "B676", "B677", "B678", "B679", "B680", "B681", "B682", "B683", "B684", "B685", "B686", "B687", "B688", "B689", "B690", "B691", "B692", "B693", "B694", "B695", "B696", "B697", "B698", "B699", "B700", "B701", "B702", "B703", "B704", "B705", "B706", "B707", "B708", "B709", "B710", "B711", "B712", "B713", "B714", "B715", "B716", "B717", "B718", "B719", "B720", "B721", "B722", "B723", "B724", "B725", "B726", "B727", "B728", "B729", "B730", "B731", "B732", "B733", "B734", "B735", "B736", "B737", "B738", "B739", "B740", "B741", "B742", "B743", "B744", "B745", "B746", "B747", "B748", "B749", "B750", "B751", "B752", "B753", "B754", "B755", "B756", "B757", "B758", "B759", "B760", "B761", "B762", "B763", "B764", "B765", "B766", "B767", "B768", "B769", "B770", "B771", "B772", "B773", "B774", "B775", "B776", "B777", "B778", "B779", "B780", "B781", "B782", "B783", "B784", "B785", "B786", "B787", "B788", "B789", "B790", "B791", "B792", "B793", "B794", "B795", "B796", "B797", "B798", "B799", "B800", "B801", "B802", "B803", "B804", "B805", "B806", "B807", "B808", "B809", "B810", "B811", "B812", "B813", "B814", "B815", "B816", "B817", "B818", "B819", "B820", "B821", "B822", "B823", "B824", "B825", "B826", "B827", "B828", "B829", "B830", "B831", "B832", "B833", "B834", "B835", "B836", "B837", "B838", "B839", "B840", "B841", "B842", "B843", "B844", "B845", "B846", "B847", "B848", "B849", "B850", "B851", "B852", "B853", "B854", "B855", "B856", "B857", "B858", "B859", "B860", "B861", "B862", "B863", "B864", "B865", "B866", "B867", "B868", "B869", "B870", "B871", "B872", "B873", "B874", "B875", "B876", "B877", "B878", "B879", "B880", "B881", "B882", "B883", "B884", "B885", "B886", "B887", "B888", "B889", "B890", "B891", "B892", "B893", "B894", "B895", "B896", "B897", "B898", "B899", "B900", "B901", "B902", "B903", "B904", "B905", "B906", "B907", "B908", "B909", "B910", "B911", "B912", "B913", "B914", "B915", "B916", "B917", "B918", "B919", "B920", "B921", "B922", "B923", "B924", "B925", "B926", "B927", "B928", "B929", "B930", "B931", "B932", "B933", "B934", "B935", "B936", "B937", "B938", "B939", "B940", "B941", "B942", "B943", "B944", "B945", "B946", "B947", "B948", "B949", "B950", "B951", "B952", "B953", "B954", "B955", "B956", "B957", "B958", "B959", "B960", "B961", "B962", "B963", "B964", "B965", "B966", "B967", "B968", "B969", "B970", "B971", "B972", "B973", "B974", "B975", "B976", "B977", "B978", "B979", "B980", "B981", "B982", "B983", "B984", "B985", "B986", "B987", "B988", "B989", "B990", "B991", "B992", "B993", "B994", "B995", "B996", "B997", "B998", "B999"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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
+ ![MCP Demo](assets/demo.gif)
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,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ yfin_mcp.egg-info/PKG-INFO
5
+ yfin_mcp.egg-info/SOURCES.txt
6
+ yfin_mcp.egg-info/dependency_links.txt
7
+ yfin_mcp.egg-info/requires.txt
8
+ yfin_mcp.egg-info/top_level.txt
@@ -0,0 +1,8 @@
1
+ mcp[cli]>=1.6.0
2
+ yfinance>=0.2.62
3
+ pandas>=2.0.0
4
+
5
+ [dev]
6
+ pre-commit>=3.6.0
7
+ black>=24.2.0
8
+ isort>=5.13.2
@@ -0,0 +1 @@
1
+ assets