Downloads · 30 days
0
Warcos/PolicyCaliper
PolicyCaliper is a machine learning model from Warcos. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
AI-powered risk analysis for Terms of Service and Privacy Policies. Upload a policy (or two versions), get a structured risk report with citations, exportable to PDF, and MCP-friendly tooling.
Downloads · 30 days
0
Access
Public
Updated Nov 30, 2025
Repo size
—
Likes
1
Public
Click a slice to open those files.
.py224 KB · 80%
From the Hugging Face model README
AI-powered risk analysis for Terms of Service and Privacy Policies. Upload a policy (or two versions), get a structured risk report with citations, exportable to PDF, and MCP-friendly tooling.
building-mcp-track-enterprise & mcp-in-action-track-enterpriseTry it: https://huggingface.co/spaces/MCP-1st-Birthday/Policy_Caliper
Demo video: https://drive.google.com/file/d/159M7GqItbvtp4UmsgypwqgNcxs2e_wd5/view
Official post: https://www.linkedin.com/posts/marcosgarest_mcps1stbirthdayhackathon-activity-7400896699755470848-uE23
Policy Caliper is a Gradio app + MCP server that reads Terms/Privacy Policies and produces a risk report with topic-level severities, rationales, and citations. Unlike a generic “chat with your PDF” approach, the LLM is constrained to the structured MCP report (topics, risks, citations) instead of the raw policy text, making answers easier to audit and less prone to hallucinations. It supports:
Built to showcase an end-to-end MCP workflow: typed tools, LlamaIndex pipeline, and a polished UI with streaming progress and PDF export.
policy-drift-mcp).parse_policy → parse PDF/URL into documents.profile_policy → LlamaIndex index + topic summaries and citations.diff_policies (compare mode) → topic-level change types.assess_risk → batch LLM scoring (0–4) mapped to low/medium/high with rubric.generate_report → HTML/JSON report and optional PDF export.report_json (findings, topics/citations, sections A/B, diff) for grounded answers; it does not re-run tools.Server: policy-drift-mcp (FastMCP).
run_id is provided, one is generated. By default it caches the full document server-side and returns only metadata + run_id (set lightweight=False to return the documents).VectorStoreIndex, queries per topic, returns PolicyProfile. If run_id is present (argument or in the document), it will fetch cached docs from parse_policy. With lightweight=True (default for MCP), it trims the payload (one citation per topic, summaries trimmed, sections without body). Set lightweight=False if you need the full profile (used internally by Gradio).RiskSummary/DetailedRiskSummary.report_html, report_json, and PDF path via WeasyPrint.Recommended MCP flow (to avoid large payloads): call parse_policy first and reuse the returned run_id in profile_policy / diff_policies / assess_risk / generate_report. Keep lightweight=True (default) unless you explicitly need the full document inline.
report_json.parse_policy tries LlamaParse for PDFs (falls back to SimpleDirectoryReader), and SimpleWebPageReader for URLs; results stay in-memory per run_id.profile_policy uses SentenceSplitter to build nodes and a VectorStoreIndex with Gemini embeddings (gemini-embedding-001, 1536 dims) for retrieval.run_context caches documents, sections, and indices keyed by run_id, so repeated calls in the same session avoid re-parsing/re-indexing.Taken together, this makes LlamaIndex the core of the analysis pipeline: MCP tools never hit the raw PDF directly, they always operate on the structured view that LlamaIndex builds and maintains.
claude mcp add --transport http policy-drift-mcp http://127.0.0.1:9100/mcp/
Notes for the Hugging Face demo:
SimpleDirectoryReader and PDF parsing quality may be slightly lower.git clone https://huggingface.co/Warcos/PolicyCaliper.git
cd PolicyCaliper
pip install -r requirements.txt
cp .env.example .env # create the file and fill your keys
python app.py
Environment vars (see Configuration below) must be set before running.
User (browser)
-> Gradio UI (ui/gradio_app.py)
-> Orchestrator (agents/orchestrator.py)
-> MCP client
-> FastMCP server (policy-drift-mcp)
-> Tools: parse_policy, profile_policy, diff_policies, assess_risk, generate_report
-> LlamaIndex parsers + vector index + topic queries
-> Report HTML/JSON + PDF export (WeasyPrint)
For a deeper architecture/design overview (Spanish), see Extra/Guias/; they’re useful as extra context if you want an LLM to answer repo questions without browsing the code.
Single
Upload a PDF or paste a policy URL and click Analyze to generate a structured risk report by topic and severity.
Compare
Upload the previous ToS as Policy A and the updated ToS as Policy B and click Analyze to see topic-level changes and risk deltas between versions.
For example, you can try these public General Terms and Conditions from Serrala to see how the tool surfaces changes over time:
Once the workflow has produced a report, the Assistant can answer grounded questions on top of that analysis. For example:
policy-drift-mcp) with a full toolchain (parse, profile, diff, assess, report), run_id based caching, and lightweight payloads designed to work both in the Space and in external MCP clients (Claude Code).report_json, and the Assistant then performs grounded Q&A over that report instead of hitting the raw PDF on every turn.policy-drift-mcp server with typed tools for parsing, profiling, diff, risk, reporting.Environment variables (.env):
GEMINI_API_KEY — for LLM (gemini/gemini-2.5-flash-lite) and embeddings (gemini-embedding-001).STRICT_LOCAL_MODE=1 to force local parsing and block remote URLs.Settings (settings.yaml):
llm.model: gemini/gemini-2.5-flash-literate_limit.llm.requests_per_minute: e.g., 15embeddings.model: gemini-embedding-001embeddings.output_dimensionality: 1536embeddings.document_task_type: RETRIEVAL_DOCUMENTembeddings.query_task_type: RETRIEVAL_QUERYapp.py — Gradio entrypoint.ui/ — Gradio UI and styling.agents/ — orchestrator and tool runners.mcp_server/ — FastMCP server + tool definitions.domain/ — taxonomy, rules engine, report templates.llama_index_integration/ — models and parsers.persistence/ — in-memory session cache.Extra/Guias/ — internal guides (Spanish).settings.yaml and env vars accordingly.Apache 2.0