Skip to main content

MCP server that sanitizes bad broker data and compresses options chains 95% for AI trading agents.

Project description

ThinChain

The catalytic converter between raw broker data and your AI trading agent.

Battle-tested. Sanitization logic extracted from a production options trading app. Handles every bad tick Tradier has thrown at us in production.

ThinChain Demo

☁️ Moving to production?

The open-source server runs locally with your own API keys. For hosted infrastructure with multi-broker failover, SLA guarantees, and webhook alerts — join the managed cloud waitlist.

The Problem

Tradier'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.

Installation

git clone https://github.com/snipmcp/thinchain.git
cd thinchain
pip install -e ".[dev]"
cp .env.example .env

Or with Docker:

docker-compose up --build

Configuration

TRADIER_API_KEY=your_key_here
TRADIER_BASE_URL=https://api.tradier.com/v1
POLYGON_API_KEY=your_key_here
POLYGON_BASE_URL=https://api.polygon.io
DEFAULT_BROKER=tradier
CACHE_TTL_SECONDS=30
LOG_LEVEL=INFO

Usage

Three example prompts to send to Claude (or any MCP-compatible agent):

  1. Use get_compressed_chain to get an iron condor setup on SPY expiring 2026-06-19
  2. Check if SPY options data is trustworthy before I place my trade
  3. Get me the ATM straddle strikes for AAPL expiring 2026-06-19

Run it in two terminals

# Tab 1 — start the MCP server
python -m thinchain.server
# Tab 2 — call a tool from a Python shell or your MCP client
# Tool signatures:
#   get_compressed_chain(symbol, expiration, strategy="raw",
#                        delta_range=None, broker="tradier")
#   get_sanitized_quote(symbol, broker="tradier")
#   get_circuit_status(symbol, expiration, broker="tradier")

How it works

Three layers between raw broker output and your model:

Broker API → [Sanitize] → [Compress] → [Circuit Break] → MCP Tool → AI Agent
              hygiene     strategy      anomaly gate
              rules       slicing       + cache
  • 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.
  • Compress: Slices the chain to only the strikes relevant to your strategy (iron condor, straddle, etc.) — typically 95%+ token reduction.
  • 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.

Real numbers from a live SPY iron condor (2026-06-19 expiration)

RAW TRADIER PAYLOAD          THINCHAIN OUTPUT
─────────────────────────────────────────────
Rows:        482             Rows:        25
Est tokens:  38,560          Est tokens:  2,000
Token savings:               95%
Anomalous rows removed:      217
Data quality:                noisy → still safely served

ThinChain 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.

Roadmap

  • Managed cloud tier (hosted, multi-tenant, webhook alerts)
  • Polygon connector hardening (live SIP feed)
  • Webhook alerts for circuit breaker trips

Contributing

PRs welcome. Run pytest before submitting.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thinchain-0.1.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thinchain-0.1.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file thinchain-0.1.1.tar.gz.

File metadata

  • Download URL: thinchain-0.1.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for thinchain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 62d4614f81790d121c36837ac858449f09ea09e85863548977f69662305d1200
MD5 1ed922748e2031aa740c92297403a850
BLAKE2b-256 523d5b1da95a2242bc7d5ea7c7d2d031d55a0cb34f2ccb4057ad817faf55f0df

See more details on using hashes here.

File details

Details for the file thinchain-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: thinchain-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for thinchain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc462e1ef7a50c1aaa7a8b0d9c2a4c0aa780353bb1aa046354bb903da5c907e3
MD5 cdfbaed4efdf95a7702e34c820b9d398
BLAKE2b-256 5d72f6715fb9aba99d2da16ef05e611f283940cd6280ad9549e63314c5253d8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page