Metadata-Version: 2.4
Name: alloc-context
Version: 0.3.0
Summary: Portfolio-aware crypto context — CEX or wallet holdings, holdings-scoped market, optional allocation analysis
License: MIT
Project-URL: Homepage, https://github.com/AllocContext/alloc-context
Project-URL: Documentation, https://github.com/AllocContext/alloc-context/blob/main/docs/cursor-mcp.md
Project-URL: Repository, https://github.com/AllocContext/alloc-context
Project-URL: Issues, https://github.com/AllocContext/alloc-context/issues
Project-URL: Changelog, https://github.com/AllocContext/alloc-context/releases
Keywords: mcp,x402,holdings,portfolio,crypto,cryptocurrency,bitcoin,ethereum,agents,allocation,rebalance,coinbase,kraken,wallet,defi
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyyaml>=6.0
Requires-Dist: requests>=2.31
Requires-Dist: PyJWT>=2.8
Requires-Dist: cryptography>=42.0
Provides-Extra: mcp
Requires-Dist: mcp>=1.6; extra == "mcp"
Provides-Extra: hosted
Requires-Dist: mcp>=1.6; extra == "hosted"
Requires-Dist: x402[evm,fastapi]>=2.0; extra == "hosted"
Requires-Dist: cdp-sdk>=1.46; extra == "hosted"
Requires-Dist: uvicorn[standard]>=0.30; extra == "hosted"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=6.0; extra == "dev"
Requires-Dist: bandit>=1.8; extra == "dev"
Requires-Dist: pip-audit>=2.9; extra == "dev"
Requires-Dist: mcp>=1.6; extra == "dev"
Requires-Dist: x402[evm,fastapi]>=2.0; extra == "dev"
Requires-Dist: cdp-sdk>=1.46; extra == "dev"
Requires-Dist: uvicorn[standard]>=0.30; extra == "dev"
Dynamic: license-file

# AllocContext

mcp-name: io.github.AllocContext/alloc-context

**Portfolio-aware crypto context for whatever you hold** — discover your
holdings, holdings-scoped market data, sentiment, macro, and regime; optional
allocation analysis when you supply targets. Deterministic JSON over MCP.

