Refract MCP Server
This MCP server exposes the Refract agent so an MCP client (Claude Desktop, Cursor, etc.) can browse subject profiles and stored news, run grounded personalized insights on a news event, ask follow-ups, and inspect full traces.
Browse subjects —
list_profileslists available profiles (id, kind, summary);get_profilereturns a subject's full profile as JSON.Find relevant news —
news_feedranks stored events for a subject by code-computed relevance (with reasons) and supports asincedate,toplimit;list_eventsshows the latest events in the store.Get a digest —
news_briefruns the agent on the top few items and returns each insight cut to a paragraph, highest impact first (slower, top ≤ 5).Analyze an event —
analyze_newsruns the full agent (given anevent_id, or a title/text/URL) for a profile with a chosen reader role (owner, ceo, cfo, chief_accountant, treasurer, entrepreneur, individual, other) and language (ru/en), returning what the news means for that subject.Follow-up Q&A —
ask_followupanswers questions about an insight produced in the session, under the same grounding checks.Audit provenance —
get_traceshows every tool and model call, timing, cost and review findings for an insight.Search house research —
search_researchqueries the institution's research documents to ground house views.
Can use Ollama as a local OpenAI-compatible LLM endpoint, with configuration examples and preflight checks for structured output, context window, and hidden reasoning.
Supports OpenAI-compatible LLM endpoints for tagging, planning, drafting, revising, verification, and chat, with per-step model routing, failover, cost accounting, and disk caching.
Fetches and deduplicates RSS/Atom news feeds into events, and ranks stored news for a subject by relevance before analysis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Refract MCP Server show me the personalised news feed for demo_building_materials"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Refract
A traceable LLM agent that turns a news event into a grounded, personalised insight — for a company, a sole proprietor, a self-employed person or a private individual.
One piece of news means different things to different readers. Refract refracts it through the profile of each reader: what happened, why it matters to them, which risks and opportunities follow, what the institution's analysts think, and what can be done next. Every statement carries its origin — fact, house view, AI inference or hypothesis — and the sources it rests on. Code, not the model, enforces grounding, caps the impact level and decides which products may be offered. Every step is recorded in a trace.
ev_rate_hold_ru × demo_building_materials (wholesaler with loans, a developer as its largest customer)
→ headline The 14% rate stays: cheaper loans and leasing are postponed
→ why [AI inference] loans and leasing — debt service will not get cheaper (features: products.loans …)
[Hypothesis] the largest customer is a developer (31% of incoming payments) …
→ house view [Demo Bank view] rate to stay at 14% until end-2026 (p. 2 of the macro outlook)
→ action discuss fixing the rate — product: fixed-rate loan (rule fix_rate fired)
→ trace rule check caught an invented “1.2 bn” → revision → policy removed a product no rule allowsContents
Related MCP server: finance-pulse
Why Refract
Personalised, not summarised. Every “why it matters” statement must cite features of the subject (
products.loans,counterparties.customer.cp_dev_101,tax_regime…). Unknown feature keys are rejected by code.Provenance on every statement.
fact·house_view·ai·hypothesis. A statement attributed to the institution must cite its research; a fact must cite a source; a hypothesis carries a caveat.Deterministic guard rails. Numbers absent from the context are caught; the impact level is capped by a ceiling computed from subject–event links; products appear only when a policy rule fired on the subject's features. A prompt injection in the news cannot raise the impact or add a product.
Self-verification. Rule checks plus a review by a second model; the agent searches for more data, revises, and cuts what still fails.
Any subject. Companies, sole proprietors, self-employed people and private individuals, with reader roles from CFO and treasurer to “entrepreneur” and “individual”.
Bilingual. Insights in Russian or English, whatever the language of the news.
Provider-agnostic. Any OpenAI-compatible endpoint: OpenAI, OpenRouter, LiteLLM, vLLM, Ollama, LM Studio — with per-step model routing, failover, cost accounting and a disk cache.
A personal feed. Of a hundred news items, code picks the few that concern this subject and says why, before any model is asked.
Ready to integrate. Python API, CLI, REST API with live progress (SSE), MCP server, RSS collector.
Ready to study. Built-in ablations, baselines, multiple LLM judges, inter-judge agreement and bootstrap confidence intervals.
How it works
flowchart TB
IN([Subject profile + news event]) --> P[Profile tool]
P --> T{Event tagged?}
T -- no --> C[Tag the news: type, factors,<br/>NACE codes, countries, importance]
T -- yes --> PL
C --> PL[Plan: 3–6 tool calls]
PL --> TL[Tools: house view, research search,<br/>counterparties, group, related news]
TL --> D[Draft insight by JSON schema]
D --> A[Attribution: features and sources<br/>the model left out]
A --> V[Self-check: rule checks + second model]
V -- errors, data missing --> M[Extra research search]
M --> R[Revise]
V -- errors --> R
R --> A
V -- clean or rounds exhausted --> F[Finalize: cut unsupported statements,<br/>cap impact, enforce action policy,<br/>rewrite a rejected headline]
F --> OUT([Insight + trace])Component | Where | What it does |
Orchestrator |
| the loop above; |
Context |
| subject features with keys, the event, links, the house view, the source registry |
Impact ceiling |
| strength of each subject–event link → the highest impact level allowed |
Rule checks |
| sources, origins, feature keys, numbers, the ceiling; attribution repair, pruning and restoring |
Action policy |
| which rules fire; product names, one product per insight, manager first on high negative impact |
Chat |
| follow-up questions on the same context, with the same checks |
Prompts |
| every step in Russian and English, versioned |
Details: docs/agent.md · docs/architecture.md · docs/data-model.md · docs/cli.md.
Quick start
Requires Python 3.10+. With uv:
git clone https://github.com/Rinneway/refract.git
cd refract
uv sync --all-extras
uv run refract demo # scripted run — no API key needed
uv run refract demo injection # a news item with a prompt injection
uv run refract demo dollar # an English run: a misattributed house view and a rejected headline
uv run refract demo --list # the pairs with recorded answers of real models
uv run refract shell --demo # the interactive console: subjects, feed, analysis, trace
uv run refract analyze --demo --profile demo_grain_farm --event ev_wheat_en
uv run refract brief --demo --profile demo_building_materialsrefract demo scripts the model's answers to show a check at work. --demo on analyze, feed, brief, serve and mcp replays recorded answers of real models (qwen3.5:9b drafting, gemma4:12b verifying) on the demo data. Either way the tools, retrieval, rule checks, the impact ceiling, the action policy and the trace are the current code; the trace names the model as recorded:… or scripted.
With a model:
cp .env.example .env # set LLM_BASE_URL, LLM_API_KEY, REFRACT_MODEL
uv run refract profiles # synthetic subjects in examples/demo
uv run refract events
uv run refract analyze --profile demo_coffee_ip --event ev_usn_vat_ru --role entrepreneur --lang en --out runs/
uv run refract analyze --profile demo_family_saver --role individual \
--title "Mortgage rates fall below 18%" --text-file news.txt
uv run refract chat --run runs/<insight_id>.json --q "What does it mean for my plans to open a bakery?"Free: Ollama locally (Ollama Cloud now bills in credits beyond a few starter models) — copy examples/config/ollama-local.toml or ollama-cloud.toml to refract.toml and run uv run refract check: it verifies structured output, the context window and hidden reasoning before you spend time on runs. Providers without native structured output fall back to JSON mode and then to the schema in the prompt.
With pip: pip install "refract-agent[api,mcp,pdf] @ git+https://github.com/Rinneway/refract".
With Docker: docker build -t refract . && docker run --rm -p 8000:8000 refract starts the API in demo mode; docker compose up adds local models in Ollama. See docs/deployment.md.
Interfaces
Console — uv run refract shell (add --demo to try it without a model) on Windows, macOS and Linux: choose a subject, read its feed, explain a news item with the agent's steps shown live, ask follow-up questions, read the sources and the trace. Every command is also a one-shot CLI command (refract analyze, feed, brief, chat …): docs/cli.md.
Python
from refract import Refract
rf = Refract.from_dir("examples/demo")
run = rf.analyze("demo_london_studio", "ev_dollar_en", role="cfo", language="en")
print(run.insight.headline, run.insight.overall_impact)
for claim in run.insight.why_it_matters:
print(claim.origin.value, claim.text, claim.source_ids, claim.features)
answer = rf.chat(run.insight.insight_id, "Should we hedge?").responseREST API — uv run refract serve, OpenAPI docs at /docs:
curl -s localhost:8000/insights -H 'content-type: application/json' \
-d '{"profile_id": "demo_grain_farm", "event_id": "ev_wheat_en", "language": "en"}'
# → {"job_id": "…"}; live steps: curl -N localhost:8000/jobs/<job_id>/streamMCP — uv run refract mcp exposes list_profiles, news_feed, analyze_news, ask_followup, get_trace, search_research to Claude Desktop, Cursor and other MCP clients.
News — refract news fetch --feeds examples/feeds.example.json --data my_data collects RSS/Atom feeds into deduplicated events (titles, links, feed summaries; no full texts). refract feed --profile demo_coffee_ip ranks the stored news for one subject by code — which concern it directly, which are background, and why; --analyze 3 explains the top three.
Your own research — put Markdown, text or PDF files into knowledge/docs/; refract theses --docs … --out knowledge/theses.json extracts the institution's theses and keeps only those whose quote is found verbatim on the page.
All interfaces: docs/integrations.md · every command: docs/cli.md.
Configuration
Environment variables (or .env) override refract.toml (see refract.example.toml).
Variable | Default | Purpose |
|
| endpoint; several, comma-separated, are tried in order |
| — | key for the endpoint |
|
| model for tagging, planning, drafting, revising and chat |
| = | model for the review step and default judge; another family is better |
|
| language of insights: |
| — | enables hybrid BM25 + dense retrieval |
|
| folder with |
| — | require |
In refract.toml you can also route each step to its own model, set prices for cost accounting, name the institution whose research forms the house view, switch product offers off, and point to your own roles and action rules. See docs/configuration.md.
Evaluation and research use
refract eval pairs --data examples/demo --out runs/exp1/pairs.jsonl --languages ru,en
refract eval run --out runs/exp1 --systems full,no_plan,no_verifier,no_rules,no_cap,no_policy,single_call,retelling
refract eval judge --out runs/exp1 --judges verifier,judge2
refract eval label export --out runs/exp1 --sample 40 # optional: a blinded sheet for human labels
refract eval label import --out runs/exp1
refract eval report --out runs/exp1 --reference fullSystems: the full agent, nine ablations (
no_plan,no_verifier,no_rules,no_revise,no_self_check,no_cap,no_policy,no_attribution,no_reconcile) and two baselines (single_call— the same prompt and house view in one call;retelling— one call with a plain prompt).Judge metrics: six questions scored 0–2 (what happened, why it matters, consequences, actions, house view, grounding), overall 1–5, unsupported statements, retelling and impact calibration.
Code metrics that need no judge: rule errors reaching the reader, invented numbers, impact above the computed ceiling, answers not in the requested language, cost, latency; results are also split by output language.
Human labels: a blinded, shuffled sheet with the judge's rubric; imported as one more judge, so the report shows how far each LLM judge agrees with people.
Statistics: 95% bootstrap CIs, paired differences, sign tests, quadratic-weighted κ and Spearman for every pair of judges, accuracy and κ against human labels.
Reproducibility: prompt versions and the agent configuration are written into every trace; model answers are cached by request hash.
Method, metrics and threats to validity: docs/evaluation.md. A plan for a paper: docs/paper/outline.md.
Pilot so far (docs/results/smoke-2026-11.md): 8 synthetic pairs, local models (qwen3.5:9b writing, gemma4:12b reviewing), three judges. On judge scores the agent beats a plain retelling but not a single call with the same context. What sets it apart is measured by code: no rule errors and no invented numbers reached the reader, against rule errors in 62% of single-call answers. The judges agree poorly with each other (κ 0.12–0.27), and no human labels exist yet, so this is a pilot, not evidence of quality.
Project layout
src/refract/
agent/ orchestrator, context, tools, checks, impact ceiling, action policy, chat, progress
prompts/ prompts of every step, ru + en
schemas/ Pydantic contracts and the shared vocabulary (factors, NACE, ISO countries)
knowledge/ data store, BM25 / hybrid retrieval, document ingestion, thesis extraction
llm/ OpenAI-compatible client, scripted model for tests and demos
eval/ experiments, judges, statistics, report
news/ RSS / Atom collector
policies/ reader roles and action rules (JSON)
api.py mcp_server.py cli.py shell.py facade.py render.py demo.py
examples/demo/ synthetic profiles, news, research, evaluation pairs and recorded model answers (ru + en)
docs/ architecture, agent, data model, configuration, CLI, integrations, deployment, evaluation, paper outline, JSON Schemas
tests/ 194 tests on a scripted model and a fake OpenAI-compatible server — no network neededData and confidentiality
Refract grew out of the author's agent component in an earlier team project on news analytics. That project worked with data and documents that cannot be published, so this repository is a standalone re-implementation and contains none of them: no client data (even anonymised), no internal research or theses, no infrastructure addresses, no keys. Everything in examples/ — subjects, news, research notes and the “Demo Bank” itself — is invented; numbers in it do not describe real events. A test fails if strings shaped like client ids of the original data or like API keys appear anywhere in the repository. Details: docs/provenance.md.
Limitations
Insights are only as good as the profile: the agent sees what the profile says and nothing else; it does not know about products at other institutions.
Number checks match numbers against the whole context, not the cited source; a number that appears elsewhere in the context passes.
The impact ceiling and the action policy are hand-written rules; thresholds are configurable but not learned.
English prompts are translations of prompts tuned on Russian news; check them with the parity run in docs/evaluation.md before relying on them.
An LLM judge is not a human expert; report agreement between judges and validate on human labels.
Quality has been measured only in a pilot: 8 synthetic pairs, LLM judges, no human labels (see above). The checks make answers safer, not richer: after cutting what is wrong they can leave a thinner answer, which judges score lower.
Refract produces information, not individual investment, tax or legal advice.
Citing
If you use Refract in research, please cite it via CITATION.cff (GitHub shows a “Cite this repository” button).
License
MIT. Contributions are welcome — see CONTRIBUTING.md.
Available Tools
9 toolsanalyze_newsC
Run the agent: what the news means for the subject. Give an event_id, or a title and text. role: owner, ceo, cfo, chief_accountant, treasurer, entrepreneur, individual, other. language: ru or en.
Inputs: profile_id (required), url, role, text, +4 more. Returns: result
ask_followupC
A follow-up question about an insight produced in this session.
Inputs: question (required), insight_id (required). Returns: result
get_profileC
The full profile of a subject as JSON.
Inputs: profile_id (required). Returns: result
get_traceB
How an insight was produced: every tool call and model call with timing, cost and review findings.
Inputs: insight_id (required). Returns: result
list_eventsC
Latest news events in the store.
Inputs: limit. Returns: result
list_profilesC
Subjects available for analysis: id, kind and a short summary.
Inputs: no named parameters. Returns: result
news_briefA
The strongest news for the subject, each explained by the agent and cut to a paragraph, highest impact first. Slower than news_feed: one agent run per item (top ≤ 5).
Inputs: profile_id (required), top. Returns: result
news_feedA
Which stored news concern the subject, strongest links first — ranked by code, with the reason for each. since: YYYY-MM-DD. Use analyze_news on an event_id from the list to get the full insight.
Inputs: profile_id (required), top, since. Returns: result
search_researchC
Search the institution's research documents.
Inputs: query (required), limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools target clearly different steps: profile discovery, event listing, research search, analysis, follow-up, and tracing. The news cluster (list_events, news_feed, news_brief, analyze_news) overlaps conceptually, but descriptions explain their distinct roles, especially the ranked-feed vs synthesized-brief vs deep-analysis distinction.
All names use snake_case and are readable. Most follow a verb_noun pattern (search_research, analyze_news, ask_followup, get_profile, get_trace, list_events, list_profiles), though news_brief and news_feed are noun phrases rather than action-oriented names.
Nine tools is well within the ideal range and each appears to earn its place in a coherent analysis workflow. The set covers discovery, ranking, synthesis, follow-up, and provenance without obvious redundancy.
The surface covers the core lifecycle: list subjects, get profiles, inspect events, rank/filter news, run analysis, ask follow-ups, and inspect traces. Minor gaps exist around research-document retrieval or broader insight listing, but the main workflows are supported.
Maintenance
Related MCP Connectors
Machine-readable entity discovery with provenance, trust and verified source evidence.
Give your AI assistant access to the world’s news. Search articles in any language, track coverage over time, and research companies and events.
Read-only cited financial datasets, bounded research queries and source diagnostics.
Real-time financial news & regulatory intelligence: cited search, fetch, summaries, collections.
Related MCP Servers
AlicenseAqualityCmaintenanceEnables AI clients to query and analyze aggregated multi-platform trending news through natural language, offering tools for trend tracking, sentiment analysis, similarity search, and other news intelligence tasks.27GPL 3.0- AlicenseAqualityBmaintenanceLets MCP clients query financial news as structured, sourced statements and topics — searching by symbol, sector, theme, sentiment, importance and time range, and retrieving trending developments, topic detail, news-volume and sentiment series, and attention-screened symbols or sectors. It also exposes reference metadata such as the data window and known incidents.1223 PyPIMIT
- AlicenseNot gradedqualityCmaintenanceEnables users to run deep research, quick searches, and report writing, and to retrieve research sources and context through MCP-compatible clients.MIT

trendradar-mcpofficial
AlicenseNot gradedqualityBmaintenanceEnables AI clients to access aggregated multi-platform trending topics and RSS feeds, filter news by keywords, and perform natural-language analysis, sentiment insights, and trend prediction.GPL 3.0