alloc-context 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 (135) hide show
  1. alloc_context-0.1.0/LICENSE +21 -0
  2. alloc_context-0.1.0/PKG-INFO +154 -0
  3. alloc_context-0.1.0/README.md +112 -0
  4. alloc_context-0.1.0/alloc_context.egg-info/PKG-INFO +154 -0
  5. alloc_context-0.1.0/alloc_context.egg-info/SOURCES.txt +133 -0
  6. alloc_context-0.1.0/alloc_context.egg-info/dependency_links.txt +1 -0
  7. alloc_context-0.1.0/alloc_context.egg-info/entry_points.txt +4 -0
  8. alloc_context-0.1.0/alloc_context.egg-info/requires.txt +20 -0
  9. alloc_context-0.1.0/alloc_context.egg-info/top_level.txt +1 -0
  10. alloc_context-0.1.0/alloccontext/__init__.py +3 -0
  11. alloc_context-0.1.0/alloccontext/__main__.py +149 -0
  12. alloc_context-0.1.0/alloccontext/config.py +415 -0
  13. alloc_context-0.1.0/alloccontext/horizon.py +30 -0
  14. alloc_context-0.1.0/alloccontext/ingest/__init__.py +1 -0
  15. alloc_context-0.1.0/alloccontext/ingest/cf_benchmarks.py +38 -0
  16. alloc_context-0.1.0/alloccontext/ingest/cf_history.py +65 -0
  17. alloc_context-0.1.0/alloccontext/ingest/coinbase_client.py +234 -0
  18. alloc_context-0.1.0/alloccontext/ingest/coinbase_portfolio.py +53 -0
  19. alloc_context-0.1.0/alloccontext/ingest/coingecko.py +148 -0
  20. alloc_context-0.1.0/alloccontext/ingest/coinmarketcap.py +135 -0
  21. alloc_context-0.1.0/alloccontext/ingest/env_keys.py +12 -0
  22. alloc_context-0.1.0/alloccontext/ingest/etf_flows.py +282 -0
  23. alloc_context-0.1.0/alloccontext/ingest/exchange/__init__.py +4 -0
  24. alloc_context-0.1.0/alloccontext/ingest/exchange/coinbase_adapter.py +64 -0
  25. alloc_context-0.1.0/alloccontext/ingest/exchange/kraken_adapter.py +66 -0
  26. alloc_context-0.1.0/alloccontext/ingest/exchange/live.py +95 -0
  27. alloc_context-0.1.0/alloccontext/ingest/exchange/portfolio.py +8 -0
  28. alloc_context-0.1.0/alloccontext/ingest/exchange/registry.py +27 -0
  29. alloc_context-0.1.0/alloccontext/ingest/exchange/types.py +5 -0
  30. alloc_context-0.1.0/alloccontext/ingest/exchange_http.py +28 -0
  31. alloc_context-0.1.0/alloccontext/ingest/fear_greed.py +89 -0
  32. alloc_context-0.1.0/alloccontext/ingest/fred.py +138 -0
  33. alloc_context-0.1.0/alloccontext/ingest/http_errors.py +29 -0
  34. alloc_context-0.1.0/alloccontext/ingest/kalshi.py +84 -0
  35. alloc_context-0.1.0/alloccontext/ingest/kalshi_api.py +199 -0
  36. alloc_context-0.1.0/alloccontext/ingest/kalshi_client.py +95 -0
  37. alloc_context-0.1.0/alloccontext/ingest/kalshi_files.py +44 -0
  38. alloc_context-0.1.0/alloccontext/ingest/kalshi_state.py +67 -0
  39. alloc_context-0.1.0/alloccontext/ingest/kraken_client.py +177 -0
  40. alloc_context-0.1.0/alloccontext/ingest/kraken_portfolio.py +161 -0
  41. alloc_context-0.1.0/alloccontext/ingest/macro_calendar.py +310 -0
  42. alloc_context-0.1.0/alloccontext/ingest/macro_normalize.py +98 -0
  43. alloc_context-0.1.0/alloccontext/ingest/market_snapshots.py +113 -0
  44. alloc_context-0.1.0/alloccontext/ingest/outcome.py +110 -0
  45. alloc_context-0.1.0/alloccontext/ingest/parse_helpers.py +23 -0
  46. alloc_context-0.1.0/alloccontext/ingest/runner.py +148 -0
  47. alloc_context-0.1.0/alloccontext/mcp/__init__.py +1 -0
  48. alloc_context-0.1.0/alloccontext/mcp/assets.py +153 -0
  49. alloc_context-0.1.0/alloccontext/mcp/bazaar.py +630 -0
  50. alloc_context-0.1.0/alloccontext/mcp/contracts.py +286 -0
  51. alloc_context-0.1.0/alloccontext/mcp/handlers.py +487 -0
  52. alloc_context-0.1.0/alloccontext/mcp/http.py +250 -0
  53. alloc_context-0.1.0/alloccontext/mcp/payment_middleware.py +211 -0
  54. alloc_context-0.1.0/alloccontext/mcp/server.py +319 -0
  55. alloc_context-0.1.0/alloccontext/mcp/staleness.py +30 -0
  56. alloc_context-0.1.0/alloccontext/mcp/validation.py +56 -0
  57. alloc_context-0.1.0/alloccontext/mcp/x402_bazaar_dynamic.py +104 -0
  58. alloc_context-0.1.0/alloccontext/mcp/x402_config.py +131 -0
  59. alloc_context-0.1.0/alloccontext/mcp/x402_pricing.py +55 -0
  60. alloc_context-0.1.0/alloccontext/mcp/x402_stables.py +179 -0
  61. alloc_context-0.1.0/alloccontext/rollup/__init__.py +1 -0
  62. alloc_context-0.1.0/alloccontext/rollup/band.py +50 -0
  63. alloc_context-0.1.0/alloccontext/rollup/breadth.py +45 -0
  64. alloc_context-0.1.0/alloccontext/rollup/cf_math.py +103 -0
  65. alloc_context-0.1.0/alloccontext/rollup/cluster.py +149 -0
  66. alloc_context-0.1.0/alloccontext/rollup/cluster_config.py +86 -0
  67. alloc_context-0.1.0/alloccontext/rollup/comparison.py +67 -0
  68. alloc_context-0.1.0/alloccontext/rollup/context.py +118 -0
  69. alloc_context-0.1.0/alloccontext/rollup/delta.py +109 -0
  70. alloc_context-0.1.0/alloccontext/rollup/etf.py +113 -0
  71. alloc_context-0.1.0/alloccontext/rollup/fear_greed.py +61 -0
  72. alloc_context-0.1.0/alloccontext/rollup/macro.py +185 -0
  73. alloc_context-0.1.0/alloccontext/rollup/portfolio.py +137 -0
  74. alloc_context-0.1.0/alloccontext/rollup/rebalance.py +125 -0
  75. alloc_context-0.1.0/alloccontext/rollup/regime.py +188 -0
  76. alloc_context-0.1.0/alloccontext/rollup/sentiment.py +118 -0
  77. alloc_context-0.1.0/alloccontext/rollup/snapshots.py +64 -0
  78. alloc_context-0.1.0/alloccontext/rollup/tape.py +176 -0
  79. alloc_context-0.1.0/alloccontext/status_report.py +321 -0
  80. alloc_context-0.1.0/alloccontext/store/__init__.py +0 -0
  81. alloc_context-0.1.0/alloccontext/store/db.py +216 -0
  82. alloc_context-0.1.0/alloccontext/store/jsonutil.py +10 -0
  83. alloc_context-0.1.0/alloccontext/store/meta.py +20 -0
  84. alloc_context-0.1.0/alloccontext/store/retention.py +63 -0
  85. alloc_context-0.1.0/alloccontext/store/status.py +89 -0
  86. alloc_context-0.1.0/alloccontext/timeutil.py +11 -0
  87. alloc_context-0.1.0/alloccontext/x402_production_check.py +193 -0
  88. alloc_context-0.1.0/alloccontext/x402_smoke_redact.py +41 -0
  89. alloc_context-0.1.0/pyproject.toml +77 -0
  90. alloc_context-0.1.0/setup.cfg +4 -0
  91. alloc_context-0.1.0/tests/test_adr005_ingest.py +59 -0
  92. alloc_context-0.1.0/tests/test_backup_sqlite.py +76 -0
  93. alloc_context-0.1.0/tests/test_bump_version.py +84 -0
  94. alloc_context-0.1.0/tests/test_coinbase_portfolio.py +166 -0
  95. alloc_context-0.1.0/tests/test_context_snapshots.py +120 -0
  96. alloc_context-0.1.0/tests/test_db_schema.py +60 -0
  97. alloc_context-0.1.0/tests/test_deploy.py +58 -0
  98. alloc_context-0.1.0/tests/test_dev_stack.py +61 -0
  99. alloc_context-0.1.0/tests/test_etf.py +84 -0
  100. alloc_context-0.1.0/tests/test_exchanges_config.py +176 -0
  101. alloc_context-0.1.0/tests/test_fear_greed.py +24 -0
  102. alloc_context-0.1.0/tests/test_fred.py +134 -0
  103. alloc_context-0.1.0/tests/test_horizon.py +39 -0
  104. alloc_context-0.1.0/tests/test_ingest_outcome.py +99 -0
  105. alloc_context-0.1.0/tests/test_ingest_runner.py +174 -0
  106. alloc_context-0.1.0/tests/test_kalshi_api.py +100 -0
  107. alloc_context-0.1.0/tests/test_kraken_portfolio.py +160 -0
  108. alloc_context-0.1.0/tests/test_macro.py +204 -0
  109. alloc_context-0.1.0/tests/test_market_breadth.py +188 -0
  110. alloc_context-0.1.0/tests/test_mcp_assets_regime.py +131 -0
  111. alloc_context-0.1.0/tests/test_mcp_bazaar.py +130 -0
  112. alloc_context-0.1.0/tests/test_mcp_contracts.py +186 -0
  113. alloc_context-0.1.0/tests/test_mcp_freshness.py +18 -0
  114. alloc_context-0.1.0/tests/test_mcp_handlers.py +46 -0
  115. alloc_context-0.1.0/tests/test_mcp_health.py +27 -0
  116. alloc_context-0.1.0/tests/test_mcp_http_lifecycle.py +74 -0
  117. alloc_context-0.1.0/tests/test_mcp_live_portfolio.py +64 -0
  118. alloc_context-0.1.0/tests/test_mcp_server.py +26 -0
  119. alloc_context-0.1.0/tests/test_mcp_validation.py +34 -0
  120. alloc_context-0.1.0/tests/test_mcp_x402.py +139 -0
  121. alloc_context-0.1.0/tests/test_mcp_x402_http.py +95 -0
  122. alloc_context-0.1.0/tests/test_mcp_x402_pricing.py +176 -0
  123. alloc_context-0.1.0/tests/test_mcp_x402_stables.py +90 -0
  124. alloc_context-0.1.0/tests/test_qa_ingest_store.py +163 -0
  125. alloc_context-0.1.0/tests/test_rebalance.py +56 -0
  126. alloc_context-0.1.0/tests/test_rollup.py +95 -0
  127. alloc_context-0.1.0/tests/test_scaffold.py +37 -0
  128. alloc_context-0.1.0/tests/test_script_runtime.py +27 -0
  129. alloc_context-0.1.0/tests/test_security_hardening.py +103 -0
  130. alloc_context-0.1.0/tests/test_snapshots_and_delta.py +95 -0
  131. alloc_context-0.1.0/tests/test_status_report.py +118 -0
  132. alloc_context-0.1.0/tests/test_workflows.py +102 -0
  133. alloc_context-0.1.0/tests/test_x402_bazaar_dynamic.py +97 -0
  134. alloc_context-0.1.0/tests/test_x402_production_check.py +118 -0
  135. alloc_context-0.1.0/tests/test_x402_smoke_redact.py +27 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AllocContext contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: alloc-context
