CleanParse A2A Document & Table Extractor

v1.0.0
io.github.ZhannaBee/cleanparse-a2a Checked 1 hour ago Published 2 hours ago

Zero-LLM HTML/text extraction and lossless table normalization: clean Markdown, JSON and 2D tables.

Zero-LLM-cost deterministic Web/HTML/Text extraction & lossless Table normalizer with FastAPI REST + MCP JSON-RPC 2.0 dual endpoints, SQLite billing/rate-limit metering, RapidAPI proxy verification, and one-click Render cloud deployment. Architecture - Zero External LLM Cost ($0.00/call): Pure local parsing (BeautifulSoup4 + lxml) strips nav/ads/scripts, expands complex colspan/rowspan HTML tables into lossless 2D JSON + GFM Markdown, and reduces token footprint for downstream AI agents.

Summary extracted from the README.

CleanParse A2A Micro-API (Stage 3)

Try it live & Automation Suite:

Zero-LLM-cost deterministic Web/HTML/Text extraction & lossless Table normalizer with FastAPI REST + MCP JSON-RPC 2.0 dual endpoints, SQLite billing/rate-limit metering, RapidAPI proxy verification, and one-click Render cloud deployment.

Architecture

  • Zero External LLM Cost ($0.00/call): Pure local parsing (BeautifulSoup4 + lxml) strips nav/ads/scripts, expands complex colspan/rowspan HTML tables into lossless 2D JSON + GFM Markdown, and reduces token footprint for downstream AI agents.
  • Dual A2A Interface:
    • REST API: POST /v1/extract, POST /v1/extract/tables, POST /v1/keys/issue, GET /v1/usage, GET /v1/pricing, GET /health, GET /.well-known/agent.json
    • MCP JSON-RPC 2.0: POST /mcp (initialize, tools/list, tools/call for extract_document, extract_tables, check_quota)
  • Billing & Rate-Limit Gate (SQLite WAL):
    • SHA-256 hashed API keys (X-API-Key / Authorization: Bearer)
    • Constant-time RapidAPI proxy verification (X-RapidAPI-Proxy-Secret + X-RapidAPI-User + X-RapidAPI-Subscription)
    • UTC daily plan quotas (free: 50/day, pro: 2,000/day, enterprise: 50,000/day) returning 429 Too Many Requests with Retry-After
    • Per-request usage & estimated USD revenue logging (GET /v1/admin/revenue)
  • Security: SSRF protection blocking loopback, RFC1918 private IPs, cloud metadata (169.254.169.254), and non-HTTP(S) schemes.

Local Run & Test

.\.venv\Scripts\python.exe -m pytest tests -v
.\.venv\Scripts\python.exe scripts\export_openapi.py
.\.venv\Scripts\python.exe -m uvicorn app.main:app --host 127.0.0.1 --port 8000

Cloud Deployment & RapidAPI Registration

  1. Push micro_api_stage3/ to a GitHub repo and connect via Render Blueprint (render.yaml, free tier).
  2. Copy the Render URL (https://<service>.onrender.com) and import artifacts/openapi_rapidapi.json into RapidAPI Studio.
  3. Copy RapidAPI's X-RapidAPI-Proxy-Secret into Render's RAPIDAPI_PROXY_SECRET environment variable.