**New here?** [Cursor MCP setup](docs/cursor-mcp.md) — stdio in your editor, or
[self-hosting](docs/self-hosting.md) with local ingest. **Organization:**
[AllocContext on GitHub](https://github.com/AllocContext).

> **Privacy:** nothing stored · one-time read-only · pass-through only when
> using live portfolio reads. See [USE.md](docs/USE.md).

## Quick start (Cursor, self-host)

**1. Install**

```bash
pip install "alloc-context[mcp]"
# From source: pip install -e ".[mcp]"
```

**2. Config and secrets**

Copy [config/config.example.yaml](config/config.example.yaml) to
`config/config.yaml`. Copy [.env.example](.env.example) to `.env` and add
read-only exchange keys when you want portfolio ingest or macro feeds.
See [self-hosting.md](docs/self-hosting.md).

**3. MCP config**

Add to your Cursor `mcp.json` (or project `.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "alloc-context": {
      "command": "alloc-context",
      "args": [
        "mcp",
        "--config",
        "/absolute/path/to/alloc-context/config/config.yaml"
      ],
      "env": {
        "ALLOC_CONTEXT_DB": "/absolute/path/to/alloc-context/state/alloccontext.db"
      }
    }
  }
}
```

Use absolute paths. See [cursor-mcp.example.json](docs/cursor-mcp.example.json).

**4. Refresh facts (optional)**

```bash
python -m alloccontext --config config/config.yaml ingest
```

Run before a session or when you want fresh macro/regime data. No cron required.

**5. Ask your agent**

Call `get_context_bundle` for a full snapshot. Pure math tools
(`check_allocation_band`, `get_rebalance_plan`) work without portfolio credentials.

Full setup: [cursor-mcp.md](docs/cursor-mcp.md). Samples: [examples.md](docs/examples.md).

Not financial advice.

## MCP tools

| Tool | Purpose |
|------|---------|
| `get_context_bundle` | Full ContextBundle — holdings, market, sentiment, macro, delta, regime; optional `allocation_analysis` |
| `get_market_context` | Sentiment, macro, ETF, breadth, and market fields (no portfolio) |
| `get_context_at` | Saved snapshot from ingest history at a given `as_of` |
| `get_context_delta` | Notable shifts between two saved snapshots |
| `get_rebalance_plan` | USD rebalance moves from allocation, target, and NAV |
| `check_allocation_band` | Drift vs target and whether allocation is outside the band |
| `check_allocation_bands` | Batch band checks for multiple target scenarios |
| `get_portfolio_state` | Live NAV and holdings (CEX keys or public EVM wallet address) |
| `get_expectation_review` | Score optional local theses against context (pass-through) |

Market context is **holdings-scoped**: band assets (BTC/ETH) use OHLC bars; alt
holdings (e.g. HYPE) use quote snapshots when cached. See
[context-bundle.md#market-coverage](docs/context-bundle.md#market-coverage).

See [mcp.md](docs/mcp.md) for arguments and resources.

## Self-host and development

Run ingest and MCP on your machine — the primary supported path.

See [self-hosting.md](docs/self-hosting.md), [local-dev.md](docs/local-dev.md)
(`./scripts/dev-up.sh`), or [docker-self-host.md](docs/docker-self-host.md).

```bash
git clone git@github.com:AllocContext/alloc-context.git
cd alloc-context
python3.11 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,mcp]"
cp .env.example .env
cp config/config.example.yaml config/config.yaml

python -m alloccontext ingest --dry-run
python -m alloccontext rollup --scope daily --stdout
pytest
```

| Command | Purpose |
|---------|---------|
| `python -m alloccontext ingest` | Pull configured sources → SQLite |
| `python -m alloccontext rollup --scope daily --stdout` | ContextBundle JSON (facts) |
| `python -m alloccontext status` | Per-source ingest ages, snapshots, MCP `/health` |
| `alloc-context mcp` | MCP server (stdio or HTTP) |

Optional HTTP MCP + x402 on **your** host: [mcp-http.md](docs/mcp-http.md).

AllocContext is **self-host only** — we do not operate `mcp.alloc-context.com`.
Quickstart: [agent-onramp.md](docs/agent-onramp.md) · [cursor-mcp.md](docs/cursor-mcp.md).

## Documentation

| Document | Purpose |
|----------|---------|
| [docs/agent-onramp.md](docs/agent-onramp.md) | **~2 min** quickstart |
| [docs/cursor-mcp.md](docs/cursor-mcp.md) | Cursor stdio MCP |
| [docs/self-hosting.md](docs/self-hosting.md) | Local ingest + MCP |
| [docs/deterministic-context-mcp-pattern.md](docs/deterministic-context-mcp-pattern.md) | Ingest → rollup → MCP pattern |
| [docs/mcp.md](docs/mcp.md) | MCP tools |
| [docs/examples.md](docs/examples.md) | Sample tool JSON (redacted) |
| [docs/context-bundle.md](docs/context-bundle.md) | ContextBundle schema |
| [docs/USE.md](docs/USE.md) | License and use policy |
| [docs/local-dev.md](docs/local-dev.md) | Local internal MCP + dev ingest |
| [docs/docker-self-host.md](docs/docker-self-host.md) | Docker Compose self-host |
| [docs/distribution.md](docs/distribution.md) | PyPI and MCP Registry |
| [docs/publishing.md](docs/publishing.md) | Release workflow |
| [docs/mcp-http.md](docs/mcp-http.md) | Optional HTTP + x402 (your host) |
| [docs/user-config.md](docs/user-config.md) | Bridge `user.yaml` (legacy archive) |

## Contributing

GitHub Issues are welcome for bugs, schema feedback, and MCP API suggestions.
Unsolicited pull requests are not expected — see [CONTRIBUTING.md](CONTRIBUTING.md).

## License

[MIT License](LICENSE). Self-host via PyPI. See [docs/USE.md](docs/USE.md).