3
+ Version: 0.1.0
4
+ Summary: AllocContext — BTC/ETH allocation context, drift, and rebalance facts
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/negillett/alloc-context
7
+ Project-URL: Documentation, https://github.com/negillett/alloc-context/blob/main/docs/agent-integration.md
8
+ Project-URL: Repository, https://github.com/negillett/alloc-context
9
+ Project-URL: Issues, https://github.com/negillett/alloc-context/issues
10
+ Project-URL: Changelog, https://github.com/negillett/alloc-context/releases
11
+ Project-URL: MCP Server, https://mcp.alloc-context.com/mcp
12
+ Keywords: mcp,x402,bitcoin,ethereum,portfolio,allocation,agents,crypto,rebalance
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Office/Business :: Financial
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: requests>=2.31
26
+ Requires-Dist: PyJWT>=2.8
27
+ Requires-Dist: cryptography>=42.0
28
+ Provides-Extra: mcp
29
+ Requires-Dist: mcp>=1.6; extra == "mcp"
30
+ Provides-Extra: hosted
31
+ Requires-Dist: mcp>=1.6; extra == "hosted"
32
+ Requires-Dist: x402[evm,fastapi]>=2.0; extra == "hosted"
33
+ Requires-Dist: cdp-sdk>=1.46; extra == "hosted"
34
+ Requires-Dist: uvicorn[standard]>=0.30; extra == "hosted"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0; extra == "dev"
37
+ Requires-Dist: mcp>=1.6; extra == "dev"
38
+ Requires-Dist: x402[evm,fastapi]>=2.0; extra == "dev"
39
+ Requires-Dist: cdp-sdk>=1.46; extra == "dev"
40
+ Requires-Dist: uvicorn[standard]>=0.30; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # AllocContext
44
+
45
+ **Allocation context for BTC/ETH** — drift, band checks, USD rebalance moves,
46
+ and a fused market backdrop (Fear & Greed, Kalshi, ETF flows, macro) as
47
+ deterministic JSON over MCP.
48
+
49
+ The product is an **agent-native MCP API** with x402 pay-per-call on Base —
50
+ see [docs/mcp.md](docs/mcp.md).
51
+
52
+ ## Hosted MCP (production)
53
+
54
+ Try the public endpoint without self-hosting:
55
+
56
+ | | |
57
+ |--|--|
58
+ | **URL** | `https://mcp.alloc-context.com/mcp` |
59
+ | **Discovery** | [llms.txt](https://mcp.alloc-context.com/llms.txt), [x402 manifest](https://mcp.alloc-context.com/.well-known/x402.json) |
60
+ | **Pricing** | **$0.02** cached context/math · **$0.05** live ingest or portfolio |
61
+ | **Payment** | x402 on Base — USDC or EURC |
62
+
63
+ Agents find the service via [CDP Bazaar](docs/mcp-discovery.md). Integration
64
+ guide: [docs/agent-integration.md](docs/agent-integration.md). Example JSON:
65
+ [docs/examples.md](docs/examples.md).
66
+
67
+ **Try free locally** (no payment): `./scripts/dev-up.sh` — see
68
+ [docs/local-dev.md](docs/local-dev.md).
69
+
70
+ Optional live portfolio reads use read-only exchange credentials passed in
71
+ each request. Not financial advice.
72
+
73
+ ```text
74
+ ingest → store → rollup → MCP tools (+ optional x402 HTTP)
75
+ ```
76
+
77
+ This package is **facts and MCP only** — ingest, rollups, and agent tools.
78
+ Email, LLM synthesis, and alert delivery are out of scope for this repository.
79
+
80
+ ## Try it locally
81
+
82
+ ```bash
83
+ git clone git@github.com:negillett/alloc-context.git
84
+ cd alloc-context
85
+ python3.11 -m venv .venv && source .venv/bin/activate
86
+ pip install -e ".[dev]"
87
+ cp .env.example .env # fill locally; never commit
88
+ cp config/config.example.yaml config/config.yaml
89
+
90
+ python -m alloccontext ingest --dry-run
91
+ python -m alloccontext rollup --scope daily --stdout
92
+ pytest
93
+ ```
94
+
95
+ **MCP (stdio):** `pip install -e ".[mcp]"` then `alloc-context mcp`.
96
+ See [docs/cursor-mcp.md](docs/cursor-mcp.md).
97
+
98
+ **Hosted MCP + x402:** `pip install -e ".[hosted]"` then
99
+ `alloc-context mcp --transport http --x402`. See [docs/mcp-http.md](docs/mcp-http.md).
100
+
101
+ **Local dev stack (internal MCP on :8001):** `./scripts/dev-up.sh`.
102
+ See [docs/local-dev.md](docs/local-dev.md).
103
+
104
+ CLI entry point: `alloc-context` (same as `python -m alloccontext`).
105
+
106
+ ## Commands
107
+
108
+ | Command | Purpose |
109
+ |---------|---------|
110
+ | `python -m alloccontext ingest` | Pull configured sources → SQLite |
111
+ | `python -m alloccontext rollup --scope daily --stdout` | ContextBundle JSON (facts) |
112
+ | `python -m alloccontext status` | Per-source ingest ages, snapshots, MCP `/health` |
113
+ | `alloc-context mcp` | MCP server (stdio or HTTP) |
114
+
115
+ ## MCP tools
116
+
117
+ | Tool | Purpose |
118
+ |------|---------|
119
+ | `get_context_bundle` | Full ContextBundle — portfolio, market, sentiment, macro, delta, regime |
120
+ | `get_market_context` | Sentiment, macro, ETF, breadth, and market fields (no portfolio) |
121
+ | `get_context_at` | Saved snapshot from ingest history at a given `as_of` |
122
+ | `get_context_delta` | Notable shifts between two saved snapshots |
123
+ | `get_rebalance_plan` | USD rebalance moves from allocation, target, and NAV |
124
+ | `check_allocation_band` | Drift vs target and whether allocation is outside the band |
125
+ | `check_allocation_bands` | Batch band checks for multiple target scenarios |
126
+ | `get_portfolio_state` | Live NAV and allocation from Kraken or Coinbase (credentials in request) |
127
+
128
+ See [docs/mcp.md](docs/mcp.md) for arguments, pricing, and resources.
129
+
130
+ ## Documentation
131
+
132
+ | Document | Purpose |
133
+ |----------|---------|
134
+ | [docs/mcp.md](docs/mcp.md) | MCP tools and x402 |
135
+ | [docs/mcp-http.md](docs/mcp-http.md) | HTTP MCP + x402 setup |
136
+ | [docs/mcp-discovery.md](docs/mcp-discovery.md) | Bazaar and agent discovery |
137
+ | [docs/distribution.md](docs/distribution.md) | GitHub, PyPI, MCP Registry, directories |
138
+ | [docs/agent-integration.md](docs/agent-integration.md) | Paid HTTP MCP + Bazaar for agents |
139
+ | [docs/cursor-mcp.md](docs/cursor-mcp.md) | Cursor stdio MCP |
140
+ | [docs/examples.md](docs/examples.md) | Sample tool JSON (redacted) |
141
+ | [docs/context-bundle.md](docs/context-bundle.md) | ContextBundle schema |
142
+ | [docs/architecture.md](docs/architecture.md) | Pipeline and trust boundaries |
143
+ | [docs/data-sources.md](docs/data-sources.md) | Ingest sources |
144
+ | [docs/self-hosting.md](docs/self-hosting.md) | Optional Linux/systemd ingest + MCP |
145
+ | [docs/local-dev.md](docs/local-dev.md) | Local internal MCP + dev ingest |
146
+
147
+ ## Contributing
148
+
149
+ GitHub Issues are welcome for bugs, schema feedback, and MCP API suggestions.
150
+ Unsolicited pull requests are not expected — see [CONTRIBUTING.md](CONTRIBUTING.md).
151
+
152
+ ## License
153
+
154
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,112 @@
1
+ # AllocContext
2
+
3
+ **Allocation context for BTC/ETH** — drift, band checks, USD rebalance moves,
4
+ and a fused market backdrop (Fear & Greed, Kalshi, ETF flows, macro) as
5
+ deterministic JSON over MCP.
6
+
7
+ The product is an **agent-native MCP API** with x402 pay-per-call on Base —
8
+ see [docs/mcp.md](docs/mcp.md).
9
+
10
+ ## Hosted MCP (production)
11
+
12
+ Try the public endpoint without self-hosting:
13
+
14
+ | | |
15
+ |--|--|
16
+ | **URL** | `https://mcp.alloc-context.com/mcp` |
17
+ | **Discovery** | [llms.txt](https://mcp.alloc-context.com/llms.txt), [x402 manifest](https://mcp.alloc-context.com/.well-known/x402.json) |
18
+ | **Pricing** | **$0.02** cached context/math · **$0.05** live ingest or portfolio |
19
+ | **Payment** | x402 on Base — USDC or EURC |
20
+
21
+ Agents find the service via [CDP Bazaar](docs/mcp-discovery.md). Integration
22
+ guide: [docs/agent-integration.md](docs/agent-integration.md). Example JSON:
23
+ [docs/examples.md](docs/examples.md).
24
+
25
+ **Try free locally** (no payment): `./scripts/dev-up.sh` — see
26
+ [docs/local-dev.md](docs/local-dev.md).
27
+
28
+ Optional live portfolio reads use read-only exchange credentials passed in
29
+ each request. Not financial advice.
30
+
31
+ ```text
32
+ ingest → store → rollup → MCP tools (+ optional x402 HTTP)
33
+ ```
34
+
35
+ This package is **facts and MCP only** — ingest, rollups, and agent tools.
36
+ Email, LLM synthesis, and alert delivery are out of scope for this repository.
37
+
38
+ ## Try it locally
39
+
40
+ ```bash
41
+ git clone git@github.com:negillett/alloc-context.git
42
+ cd alloc-context
43
+ python3.11 -m venv .venv && source .venv/bin/activate
44
+ pip install -e ".[dev]"
45
+ cp .env.example .env # fill locally; never commit
46
+ cp config/config.example.yaml config/config.yaml
47
+
48
+ python -m alloccontext ingest --dry-run
49
+ python -m alloccontext rollup --scope daily --stdout
50
+ pytest
51
+ ```
52
+
53
+ **MCP (stdio):** `pip install -e ".[mcp]"` then `alloc-context mcp`.
54
+ See [docs/cursor-mcp.md](docs/cursor-mcp.md).
55
+
56
+ **Hosted MCP + x402:** `pip install -e ".[hosted]"` then
57
+ `alloc-context mcp --transport http --x402`. See [docs/mcp-http.md](docs/mcp-http.md).
58
+
59
+ **Local dev stack (internal MCP on :8001):** `./scripts/dev-up.sh`.
60
+ See [docs/local-dev.md](docs/local-dev.md).
61
+
62
+ CLI entry point: `alloc-context` (same as `python -m alloccontext`).
63
+
64
+ ## Commands
65
+
66
+ | Command | Purpose |
67
+ |---------|---------|
68
+ | `python -m alloccontext ingest` | Pull configured sources → SQLite |
69
+ | `python -m alloccontext rollup --scope daily --stdout` | ContextBundle JSON (facts) |
70
+ | `python -m alloccontext status` | Per-source ingest ages, snapshots, MCP `/health` |
71
+ | `alloc-context mcp` | MCP server (stdio or HTTP) |
72
+
73
+ ## MCP tools
74
+
75
+ | Tool | Purpose |
76
+ |------|---------|
77
+ | `get_context_bundle` | Full ContextBundle — portfolio, market, sentiment, macro, delta, regime |
78
+ | `get_market_context` | Sentiment, macro, ETF, breadth, and market fields (no portfolio) |
79
+ | `get_context_at` | Saved snapshot from ingest history at a given `as_of` |
80
+ | `get_context_delta` | Notable shifts between two saved snapshots |
81
+ | `get_rebalance_plan` | USD rebalance moves from allocation, target, and NAV |
82
+ | `check_allocation_band` | Drift vs target and whether allocation is outside the band |
83
+ | `check_allocation_bands` | Batch band checks for multiple target scenarios |
84
+ | `get_portfolio_state` | Live NAV and allocation from Kraken or Coinbase (credentials in request) |
85
+
86
+ See [docs/mcp.md](docs/mcp.md) for arguments, pricing, and resources.
87
+
88
+ ## Documentation
89
+
90
+ | Document | Purpose |
91
+ |----------|---------|
92
+ | [docs/mcp.md](docs/mcp.md) | MCP tools and x402 |
93
+ | [docs/mcp-http.md](docs/mcp-http.md) | HTTP MCP + x402 setup |
94
+ | [docs/mcp-discovery.md](docs/mcp-discovery.md) | Bazaar and agent discovery |
95
+ | [docs/distribution.md](docs/distribution.md) | GitHub, PyPI, MCP Registry, directories |
96
+ | [docs/agent-integration.md](docs/agent-integration.md) | Paid HTTP MCP + Bazaar for agents |
97
+ | [docs/cursor-mcp.md](docs/cursor-mcp.md) | Cursor stdio MCP |
98
+ | [docs/examples.md](docs/examples.md) | Sample tool JSON (redacted) |
99
+ | [docs/context-bundle.md](docs/context-bundle.md) | ContextBundle schema |
100
+ | [docs/architecture.md](docs/architecture.md) | Pipeline and trust boundaries |
101
+ | [docs/data-sources.md](docs/data-sources.md) | Ingest sources |
102
+ | [docs/self-hosting.md](docs/self-hosting.md) | Optional Linux/systemd ingest + MCP |
103
+ | [docs/local-dev.md](docs/local-dev.md) | Local internal MCP + dev ingest |
104
+
105
+ ## Contributing
106
+
107
+ GitHub Issues are welcome for bugs, schema feedback, and MCP API suggestions.
108
+ Unsolicited pull requests are not expected — see [CONTRIBUTING.md](CONTRIBUTING.md).
109
+
110
+ ## License
111
+
112
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: alloc-context
3
+ Version: 0.1.0
4
+ Summary: AllocContext — BTC/ETH allocation context, drift, and rebalance facts
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/negillett/alloc-context
7
+ Project-URL: Documentation, https://github.com/negillett/alloc-context/blob/main/docs/agent-integration.md
8
+ Project-URL: Repository, https://github.com/negillett/alloc-context
9
+ Project-URL: Issues, https://github.com/negillett/alloc-context/issues
10
+ Project-URL: Changelog, https://github.com/negillett/alloc-context/releases
11
+ Project-URL: MCP Server, https://mcp.alloc-context.com/mcp
12
+ Keywords: mcp,x402,bitcoin,ethereum,portfolio,allocation,agents,crypto,rebalance
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Office/Business :: Financial
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: requests>=2.31
26
+ Requires-Dist: PyJWT>=2.8
27
+ Requires-Dist: cryptography>=42.0
28
+ Provides-Extra: mcp
29
+ Requires-Dist: mcp>=1.6; extra == "mcp"
30
+ Provides-Extra: hosted
31
+ Requires-Dist: mcp>=1.6; extra == "hosted"
32
+ Requires-Dist: x402[evm,fastapi]>=2.0; extra == "hosted"
33
+ Requires-Dist: cdp-sdk>=1.46; extra == "hosted"
34
+ Requires-Dist: uvicorn[standard]>=0.30; extra == "hosted"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0; extra == "dev"
37
+ Requires-Dist: mcp>=1.6; extra == "dev"
38
+ Requires-Dist: x402[evm,fastapi]>=2.0; extra == "dev"
39
+ Requires-Dist: cdp-sdk>=1.46; extra == "dev"
40
+ Requires-Dist: uvicorn[standard]>=0.30; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # AllocContext
44
+
45
+ **Allocation context for BTC/ETH** — drift, band checks, USD rebalance moves,
46
+ and a fused market backdrop (Fear & Greed, Kalshi, ETF flows, macro) as
47
+ deterministic JSON over MCP.
48
+
49
+ The product is an **agent-native MCP API** with x402 pay-per-call on Base —
50
+ see [docs/mcp.md](docs/mcp.md).
51
+
52
+ ## Hosted MCP (production)
53
+
54
+ Try the public endpoint without self-hosting:
55
+
56
+ | | |
57
+ |--|--|
58
+ | **URL** | `https://mcp.alloc-context.com/mcp` |
59
+ | **Discovery** | [llms.txt](https://mcp.alloc-context.com/llms.txt), [x402 manifest](https://mcp.alloc-context.com/.well-known/x402.json) |
60
+ | **Pricing** | **$0.02** cached context/math · **$0.05** live ingest or portfolio |
61
+ | **Payment** | x402 on Base — USDC or EURC |
62
+
63
+ Agents find the service via [CDP Bazaar](docs/mcp-discovery.md). Integration
64
+ guide: [docs/agent-integration.md](docs/agent-integration.md). Example JSON:
65
+ [docs/examples.md](docs/examples.md).
66
+
67
+ **Try free locally** (no payment): `./scripts/dev-up.sh` — see
68
+ [docs/local-dev.md](docs/local-dev.md).
69
+
70
+ Optional live portfolio reads use read-only exchange credentials passed in
71
+ each request. Not financial advice.
72
+
73
+ ```text
74
+ ingest → store → rollup → MCP tools (+ optional x402 HTTP)
75
+ ```
76
+
77
+ This package is **facts and MCP only** — ingest, rollups, and agent tools.
78
+ Email, LLM synthesis, and alert delivery are out of scope for this repository.
79
+
80
+ ## Try it locally
81
+
82
+ ```bash
83
+ git clone git@github.com:negillett/alloc-context.git
84
+ cd alloc-context
85
+ python3.11 -m venv .venv && source .venv/bin/activate
86
+ pip install -e ".[dev]"
87
+ cp .env.example .env # fill locally; never commit
88
+ cp config/config.example.yaml config/config.yaml
89
+
90
+ python -m alloccontext ingest --dry-run
91
+ python -m alloccontext rollup --scope daily --stdout
92
+ pytest
93
+ ```
94
+
95
+ **MCP (stdio):** `pip install -e ".[mcp]"` then `alloc-context mcp`.
96
+ See [docs/cursor-mcp.md](docs/cursor-mcp.md).
97
+
98
+ **Hosted MCP + x402:** `pip install -e ".[hosted]"` then
99
+ `alloc-context mcp --transport http --x402`. See [docs/mcp-http.md](docs/mcp-http.md).
100
+
101
+ **Local dev stack (internal MCP on :8001):** `./scripts/dev-up.sh`.
102
+ See [docs/local-dev.md](docs/local-dev.md).
103
+
104
+ CLI entry point: `alloc-context` (same as `python -m alloccontext`).
105
+
106
+ ## Commands
107
+
108
+ | Command | Purpose |
109
+ |---------|---------|
110
+ | `python -m alloccontext ingest` | Pull configured sources → SQLite |
111
+ | `python -m alloccontext rollup --scope daily --stdout` | ContextBundle JSON (facts) |
112
+ | `python -m alloccontext status` | Per-source ingest ages, snapshots, MCP `/health` |
113
+ | `alloc-context mcp` | MCP server (stdio or HTTP) |
114
+
115
+ ## MCP tools
116
+
117
+ | Tool | Purpose |
118
+ |------|---------|
119
+ | `get_context_bundle` | Full ContextBundle — portfolio, market, sentiment, macro, delta, regime |
120
+ | `get_market_context` | Sentiment, macro, ETF, breadth, and market fields (no portfolio) |
121
+ | `get_context_at` | Saved snapshot from ingest history at a given `as_of` |
122
+ | `get_context_delta` | Notable shifts between two saved snapshots |
123
+ | `get_rebalance_plan` | USD rebalance moves from allocation, target, and NAV |
124
+ | `check_allocation_band` | Drift vs target and whether allocation is outside the band |
125
+ | `check_allocation_bands` | Batch band checks for multiple target scenarios |
126
+ | `get_portfolio_state` | Live NAV and allocation from Kraken or Coinbase (credentials in request) |
127
+
128
+ See [docs/mcp.md](docs/mcp.md) for arguments, pricing, and resources.
129
+
130
+ ## Documentation
131
+
132
+ | Document | Purpose |
133
+ |----------|---------|
134
+ | [docs/mcp.md](docs/mcp.md) | MCP tools and x402 |
135
+ | [docs/mcp-http.md](docs/mcp-http.md) | HTTP MCP + x402 setup |
136
+ | [docs/mcp-discovery.md](docs/mcp-discovery.md) | Bazaar and agent discovery |
137
+ | [docs/distribution.md](docs/distribution.md) | GitHub, PyPI, MCP Registry, directories |
138
+ | [docs/agent-integration.md](docs/agent-integration.md) | Paid HTTP MCP + Bazaar for agents |
139
+ | [docs/cursor-mcp.md](docs/cursor-mcp.md) | Cursor stdio MCP |
140
+ | [docs/examples.md](docs/examples.md) | Sample tool JSON (redacted) |
141
+ | [docs/context-bundle.md](docs/context-bundle.md) | ContextBundle schema |
142
+ | [docs/architecture.md](docs/architecture.md) | Pipeline and trust boundaries |
143
+ | [docs/data-sources.md](docs/data-sources.md) | Ingest sources |
144
+ | [docs/self-hosting.md](docs/self-hosting.md) | Optional Linux/systemd ingest + MCP |
145
+ | [docs/local-dev.md](docs/local-dev.md) | Local internal MCP + dev ingest |
146
+
147
+ ## Contributing
148
+
149
+ GitHub Issues are welcome for bugs, schema feedback, and MCP API suggestions.
150
+ Unsolicited pull requests are not expected — see [CONTRIBUTING.md](CONTRIBUTING.md).
151
+
152
+ ## License
153
+
154
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,133 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ alloc_context.egg-info/PKG-INFO
5
+ alloc_context.egg-info/SOURCES.txt
6
+ alloc_context.egg-info/dependency_links.txt
7
+ alloc_context.egg-info/entry_points.txt
8
+ alloc_context.egg-info/requires.txt
9
+ alloc_context.egg-info/top_level.txt
10
+ alloccontext/__init__.py
11
+ alloccontext/__main__.py
12
+ alloccontext/config.py
13
+ alloccontext/horizon.py
14
+ alloccontext/status_report.py
15
+ alloccontext/timeutil.py
16
+ alloccontext/x402_production_check.py
17
+ alloccontext/x402_smoke_redact.py
18
+ alloccontext/ingest/__init__.py
19
+ alloccontext/ingest/cf_benchmarks.py
20
+ alloccontext/ingest/cf_history.py
21
+ alloccontext/ingest/coinbase_client.py
22
+ alloccontext/ingest/coinbase_portfolio.py
23
+ alloccontext/ingest/coingecko.py
24
+ alloccontext/ingest/coinmarketcap.py
25
+ alloccontext/ingest/env_keys.py
26
+ alloccontext/ingest/etf_flows.py
27
+ alloccontext/ingest/exchange_http.py
28
+ alloccontext/ingest/fear_greed.py
29
+ alloccontext/ingest/fred.py
30
+ alloccontext/ingest/http_errors.py
31
+ alloccontext/ingest/kalshi.py
32
+ alloccontext/ingest/kalshi_api.py
33
+ alloccontext/ingest/kalshi_client.py
34
+ alloccontext/ingest/kalshi_files.py
35
+ alloccontext/ingest/kalshi_state.py
36
+ alloccontext/ingest/kraken_client.py
37
+ alloccontext/ingest/kraken_portfolio.py
38
+ alloccontext/ingest/macro_calendar.py
39
+ alloccontext/ingest/macro_normalize.py
40
+ alloccontext/ingest/market_snapshots.py
41
+ alloccontext/ingest/outcome.py
42
+ alloccontext/ingest/parse_helpers.py
43
+ alloccontext/ingest/runner.py
44
+ alloccontext/ingest/exchange/__init__.py
45
+ alloccontext/ingest/exchange/coinbase_adapter.py
46
+ alloccontext/ingest/exchange/kraken_adapter.py
47
+ alloccontext/ingest/exchange/live.py
48
+ alloccontext/ingest/exchange/portfolio.py
49
+ alloccontext/ingest/exchange/registry.py
50
+ alloccontext/ingest/exchange/types.py
51
+ alloccontext/mcp/__init__.py
52
+ alloccontext/mcp/assets.py
53
+ alloccontext/mcp/bazaar.py
54
+ alloccontext/mcp/contracts.py
55
+ alloccontext/mcp/handlers.py
56
+ alloccontext/mcp/http.py
57
+ alloccontext/mcp/payment_middleware.py
58
+ alloccontext/mcp/server.py
59
+ alloccontext/mcp/staleness.py
60
+ alloccontext/mcp/validation.py
61
+ alloccontext/mcp/x402_bazaar_dynamic.py
62
+ alloccontext/mcp/x402_config.py
63
+ alloccontext/mcp/x402_pricing.py
64
+ alloccontext/mcp/x402_stables.py
65
+ alloccontext/rollup/__init__.py
66
+ alloccontext/rollup/band.py
67
+ alloccontext/rollup/breadth.py
68
+ alloccontext/rollup/cf_math.py
69
+ alloccontext/rollup/cluster.py
70
+ alloccontext/rollup/cluster_config.py
71
+ alloccontext/rollup/comparison.py
72
+ alloccontext/rollup/context.py
73
+ alloccontext/rollup/delta.py
74
+ alloccontext/rollup/etf.py
75
+ alloccontext/rollup/fear_greed.py
76
+ alloccontext/rollup/macro.py
77
+ alloccontext/rollup/portfolio.py
78
+ alloccontext/rollup/rebalance.py
79
+ alloccontext/rollup/regime.py
80
+ alloccontext/rollup/sentiment.py
81
+ alloccontext/rollup/snapshots.py
82
+ alloccontext/rollup/tape.py
83
+ alloccontext/store/__init__.py
84
+ alloccontext/store/db.py
85
+ alloccontext/store/jsonutil.py
86
+ alloccontext/store/meta.py
87
+ alloccontext/store/retention.py
88
+ alloccontext/store/status.py
89
+ tests/test_adr005_ingest.py
90
+ tests/test_backup_sqlite.py
91
+ tests/test_bump_version.py
92
+ tests/test_coinbase_portfolio.py
93
+ tests/test_context_snapshots.py
94
+ tests/test_db_schema.py
95
+ tests/test_deploy.py
96
+ tests/test_dev_stack.py
97
+ tests/test_etf.py
98
+ tests/test_exchanges_config.py
99
+ tests/test_fear_greed.py
100
+ tests/test_fred.py
101
+ tests/test_horizon.py
102
+ tests/test_ingest_outcome.py
103
+ tests/test_ingest_runner.py
104
+ tests/test_kalshi_api.py
105
+ tests/test_kraken_portfolio.py
106
+ tests/test_macro.py
107
+ tests/test_market_breadth.py
108
+ tests/test_mcp_assets_regime.py
109
+ tests/test_mcp_bazaar.py
110
+ tests/test_mcp_contracts.py
111
+ tests/test_mcp_freshness.py
112
+ tests/test_mcp_handlers.py
113
+ tests/test_mcp_health.py
114
+ tests/test_mcp_http_lifecycle.py
115
+ tests/test_mcp_live_portfolio.py
116
+ tests/test_mcp_server.py
117
+ tests/test_mcp_validation.py
118
+ tests/test_mcp_x402.py
119
+ tests/test_mcp_x402_http.py
120
+ tests/test_mcp_x402_pricing.py
121
+ tests/test_mcp_x402_stables.py
122
+ tests/test_qa_ingest_store.py
123
+ tests/test_rebalance.py
124
+ tests/test_rollup.py
125
+ tests/test_scaffold.py
126
+ tests/test_script_runtime.py
127
+ tests/test_security_hardening.py
128
+ tests/test_snapshots_and_delta.py
129
+ tests/test_status_report.py
130
+ tests/test_workflows.py
131
+ tests/test_x402_bazaar_dynamic.py
132
+ tests/test_x402_production_check.py
133
+ tests/test_x402_smoke_redact.py
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ alloc-context = alloccontext.__main__:main
3
+ alloc-context-mcp = alloccontext.mcp.server:main
4
+ alloc-context-mcp-http = alloccontext.mcp.http:main
@@ -0,0 +1,20 @@
1
+ pyyaml>=6.0
2
+ requests>=2.31
3
+ PyJWT>=2.8
4
+ cryptography>=42.0
5
+
6
+ [dev]
7
+ pytest>=8.0
8
+ mcp>=1.6
9
+ x402[evm,fastapi]>=2.0
10
+ cdp-sdk>=1.46
11
+ uvicorn[standard]>=0.30
12
+
13
+ [hosted]
14
+ mcp>=1.6
15
+ x402[evm,fastapi]>=2.0
16
+ cdp-sdk>=1.46
17
+ uvicorn[standard]>=0.30
18
+
19
+ [mcp]
20
+ mcp>=1.6
@@ -0,0 +1 @@
1
+ alloccontext
@@ -0,0 +1,3 @@
1
+ """AllocContext — BTC/ETH allocation context and rebalance facts."""
2
+
3
+ __version__ = "0.1.0"