Skip to main content
Glama
README.md
# far-mcp

MCP server for US federal acquisition regulations: dated, cited access to **FAR** and **DFARS**
text, plus how the **Revolutionary FAR Overhaul (RFO)** changes it.

Every result carries its **source URL** and **effective date**. The server does not answer from
memory: `far_mcp.provenance` raises instead of returning a result that lacks provenance, so a
sourced answer is enforced in code rather than requested in a prompt.

> **This is not legal advice.** far-mcp reproduces published regulation text from official
> sources and labels its own plain-English summaries as summaries. It does not assess your
> facts, your contract, or your agency's deviation. Confirm against the cited source and talk
> to counsel.

## Tools

| Tool | What it does |
|---|---|
| `get_clause(id, as_of_date?, include_deviations?, regulation?)` | Clause text as of a date, plus RFO/agency deviation text when asked |
| `search(query, regulation?, part?, as_of_date?, limit?)` | Keyword search over clause and section text |
| `get_section(citation, regulation?)` | Full section by cite, e.g. `9.104-1` |
| `list_reps_certs(regulation?)` | The FAR 52.204-8 / 52.212-3 representations set; `summary` is null until a reviewer authors one |
| `applicable_clauses(contract_type, value?, commercial?, agency?)` | Applicability by contract type from the official Smart Matrix |
| `diff(id, from_date, to_date, regulation?)` | Change between two dates, including FAR vs RFO deviation text |
| `whats_new(since_date)` | Federal Register rules, eCFR amendments, RFO part updates |
| `cite(id, regulation?)` | Formatted citation with URL and effective date |

### Plain-English summaries

`list_reps_certs` may return a plain-English summary and a note on what an answer commits you
to. These are **curated by human review**, stored in the `summary` table, and never written by
the ingest job. Until a reviewer authors one the tool returns `summary: null` with
`summary_kind: "none_authored"` — it does not synthesise prose, because a plausible-sounding
summary of a representation is exactly the kind of text that must not be invented.

Every non-null summary is labelled `summary_kind: "plain_english_summary"` and
`summary_is_not_legal_text: true`, so a consumer cannot mistake it for regulation text.

## Setup

Requires Python 3.12+.

```bash
git clone https://github.com/SureForgeTech/sureforge-far-mcp.git
cd sureforge-far-mcp
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
```

### Build the local store

The tools read a local SQLite store; they do not call the network at query time. Ingest it
first (about 2–4 minutes, then a few minutes for agency deviation PDFs):

```bash
.venv/bin/python -m far_mcp.ingest.runner            # all phases
.venv/bin/python -m far_mcp.ingest.runner --phase matrix   # one phase
.venv/bin/python -m far_mcp.ingest.runner --force          # ignore checkpoints
```

Phases run in order — `freshness, versions, clauses, historical_text, matrix, rfo, deviations,
federal_register, finalize` — and each checkpoints into `ingest_run`, so an interrupted run
resumes where it stopped instead of re-fetching. The store lands at `data/far-mcp.db`
(gitignored: it is derived data).

Querying an empty store raises rather than returning empty, authoritative-looking answers:
far-mcp answers from the store, never from memory or the network.

### MCP config for Claude

Claude Desktop (`claude_desktop_config.json`) and Claude Code (`claude mcp add`):

```json
{
  "mcpServers": {
    "far-mcp": {
      "command": "/absolute/path/to/sureforge-far-mcp/.venv/bin/python",
      "args": ["-m", "far_mcp.server"],
      "env": {
        "FAR_MCP_DB": "/absolute/path/to/sureforge-far-mcp/data/far-mcp.db"
      }
    }
  }
}
```

Or from a shell:

```bash
claude mcp add far-mcp --env FAR_MCP_DB=$PWD/data/far-mcp.db -- \
  /absolute/path/to/sureforge-far-mcp/.venv/bin/python -m far_mcp.server
```

`FAR_MCP_DB` defaults to `data/far-mcp.db` relative to the working directory, so setting it
explicitly avoids surprises when the client launches from a different cwd.

## Data freshness

Freshness is **measured**, not asserted. The store records the source's own markers and exposes
them through `source_freshness()`:

| Marker | Meaning |
|---|---|
| `ecfr_up_to_date_as_of` | Date through which eCFR text is current (`2026-12-01` at last ingest) |
| `ecfr_latest_amendment_date` | Most recent amendment to Title 48 (`2026-11-19` at last ingest) |
| `last_ingest_at` | When this store was last refreshed |

`as_of_date` queries past `ecfr_up_to_date_as_of` are **rejected** rather than answered with
newer text, so a historical question can never be silently answered with today's regulation.

Refresh daily with the same command. It stays cheap because each phase **probes the source
first** and only does the expensive work when the probe shows a change:

- `freshness` always runs — one request to `titles.json`. It is the probe that tells the
  downstream phases whether eCFR moved; keying it on its own stored marker would freeze the
  whole refresh.
- `matrix`, `rfo` and `federal_register` hash one cheap response (baseline Smart Matrix page,
  RFO deviation guide, newest Federal Register document) and skip their full pull when it is
  unchanged.
- `versions`, `clauses`, `historical_text` and `finalize` re-run only when the eCFR coverage
  marker advances.
