Skip to main content
Glama
filings-library MCP Server

filings-library MCP Server

by benjamin-di

filings-library

Multi-user company financial filings library: immutable SHA-256 archive, isolated PDF/OCR/HTML/XLSX extraction, Markdown conversion with unified locators, FTS5 financial search, SEC XBRL companyfacts, CLI, and a strictly scoped FastMCP server.

Quick start

uv sync --locked --extra extractor
make check

Run the reference 3-container stack locally:

docker compose up --build

Related MCP server: XBRL-US MCP Server

Architecture

  • Single source of truth: SQLite (WAL mode) + immutable SHA-256 CAS (objects/sha256/<aa>/<sha256>). Derivatives (ocr_pdf, markdown, facts_json) are stored in CAS keyed by (source_sha256, converter_id, converter_version). The FTS5 index (fts_chunks) is strictly rebuildable from sections.

  • Extraction isolation: PDF, OCR, HTML/iXBRL, and XLSX parsing run inside the stateless filings-extractor container (pypdfium2, poppler-utils, tesseract-ocr, qpdf) with read_only: true, cap_drop: [ALL], /scratch tmpfs, memory limits, and zero credentials or persistent volumes.

  • Multi-user fail-closed scoping: Every read, search, facts, and status call resolves the authenticated caller's allowed source_keys from the targets hub (GET /internal/library-targets, TTL <= 60s). If the hub is unavailable, the service fails closed (HTTP 503) and never falls back to stale or corpus-wide data.

  • HTTP security boundaries: /mcp requires a configured backend bearer token (>= 32 chars, constant-time hmac.compare_digest check, 401 on failure), a non-empty X-Fleet-Subject header (403 on missing), TrustedHostMiddleware host validation, and Cache-Control: no-store on all API responses. GET /health runs SQLite PRAGMA quick_check (200/503) without auth.

CLI reference

All commands are exposed via filings-library:

# Run one bounded sync pass
filings-library sync --data-dir ./data \
  --targets-url http://127.0.0.1:8000 \
  --targets-token "$FILINGS_TARGETS_TOKEN" \
  --extractor-url http://127.0.0.1:8081 \
  --sec-user-agent "FilingsLibrary/0.1 (contact@example.com)"

# Search, read, query XBRL facts, and inspect coverage (--person ID or --all)
filings-library search "operating margin" --data-dir ./data --all --json
filings-library read <document_id> --data-dir ./data --all --start page:1 --end page:3
filings-library facts Revenues NetIncomeLoss --data-dir ./data --all --json
filings-library status --data-dir ./data --all --json

# Maintenance & one-way Markdown export
filings-library export-md ./export --data-dir ./data
filings-library rebuild-fts --data-dir ./data

# Hosted servers
filings-library serve --data-dir ./data --host 0.0.0.0 --port 8080
filings-library extractor --host 0.0.0.0 --port 8081

MCP tools

Mounted at /mcp (Streamable HTTP, stateless JSON responses):

Tool

Description

filings_list_companies

List companies in the caller's allowed source_keys.

filings_list_documents

List documents filtered by source_key, form_family, since, limit.

filings_search

Scoped FTS5 financial search returning strict Citation dicts.

filings_read

Bounded section reader with start_locator, end_locator, and max_chars.

filings_facts

Query cached SEC XBRL companyfacts across the caller's allowed companies.

filings_status

Per-issuer coverage report (counts by form_family, adapters, latest filing date, has_company_facts) strictly for the caller's allowed companies.

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

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables deep analysis of SEC EDGAR filings through universal company search, document content extraction, and advanced filing search capabilities. Provides AI-ready access to business descriptions, risk factors, financial statements, and full-text search across any public company's SEC documents.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides secure access to XBRL-US financial data with session-based authentication, enabling users to search for companies by fiscal year and retrieve their financial facts from SEC filings.
      -
    • A
      license
      B
      quality
      D
      maintenance
      Enables comprehensive access to SEC EDGAR filings, allowing users to search companies, retrieve financial statements, and analyze dimensional XBRL data including revenue breakdowns by geography, business segments, and product lines.
      1
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables authenticated, read-only access to securities search, quote snapshots, indices, historical daily bars, exchange rates, and macroeconomic indicators. Cross-checks prices across multiple upstream sources and reports each source's availability and status without fabricating missing values.
      1
      MIT