forecast-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.
Files changed (119) hide show
  1. forecast_mcp-0.1.0/.github/workflows/ci.yml +29 -0
  2. forecast_mcp-0.1.0/.gitignore +8 -0
  3. forecast_mcp-0.1.0/CHANGELOG.md +15 -0
  4. forecast_mcp-0.1.0/CONTRIBUTING.md +22 -0
  5. forecast_mcp-0.1.0/LICENSE +202 -0
  6. forecast_mcp-0.1.0/PKG-INFO +82 -0
  7. forecast_mcp-0.1.0/README.md +56 -0
  8. forecast_mcp-0.1.0/docs/adr/0001-architecture-and-scope.md +39 -0
  9. forecast_mcp-0.1.0/docs/adr/0002-phase1-verification.md +25 -0
  10. forecast_mcp-0.1.0/examples/claude_desktop_config.json +8 -0
  11. forecast_mcp-0.1.0/pyproject.toml +42 -0
  12. forecast_mcp-0.1.0/src/forecast_mcp/__init__.py +2 -0
  13. forecast_mcp-0.1.0/src/forecast_mcp/backends.py +220 -0
  14. forecast_mcp-0.1.0/src/forecast_mcp/models.py +32 -0
  15. forecast_mcp-0.1.0/src/forecast_mcp/server.py +132 -0
  16. forecast_mcp-0.1.0/tests/test_baseline.py +41 -0
  17. forecast_mcp-0.1.0/tests/test_server.py +25 -0
  18. forecast_mcp-0.1.0/timesfm-master/.gitattributes +3 -0
  19. forecast_mcp-0.1.0/timesfm-master/.github/workflows/main.yml +28 -0
  20. forecast_mcp-0.1.0/timesfm-master/.github/workflows/manual_publish.yml +29 -0
  21. forecast_mcp-0.1.0/timesfm-master/.gitignore +11 -0
  22. forecast_mcp-0.1.0/timesfm-master/AGENTS.md +36 -0
  23. forecast_mcp-0.1.0/timesfm-master/LICENSE +202 -0
  24. forecast_mcp-0.1.0/timesfm-master/README.md +127 -0
  25. forecast_mcp-0.1.0/timesfm-master/pyproject.toml +45 -0
  26. forecast_mcp-0.1.0/timesfm-master/requirements.txt +49 -0
  27. forecast_mcp-0.1.0/timesfm-master/src/timesfm/__init__.py +29 -0
  28. forecast_mcp-0.1.0/timesfm-master/src/timesfm/configs.py +105 -0
  29. forecast_mcp-0.1.0/timesfm-master/src/timesfm/flax/__init__.py +13 -0
  30. forecast_mcp-0.1.0/timesfm-master/src/timesfm/flax/dense.py +110 -0
  31. forecast_mcp-0.1.0/timesfm-master/src/timesfm/flax/normalization.py +71 -0
  32. forecast_mcp-0.1.0/timesfm-master/src/timesfm/flax/transformer.py +356 -0
  33. forecast_mcp-0.1.0/timesfm-master/src/timesfm/flax/util.py +107 -0
  34. forecast_mcp-0.1.0/timesfm-master/src/timesfm/timesfm_2p5/timesfm_2p5_base.py +423 -0
  35. forecast_mcp-0.1.0/timesfm-master/src/timesfm/timesfm_2p5/timesfm_2p5_flax.py +602 -0
  36. forecast_mcp-0.1.0/timesfm-master/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py +487 -0
  37. forecast_mcp-0.1.0/timesfm-master/src/timesfm/torch/__init__.py +13 -0
  38. forecast_mcp-0.1.0/timesfm-master/src/timesfm/torch/dense.py +94 -0
  39. forecast_mcp-0.1.0/timesfm-master/src/timesfm/torch/normalization.py +39 -0
  40. forecast_mcp-0.1.0/timesfm-master/src/timesfm/torch/transformer.py +370 -0
  41. forecast_mcp-0.1.0/timesfm-master/src/timesfm/torch/util.py +94 -0
  42. forecast_mcp-0.1.0/timesfm-master/src/timesfm/utils/xreg_lib.py +520 -0
  43. forecast_mcp-0.1.0/timesfm-master/tests/__init__.py +1 -0
  44. forecast_mcp-0.1.0/timesfm-master/tests/test_base_utils.py +168 -0
  45. forecast_mcp-0.1.0/timesfm-master/tests/test_configs.py +196 -0
  46. forecast_mcp-0.1.0/timesfm-master/tests/test_torch_layers.py +262 -0
  47. forecast_mcp-0.1.0/timesfm-master/tests/test_torch_utils.py +336 -0
  48. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/SKILL.md +511 -0
  49. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/anomaly-detection/detect_anomalies.py +524 -0
  50. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/anomaly-detection/output/anomaly_detection.json +448 -0
  51. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/anomaly-detection/output/anomaly_detection.png +0 -0
  52. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/covariates-forecasting/demo_covariates.py +568 -0
  53. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/covariates-forecasting/output/covariates_data.png +0 -0
  54. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/covariates-forecasting/output/covariates_metadata.json +59 -0
  55. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/covariates-forecasting/output/sales_with_covariates.csv +109 -0
  56. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/finetuning/README.md +102 -0
  57. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/finetuning/finetune_lora.py +446 -0
  58. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/README.md +178 -0
  59. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/generate_animation_data.py +147 -0
  60. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/generate_gif.py +248 -0
  61. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/generate_html.py +544 -0
  62. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/output/animation_data.json +5441 -0
  63. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/output/forecast_animation.gif +0 -0
  64. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/output/forecast_output.csv +13 -0
  65. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/output/forecast_output.json +188 -0
  66. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/output/forecast_visualization.png +0 -0
  67. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/output/interactive_forecast.html +5939 -0
  68. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/run_example.sh +53 -0
  69. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/run_forecast.py +167 -0
  70. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/temperature_anomaly.csv +37 -0
  71. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/examples/global-temperature/visualize_forecast.py +123 -0
  72. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/references/api_reference.md +295 -0
  73. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/references/data_preparation.md +272 -0
  74. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/references/system_requirements.md +228 -0
  75. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/scripts/check_system.py +738 -0
  76. forecast_mcp-0.1.0/timesfm-master/timesfm-forecasting/scripts/forecast_csv.py +269 -0
  77. forecast_mcp-0.1.0/timesfm-master/v1/LICENSE +202 -0
  78. forecast_mcp-0.1.0/timesfm-master/v1/README.md +313 -0
  79. forecast_mcp-0.1.0/timesfm-master/v1/TROUBLESHOOTING.md +143 -0
  80. forecast_mcp-0.1.0/timesfm-master/v1/docs/contributing.md +32 -0
  81. forecast_mcp-0.1.0/timesfm-master/v1/experiments/baselines/__init__.py +13 -0
  82. forecast_mcp-0.1.0/timesfm-master/v1/experiments/baselines/timegpt_pipeline.py +259 -0
  83. forecast_mcp-0.1.0/timesfm-master/v1/experiments/extended_benchmarks/README.md +35 -0
  84. forecast_mcp-0.1.0/timesfm-master/v1/experiments/extended_benchmarks/run_timegpt.py +108 -0
  85. forecast_mcp-0.1.0/timesfm-master/v1/experiments/extended_benchmarks/run_timesfm.py +152 -0
  86. forecast_mcp-0.1.0/timesfm-master/v1/experiments/extended_benchmarks/tfm_extended_new.png +0 -0
  87. forecast_mcp-0.1.0/timesfm-master/v1/experiments/extended_benchmarks/tfm_results.png +0 -0
  88. forecast_mcp-0.1.0/timesfm-master/v1/experiments/extended_benchmarks/utils.py +278 -0
  89. forecast_mcp-0.1.0/timesfm-master/v1/experiments/long_horizon_benchmarks/README.md +45 -0
  90. forecast_mcp-0.1.0/timesfm-master/v1/experiments/long_horizon_benchmarks/run_eval.py +238 -0
  91. forecast_mcp-0.1.0/timesfm-master/v1/experiments/long_horizon_benchmarks/tfm_long_horizon.png +0 -0
  92. forecast_mcp-0.1.0/timesfm-master/v1/notebooks/covariates.ipynb +383 -0
  93. forecast_mcp-0.1.0/timesfm-master/v1/notebooks/finetuning.ipynb +619 -0
  94. forecast_mcp-0.1.0/timesfm-master/v1/notebooks/finetuning_torch.ipynb +538 -0
  95. forecast_mcp-0.1.0/timesfm-master/v1/peft/README.md +42 -0
  96. forecast_mcp-0.1.0/timesfm-master/v1/peft/finetune.py +402 -0
  97. forecast_mcp-0.1.0/timesfm-master/v1/peft/finetune.sh +31 -0
  98. forecast_mcp-0.1.0/timesfm-master/v1/peft/usage.ipynb +203 -0
  99. forecast_mcp-0.1.0/timesfm-master/v1/poetry.lock +7282 -0
  100. forecast_mcp-0.1.0/timesfm-master/v1/pyproject.toml +77 -0
  101. forecast_mcp-0.1.0/timesfm-master/v1/src/adapter/__init__.py +18 -0
  102. forecast_mcp-0.1.0/timesfm-master/v1/src/adapter/dora_layers.py +202 -0
  103. forecast_mcp-0.1.0/timesfm-master/v1/src/adapter/lora_layers.py +166 -0
  104. forecast_mcp-0.1.0/timesfm-master/v1/src/adapter/utils.py +487 -0
  105. forecast_mcp-0.1.0/timesfm-master/v1/src/finetuning/__init__.py +0 -0
  106. forecast_mcp-0.1.0/timesfm-master/v1/src/finetuning/finetuning_example.py +403 -0
  107. forecast_mcp-0.1.0/timesfm-master/v1/src/finetuning/finetuning_torch.py +399 -0
  108. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/__init__.py +35 -0
  109. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/data_loader.py +256 -0
  110. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/patched_decoder.py +543 -0
  111. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/pytorch_patched_decoder.py +787 -0
  112. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/time_features.py +215 -0
  113. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/timesfm_base.py +736 -0
  114. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/timesfm_jax.py +353 -0
  115. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/timesfm_torch.py +168 -0
  116. forecast_mcp-0.1.0/timesfm-master/v1/src/timesfm/xreg_lib.py +493 -0
  117. forecast_mcp-0.1.0/timesfm-master/v1/tests/test_data_loader.py +50 -0
  118. forecast_mcp-0.1.0/timesfm-master/v1/tests/test_timesfm.py +91 -0
  119. forecast_mcp-0.1.0/timesfm.zip +0 -0
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v4
17
+ with:
18
+ version: "latest"
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version-file: ".python-version"
24
+
25
+ - name: Install dependencies
26
+ run: uv pip install --system -e ".[dev]"
27
+
28
+ - name: Run tests (Baseline only)
29
+ run: uv run pytest tests/
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .DS_Store
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-05-30
9
+ ### Added
10
+ - Initial release of `forecast-mcp`.
11
+ - Statistical `BaselineBackend` with seasonal-naive and linear trend forecasting.
12
+ - Support for `TimesFMBackend` wrapping Google's TimesFM 2.5 foundation model (requires `timesfm` extra).
13
+ - `forecast` tool to predict future values with uncertainty bands.
14
+ - `list_backends` tool to check which backend is active.
15
+ - `backtest` tool to compare Baseline and TimesFM backends using holdout sets and sMAPE calculation.
@@ -0,0 +1,22 @@
1
+ # Contributing
2
+
3
+ We welcome contributions to `forecast-mcp`!
4
+
5
+ ## Development Setup
6
+
7
+ This project uses [`uv`](https://github.com/astral-sh/uv) for dependency management.
8
+
9
+ 1. Clone the repository.
10
+ 2. Create an environment and install development dependencies:
11
+ ```bash
12
+ uv pip install -e ".[dev]"
13
+ ```
14
+ 3. Run tests using `pytest`:
15
+ ```bash
16
+ pytest tests/
17
+ ```
18
+
19
+ ## Guidelines
20
+ - The core MCP server must always remain usable *without* heavy ML dependencies.
21
+ - Ensure that the `baseline` backend continues to work robustly for basic statistical predictions.
22
+ - The `TimesFMBackend` should be loaded lazily so that it does not block initialization if `timesfm` is not installed.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: forecast-mcp
3
+ Version: 0.1.0
4
+ Summary: An MCP server that gives any AI agent time-series forecasting superpowers (TimesFM 2.5 + statistical baselines).
5
+ Project-URL: Homepage, https://github.com/preetam/forecast-mcp
6
+ Project-URL: Repository, https://github.com/preetam/forecast-mcp
7
+ Project-URL: Issues, https://github.com/preetam/forecast-mcp/issues
8
+ Author: Preetam Ramdhave
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: agent,claude,forecasting,mcp,time-series,timesfm
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: fastmcp>=3.0
17
+ Requires-Dist: numpy>=1.24
18
+ Requires-Dist: pydantic>=2
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=8; extra == 'dev'
21
+ Provides-Extra: ollama
22
+ Requires-Dist: httpx>=0.27; extra == 'ollama'
23
+ Provides-Extra: timesfm
24
+ Requires-Dist: timesfm>=2.5; extra == 'timesfm'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # forecast-mcp
28
+
29
+ [![CI](https://github.com/preetam/forecast-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/preetam/forecast-mcp/actions/workflows/ci.yml)
30
+
31
+ **Give any AI agent time-series forecasting superpowers.**
32
+
33
+ An [MCP](https://modelcontextprotocol.io) server that lets Claude Code, Claude
34
+ Desktop, Cursor, or any MCP client forecast a series of numbers — sales, traffic,
35
+ usage, costs — and reason about the result. Powered by Google's
36
+ [TimesFM 2.5](https://github.com/google-research/timesfm) foundation model, with a
37
+ zero-dependency statistical baseline so it works the moment you install it.
38
+
39
+ ## Why
40
+
41
+ LLM agents can read, write, and run code — but they can't see the future. This
42
+ gives them a clean `forecast` tool. The agent calls it, gets point forecasts +
43
+ uncertainty bands + a compact trend/seasonality summary, and writes the
44
+ explanation and recommendation itself.
45
+
46
+ ## Quickstart (30 seconds)
47
+
48
+ ```bash
49
+ uvx forecast-mcp # runs over stdio for local agents
50
+ ```
51
+
52
+ Add to your Claude Desktop / Claude Code config:
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "forecast": { "command": "uvx", "args": ["forecast-mcp"] }
58
+ }
59
+ }
60
+ ```
61
+
62
+ Then ask your agent: *"Forecast the next 6 months from this revenue data and tell
63
+ me what to expect."*
64
+
65
+ ## Enable the foundation model
66
+
67
+ ```bash
68
+ pip install "forecast-mcp[timesfm]"
69
+ ```
70
+
71
+ The server auto-detects TimesFM and uses it; otherwise it runs the baseline.
72
+
73
+ ## Tools
74
+
75
+ | Tool | What it does |
76
+ |------|--------------|
77
+ | `forecast` | Forecast a single series with optional uncertainty bands. |
78
+ | `list_backends` | Report which engine is active (timesfm / baseline). |
79
+ | `backtest` | Hold out the last N points and compare TimesFM vs baseline performance (MAE/MAPE). |
80
+
81
+ ## License
82
+ Apache-2.0
@@ -0,0 +1,56 @@
1
+ # forecast-mcp
2
+
3
+ [![CI](https://github.com/preetam/forecast-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/preetam/forecast-mcp/actions/workflows/ci.yml)
4
+
5
+ **Give any AI agent time-series forecasting superpowers.**
6
+
7
+ An [MCP](https://modelcontextprotocol.io) server that lets Claude Code, Claude
8
+ Desktop, Cursor, or any MCP client forecast a series of numbers — sales, traffic,
9
+ usage, costs — and reason about the result. Powered by Google's
10
+ [TimesFM 2.5](https://github.com/google-research/timesfm) foundation model, with a
11
+ zero-dependency statistical baseline so it works the moment you install it.
12
+
13
+ ## Why
14
+
15
+ LLM agents can read, write, and run code — but they can't see the future. This
16
+ gives them a clean `forecast` tool. The agent calls it, gets point forecasts +
17
+ uncertainty bands + a compact trend/seasonality summary, and writes the
18
+ explanation and recommendation itself.
19
+
20
+ ## Quickstart (30 seconds)
21
+
22
+ ```bash
23
+ uvx forecast-mcp # runs over stdio for local agents
24
+ ```
25
+
26
+ Add to your Claude Desktop / Claude Code config:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "forecast": { "command": "uvx", "args": ["forecast-mcp"] }
32
+ }
33
+ }
34
+ ```
35
+
36
+ Then ask your agent: *"Forecast the next 6 months from this revenue data and tell
37
+ me what to expect."*
38
+
39
+ ## Enable the foundation model
40
+
41
+ ```bash
42
+ pip install "forecast-mcp[timesfm]"
43
+ ```
44
+
45
+ The server auto-detects TimesFM and uses it; otherwise it runs the baseline.
46
+
47
+ ## Tools
48
+
49
+ | Tool | What it does |
50
+ |------|--------------|
51
+ | `forecast` | Forecast a single series with optional uncertainty bands. |
52
+ | `list_backends` | Report which engine is active (timesfm / baseline). |
53
+ | `backtest` | Hold out the last N points and compare TimesFM vs baseline performance (MAE/MAPE). |
54
+
55
+ ## License
56
+ Apache-2.0
@@ -0,0 +1,39 @@
1
+ # ADR 0001 — Architecture and Scope
2
+
3
+ **Status:** Accepted · **Date:** 2026-05-29
4
+
5
+ ## Context
6
+ We want an open-source tool that gives any MCP-compatible AI agent (Claude Code,
7
+ Claude Desktop, Cursor, VS Code) the ability to forecast time series, powered by
8
+ Google's TimesFM 2.5 foundation model. The goal is fast adoption in the developer
9
+ community, which later funnels into a hosted API and consulting.
10
+
11
+ ## Decisions
12
+
13
+ 1. **Transport: MCP via FastMCP (3.x).** FastMCP is the de-facto standard and
14
+ powers the majority of MCP servers; decorator-based tools keep boilerplate low.
15
+ Default transport is stdio (for local agents); HTTP is available for hosting.
16
+
17
+ 2. **Distribution: `uvx`-runnable, zero-config.** Adoption dies on setup friction.
18
+ A user must be able to add one line to their agent config and have it work.
19
+
20
+ 3. **The agent is the LLM.** The server returns *numbers + a compact context
21
+ summary* (trend, seasonality, volatility). The calling agent writes the
22
+ natural-language explanation and recommendation. We do **not** bundle an LLM in
23
+ the core. This keeps dependencies light, which is what lets the tool spread.
24
+
25
+ 4. **Two backends behind one interface.** A pure-NumPy `BaselineBackend` runs
26
+ instantly with no heavy deps; the `TimesFMBackend` (optional `timesfm` extra) is
27
+ loaded lazily. The server auto-selects TimesFM when present, else the baseline.
28
+ The tool always returns something useful.
29
+
30
+ 5. **Local Ollama LLM = optional offline mode, not core.** A small local model is
31
+ only useful when there is *no* agent in the loop (e.g. CLI use). Deferred to a
32
+ later phase as an opt-in `explain` tool.
33
+
34
+ ## Consequences
35
+ - Anyone can try the server in ~30 seconds; the foundation model is a power-up,
36
+ not a prerequisite.
37
+ - TimesFM 2.5's inference API differs from 1.x/2.0, so `TimesFMBackend` ships as a
38
+ stub that delegates to the baseline until wired in Phase 2.
39
+ - The same forecasting core is reusable inside a future Shopify app (idea A).
@@ -0,0 +1,25 @@
1
+ # ADR 0002 — Phase 1 Verification
2
+
3
+ **Status:** Accepted
4
+ **Date:** 2026-05-29
5
+
6
+ ## Context
7
+ As part of the initial launch of the `forecast-mcp` server, Phase 1 was scoped to verify the core architecture (ADR 0001) using the pure-NumPy baseline fallback mechanism. The tests verify that the server can boot and serve MCP clients immediately without the heavy machine learning dependencies (TimesFM 2.5), maintaining zero-friction adoption.
8
+
9
+ ## Actions Taken
10
+ 1. Set up the local environment in a Python 3.10 virtual environment using `uv venv` and `uv pip install -e ".[dev]"`.
11
+ 2. Executed the test suite using `pytest tests/`.
12
+ 3. Verified the MCP server manually via Python integration (simulating the FastMCP inspector).
13
+ 4. Tested the `forecast` tool on a 36-point sample seasonal series with `horizon=6` and `quantiles=[0.9]`.
14
+ 5. Tested the `list_backends` tool.
15
+
16
+ ## Results & Quirks
17
+ - **Test Suite:** Passed (5/5).
18
+ - **Tool Listing:** Both `forecast` and `list_backends` were successfully exposed as MCP tools.
19
+ - **Backend Detection:** `list_backends` correctly fell back to the `baseline` engine and provided the correct installation hint for TimesFM.
20
+ - **Forecast Generation:**
21
+ - The series successfully extrapolated 6 points ahead.
22
+ - Uncertainty bands widened correctly with the horizon.
23
+ - `context` reliably reported trend and seasonality (e.g. `{'n_observations': 36, 'detected_season_length': 2, 'trend': 'rising', 'trend_pct_per_step': 4.21, 'last_value': 63.0, 'mean': 35.5556, 'volatility': 1.2371}`).
24
+ - **Quirks/Notes:**
25
+ - Since `timesfm` >= 2.5 is not formally published on standard PyPI (or requires fetching from Google Research's github), users running `pip install "forecast-mcp[timesfm]"` might experience dependency resolution failures unless we point to the repository or clarify the installation instructions in the README. We will continue respecting the current setup and lazy load approach in Phase 2.
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "forecast": {
4
+ "command": "uvx",
5
+ "args": ["forecast-mcp"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "forecast-mcp"
3
+ version = "0.1.0"
4
+ description = "An MCP server that gives any AI agent time-series forecasting superpowers (TimesFM 2.5 + statistical baselines)."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "Apache-2.0" }
8
+ authors = [{ name = "Preetam Ramdhave" }]
9
+ keywords = ["mcp", "forecasting", "time-series", "timesfm", "agent", "claude"]
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "License :: OSI Approved :: Apache Software License",
13
+ "Operating System :: OS Independent",
14
+ ]
15
+
16
+ dependencies = [
17
+ "fastmcp>=3.0",
18
+ "numpy>=1.24",
19
+ "pydantic>=2",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/preetam/forecast-mcp"
24
+ Repository = "https://github.com/preetam/forecast-mcp"
25
+ Issues = "https://github.com/preetam/forecast-mcp/issues"
26
+
27
+ [project.optional-dependencies]
28
+ # The heavy ML backend. Kept optional so the server runs instantly without it.
29
+ timesfm = ["timesfm>=2.5"]
30
+ # Optional local-LLM narrative mode (talks to a running Ollama instance via HTTP).
31
+ ollama = ["httpx>=0.27"]
32
+ dev = ["pytest>=8"]
33
+
34
+ [project.scripts]
35
+ forecast-mcp = "forecast_mcp.server:main"
36
+
37
+ [build-system]
38
+ requires = ["hatchling"]
39
+ build-backend = "hatchling.build"
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["src/forecast_mcp"]
@@ -0,0 +1,2 @@
1
+ """forecast-mcp: time-series forecasting tools for AI agents over MCP."""
2
+ __version__ = "0.1.0"