{
  "markdown": "<!-- mcp-name: io.github.SnipMCP/thinchain -->\n\n# ThinChain\n\nThe catalytic converter between raw broker data and your AI trading agent.\n\n**Battle-tested.** Sanitization logic extracted from a production options trading app. Handles every bad tick Tradier has thrown at us in production.\n\n![ThinChain Demo](demo/thinchain_demo.gif)\n\n## ☁️ Moving to production?\n\nThe open-source server runs locally with your own API keys.\nFor hosted infrastructure with multi-broker failover, SLA guarantees,\nand webhook alerts — [join the managed cloud waitlist](https://snipmcp.com).\n\n## The Problem\n\nTradier's MCP dumps 500-row JSON chains. One bad print can corrupt an agent's reasoning. ThinChain sanitizes, compresses, and circuit-breaks that data before it reaches your model.\n\n## Installation\n\n```bash\ngit clone https://github.com/snipmcp/thinchain.git\ncd thinchain\npip install -e \".[dev]\"\ncp .env.example .env\n```\n\nOr with Docker:\n\n```bash\ndocker-compose up --build\n```\n\n## Configuration\n\n```env\nTRADIER_API_KEY=your_key_here\nTRADIER_BASE_URL=https://api.tradier.com/v1\nPOLYGON_API_KEY=your_key_here\nPOLYGON_BASE_URL=https://api.polygon.io\nDEFAULT_BROKER=tradier\nCACHE_TTL_SECONDS=30\nLOG_LEVEL=INFO\n```\n\n## Usage\n\nThree example prompts to send to Claude (or any MCP-compatible agent):\n\n1. `Use get_compressed_chain to get an iron condor setup on SPY expiring 2026-06-19`\n2. `Check if SPY options data is trustworthy before I place my trade`\n3. `Get me the ATM straddle strikes for AAPL expiring 2026-06-19`\n\n### Run it in two terminals\n\n```bash\n# Tab 1 — start the MCP server\npython -m thinchain.server\n```\n\n```bash\n# Tab 2 — call a tool from a Python shell or your MCP client\n# Tool signatures:\n#   get_compressed_chain(symbol, expiration, strategy=\"raw\",\n#                        delta_range=None, broker=\"tradier\")\n#   get_sanitized_quote(symbol, broker=\"tradier\")\n#   get_circuit_status(symbol, expiration, broker=\"tradier\")\n```\n\n## How it works\n\nThree layers between raw broker output and your model:\n\n```\nBroker API → [Sanitize] → [Compress] → [Circuit Break] → MCP Tool → AI Agent\n              hygiene     strategy      anomaly gate\n              rules       slicing       + cache\n```\n\n- **Sanitize**: Drops ghost quotes (0.0/0.0), inverted spreads, NaN/empty/dash values, clamps deltas to [-1, 1], normalizes positive theta on long options, flags illiquid strikes.\n- **Compress**: Slices the chain to only the strikes relevant to your strategy (iron condor, straddle, etc.) — typically 95%+ token reduction.\n- **Circuit Break**: Four-tier data quality (`clean` / `noisy` / `degraded` / `circuit_breaker_active`). When >65% of rows are anomalous, refuses to serve stale data and falls back to last known-good cache.\n\n### Real numbers from a live SPY iron condor (2026-06-19 expiration)\n\n```\nRAW TRADIER PAYLOAD          THINCHAIN OUTPUT\n─────────────────────────────────────────────\nRows:        482             Rows:        25\nEst tokens:  38,560          Est tokens:  2,000\nToken savings:               95%\nAnomalous rows removed:      217\nData quality:                noisy → still safely served\n```\n\nThinChain compresses 482 rows / 38,560 tokens down to 25 rows / 2,000 tokens — and flags 217 anomalous strikes (illiquid, ghost quotes, wide spreads) that would have polluted the agent's context.\n\n## Roadmap\n\n- Managed cloud tier (hosted, multi-tenant, webhook alerts)\n- Polygon connector hardening (live SIP feed)\n- Webhook alerts for circuit breaker trips\n\n## Contributing\n\nPRs welcome. Run `pytest` before submitting.\n",
  "bytes": 3524,
  "sha": "bec3188baa6aa377aea3259196c26318b9ea460e9fdcb5beba3a03c35c3b0bda",
  "repo_slug": "snipmcp/thinchain",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_snipmcp_thinchain_2ce8cd8d/readme"
}