Skip to main content
Glama
cftc-cot-mcp

cftc-cot-mcp

by ajstehle2001

cftc-cot-mcp

An MCP server that exposes CFTC Commitments of Traders (COT) positioning as clean, agent-callable tools. Point any MCP client — Claude, a LangGraph app, an OpenAI Agents SDK app — at it and ask about managed-money positioning with no glue code.

Tools

Tool

Returns

get_latest_cot

Most recent weekly report: managed-money long/short/net, open interest, market, date.

query_cot_history

A YYYY-MM-DD date range, or the most recent last_n weekly reports.

cot_positioning_signal

Derived read over a lookback window: net, week-over-week change, min/max, percentile rank, z-score, extreme flag.

Related MCP server: financial-trading-risk-aiops-assistant

Architecture

flowchart LR
  H[MCP client / agent] -- stdio --> S[cftc-cot server]
  S -- read-only --> D[(SQLite: COT table)]

Stateless server: a read-only SQLite connection per call, DB path and table name from the environment, JSON out. Nothing is ever written.

Design decisions

  • Read-only by construction. The connection opens mode=ro, so a tool cannot alter the source — a guarantee, not a convention.

  • Config, not hardcoding. COT_DB_PATH and COT_TABLE come from the environment; no deployment path lives in the code.

  • Inputs validated and clamped. Dates are format-checked; last_n and lookback are bounded, so a bad argument can't scan the whole table.

  • Table name whitelisted against [A-Za-z_][A-Za-z0-9_]* before use.

Failure model

Failure

Behavior

DB file missing

FileNotFoundError naming the path and the env var to set

Malformed date argument

ValueError; the query never runs

Invalid table name in config

Server refuses to start

Empty table

get_latest_cot returns {}; signal returns explicit not enough data

Quick start

git clone https://github.com/ajstehle2001/cftc-cot-mcp.git
cd cftc-cot-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env     # edit .env with your DB path
python test_client.py    # spawns the server and exercises all 3 tools

Use it from an MCP client

{
  "mcpServers": {
    "cftc-cot": {
      "command": "/abs/path/.venv/bin/python",
      "args": ["/abs/path/server.py"],
      "env": {
        "COT_DB_PATH": "/abs/path/to/cot.db",
        "COT_TABLE": "cot_history_combined"
      }
    }
  }
}

Data

COT is public data published weekly by the US CFTC. Expected columns: report_date, mm_long, mm_short, mm_net, open_interest, market, fetched_at.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      C
      maintenance
      Enables querying real-time and historical financial market data for stocks, options, forex, and crypto, including quotes, trades, technical indicators, and reference data through a set of MCP tools.
      71
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides read-only MCP tools for market snapshots, position risk, order reconciliation, and daily report previews with deterministic financial calculations, evidence chains, and audit trails.
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents and trading desks to query institutional quantitative market telemetry, 100-bin auction profiles, order-book crowd sentiment, conformal volatility cones, macro session radar, and prop-risk metrics across 130+ global assets. It also renders interactive market-intelligence micro-app frames inside MCP-compatible chat clients.
      5
      57 npm
      28 PyPI
      Apache 2.0