- `historical_text` fills any version span still missing point-in-time text, so `as_of_date`
  returns the wording actually in force rather than an empty string.

The Federal Register slice records `last_fr_run` for `whats_new`.

### Sources

| Source | Used for |
|---|---|
| [eCFR API](https://www.ecfr.gov/developers/documentation/api/v1) | Title 48 text (Ch. 1 FAR, Ch. 2 DFARS), point-in-time versions, hierarchy, keyword search |
| [acquisition.gov](https://www.acquisition.gov/far-overhaul) | Smart Matrix, RFO part pages, agency deviation PDFs |
| [Federal Register API](https://www.federalregister.gov/developers/documentation/api/v1) | Proposed/final FAR and DFARS rules by FAR Case |
| [govinfo.gov](https://www.govinfo.gov/) | Official PDF of record — reached via the Federal Register's `pdf_url` |

**Not used:** SAM.gov is never scraped, and no entity registration answers are stored. Those are
CUI. This project holds only published regulation text.

## Known limitations

These are properties of the official sources, not TODOs to work around:

1. **No dollar thresholds.** FAR 52.301 states the matrix "is not carried in the CFR" and
   defers to `acquisition.gov/smart-matrix`, whose table has only *clause, effective date,
   prescribed-in, P/C*. `applicable_clauses(value=…)` therefore reports `value` as
   **unapplied** with the reason, rather than inventing numbers. Contract type **is** honoured
   exactly, via the matrix's own R/A/O filters.
2. **No commercial flag, no agency rows in the matrix.** Same reason; both are reported under
   `unsupported_parameters`.
3. **RFO model text has no clause-level date.** It prints a `(Deviation Date)` placeholder, so
   RFO version spans use the **part issuance date** as `effective_from`.
4. **Agency deviation text is PDF-only.** There is no HTML or XML alternative; text comes from
   PDF extraction and may vary in fidelity by agency.
5. **No separate RFO matrix.** The RFO pages link back to the same Smart Matrix.
6. **No DFARS matrix.** Only `clause-matrix-far-view` (FAR) is published.
7. **No acquisition.gov API.** HTML parsing is required and may break if the site is redesigned.
8. **Search is keyword-only (FTS5).** Vector search is a later, optional extension.
9. **FAR Case numbers are not a first-class Federal Register field.** They are parsed from
   `docket_ids`; `conditions[docket_id]` is a loose substring and is deliberately not used as a
   filter (it returns unrelated filings).
10. **46 of 2,741 version spans have no usable source text.** eCFR's versions feed lists an
    identifier for a date on which its `full` endpoint returns only a placeholder — for
    `52.224-3` at 2017-01-01 the section is present but its body is just a cross-reference to
    a later amendment, with no operative text. `get_clause` **refuses** these with an
    explanatory error rather than returning an empty string, because "the clause was empty"
    is a false statement an agent would repeat. Counted as `spans_without_source_text` in
    `source_freshness()`.
11. **Point-in-time fetches use `issue_date`, not the amendment date.** eCFR's `full` endpoint
    404s on some amendment dates — `252.203-7001` is amended 2016-12-22 but only served from
    2017-01-01 — so historical text is fetched on `issue_date`, the first date the source
    actually serves that version. This differs from `effective_from` for 1,093 of 2,741 spans.

RFO reserves clauses that are live in the current FAR — `52.204-26`, `52.212-3` and `52.204-8`
are `[Reserved]` under RFO. `diff` returns both texts and says which is which; that difference
is the point of the tool, not an edge case.

## Tests

```bash
.venv/bin/python -m pytest                  # offline unit tests (default)
.venv/bin/python -m pytest -m network       # live government endpoints (opt-in)
```

Golden fixtures cover ten clauses and assert **text, date and URL** — including
`52.204-26`, `52.209-5`, `52.212-3`, `52.219-1`, `252.204-7012` and `252.204-7016`.
`tests/test_provenance.py` fails if any tool result lacks a source.

## License

Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).

TDQS

B3.4/5.0

Scored across 8 tools

Disambiguation4/5

Most tools are clearly separated by resource and intent: cite (formatting), get_clause/get_section (text retrieval), search (keyword index), diff (per-clause comparison), whats_new (global change feed), list_reps_certs and applicable_clauses (curated datasets). The main soft spot is the retrieval trio (search vs get_clause vs get_section) and the change trio (diff vs whats_new), which an agent must read carefully to pick correctly, though the descriptions do resolve the boundaries.

Naming Consistency3/5

There is a partial verb_noun convention (get_clause, get_section, list_reps_certs) but it is mixed with bare verbs (cite, diff, search) and noun phrases (whats_new, applicable_clauses). Each name is readable and domain-meaningful, but the set does not follow one predictable pattern.

Tool Count5/5

Eight tools is well within the sweet spot, and each maps to a distinct capability (citation, text lookup, search, comparison, change tracking, reps/certs, applicability matrix). No tool feels redundant or filler.

Completeness4/5

The surface covers the core regulatory lifecycle: find (search), retrieve (get_clause/get_section), cite, compare across dates, track amendments, and derive applicability. Gaps are minor but real — no cross-reference/definition lookup (e.g. 'what clauses does this clause reference' or defined-term resolution) and no structural navigation of parts/subparts, which agents would otherwise need.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues