Skip to main content
Glama

ecfr-mcp

MCP サーバ ī. eCFR API... MCPサーバー? Let's provide actual final in Chinese as crafted.# ecfr-mcp

用于 eCFR(Electronic Code of Federal Regulations,美国联邦法规电子版)API 的 MCP 服务器。无需身份验证即可读取 FAR、DFARS 以及所有机构的 FAR 补充法规文本。

直接使用 MCP 服务器是高级用户自行维护的路径;打包智能体是受维护的新手入门路径。

已通过六轮对真实 eCFR API 的集成测试并进行了加固。295 个回归测试(182 个离线,113 个在线门控)覆盖了 2 个 P0 灾难性 bug、26 个 P1 静默错误数据 bug、32 个 P2 校验缺陷,以及第六轮审计修复(第48篇章节白名单、表格提取、附录访问)。完整测试记录见 testing.md。

它做什么

将 eCFR API 公开为 13 个 MCP 工具,涵盖法规文本、结构、搜索、版本历史和常见采购工作流:

核心端点

  • get_latest_date - 获取某个 CFR 篇章最新可用日期(在调用其他工具前调用)

  • get_cfr_content - 获取某个节、子部分或部分的已解析法规文本

  • get_cfr_structure - 章节层级目录

  • get_version_history - 某个节或部分的修订历史

  • get_ancestry - 面包屑层级路径

  • search_cfr - 支持层级过滤的全文搜索

  • list_agencies - 所有机构及其 CFR 引用

  • get_corrections - 某一篇章的编辑性更正

工作流便捷功能

  • lookup_far_clause - 一键查询 FAR/DFARS 条款文本(自动解析日期)

  • compare_versions - 两个日期下文本的并排比较

  • list_sections_in_part - 列出 FAR/DFARS 某个部分中的所有节

  • find_far_definition - 在 FAR 2.101 中查找术语定义

  • find_recent_changes - 查找自指定日期以来被修改的节

Related MCP server: mcp-ecfr

无需身份验证

eCFR API 完全公开。无需 API 密钥、无需注册、无需认证头。直接安装使用即可。

安装

通过 uvx 安装(推荐)

uvx ecfr-mcp

通过 pip 安装

pip install ecfr-mcp

从源码安装

git clone https://github.com/1102tools-dev/federal-contracting-mcps.git
cd federal-contracting-mcps/servers/ecfr-mcp
pip install -e .

配置

MCP 是一个开放标准,兼容的客户端均可运行此服务器。受维护的 1102tools Agent Setup Guide 涵盖 Codex 和 Claude Code 中打包智能体,这不包括独立服务器配置。请将以下块用作服务器配置定义,并调整其放置位置以适应你的客户端。

{
  "mcpServers": {
    "ecfr": {
      "command": "uvx",
      "args": ["--refresh-package", "ecfr-mcp", "--from", "ecfr-mcp", "ecfr-mcp"]
    }
  }
}

--refresh-package 标志要求 uv 在每次客户端启动服务器时都检查 PyPI 是否有更新版本,从而自动获得修复;如果省略该标志,uv 会一直使用首次缓存的版本。该标志会在启动时增加少许网络时间,因此如果你的平台强制设置了较短 MCP 启动超时,请调大该超时。

重启客户端。ecfr 服务器将出现,并带有 13 个工具。

示例提示

  • “抓取 FAR 15.305 (Proposal Evaluation) 的当前文本并总结其要求。”

  • “列出 FAR Part 19 (Small Business Programs) 中的所有章节。”

  • “在 2.101 中查找 FAR 对 'commercial product' 的定义。”

  • “过去 6 个月哪些 FAR 章节被修订过?”

  • “比较 FAR 52.212-4 在 2024-01-01 和 2025-01-01 之间的文本,并显示变化。”

  • “获取 DFARS 252.227-7014 (Rights in Noncommercial Computer Software) 的当前文本。”

  • “在第 48 篇中搜索 'organizational conflict of interest',并显示相关章节。”

  • “第 48 篇中第 8 章属于哪个机构?获取该机构的 FAR 补充结构。”

设计说明

  • 服务端解析 XML。 eCFR 内容端点返回原始 XML。此服务器会先将 XML 解析为清晰的文本(标题、段落、引文)再返回给模型,从而节省大量上下文 token。

  • 自动解析日期。 eCFR 比 Federal Register 晚 1-2 个工作日。在版本端点使用当天日期会导致 404 错误。所有内容工具都会自动解析到最新可用日期,除非你指定具体日期。

  • 搜索默认获取当前文本。 如果不使用 date=current,eCFR 搜索会返回所有历史版本(包括已被取代的版本)。默认的 current_only=True 可避免重复结果。

  • 结构端点限制。 eCFR 结构端点不支持按节过滤(返回 400)。list_sections_in_part 通过获取该部分的树状结构并遍历来解决此问题。

  • FAR 2.101 优化。 定义节约有 109KB XML。find_far_definition 在服务端解析整个节,仅返回与上下文匹配的段落。

CFR 第48篇快速参考

章

法规

部分

1

FAR

1-99

2

DFARS

200-299

3

HHSAR

300-399

4

AGAR

400-499

5

GSAR

500-599

6

DOSAR

600-699

7

AIDAR

700-799

8

VAAR

800-899

9

DEAR

900-999

18

NFS

1800-1899

数据来源

所有数据来自 ecfr.gov——由 Office of the Federal Register 维护、持续更新的在线版《美国联邦法规》(CFR)。每日更新,通常比 Federal Register 发布晚 1–2 个工作日。不是正式官方法律版本;如需官方引用,请参考 GPO 发布的年度 CFR。

所属项目

属于 federal-contracting-mcps,后者是面向联邦承包数据的 9 个 MCP 服务器组成的 monorepo。与 federal-contracting-skills 配套使用。

请求节奏控制

每个上游请求默认使用临时的 3 秒跨进程防突发间隔。eCFR 没有公布具体数值限制,因此这是 1102tools 为网络保护所设的安全防护措施,而不是提供方要求。可通过 FEDERAL_API_MIN_INTERVAL_SECONDS 覆盖,设为 0 可以显式关闭,使用 FEDERAL_API_PACING_DIR 可重新定位本地节奏控制状态。

许可

MIT

Available Tools

13 tools
compare_versionsA
Read-only
Inspect

Compare the text of a CFR section at two different dates.

Useful for understanding what changed in a regulatory amendment. Returns 'changes' (each paragraph that was added, removed or changed, with its before and after text; also heading, table and pending-amendment-link changes), 'identical' when nothing differs, and the parsed text at both dates side by side. When both texts together are too long to send, the full texts are left out (texts_omitted) and 'changes' is kept. changes_only=True leaves the full texts out every time: the short answer to "what changed".

Dates must be in YYYY-MM-DD format. Historical snapshot availability varies by title and section, including some dates before 2017. Use get_version_history to discover dates. Both dates must not exceed the title's up_to_date_as_of value.

This tool always returns the section-level XML parsed -- pass a small section_id like '15.305', not a whole part. Whole-part comparisons can exceed 100 KB per side.

Inputs: date_after (required), section_id (required), date_before (required), chapter, +2 more. Returns: object

find_far_definitionA
Read-only
Inspect

Find a term's definition in FAR 2.101, the FAR's main definitions section.

Returns each matching definition whole (the defining paragraph and every sub-paragraph under it), first, marked kind='definition'. Matching ignores case, hyphens, spacing, plurals, a trailing "means", and the acronym 2.101 puts in a name, so 'service-disabled veteran-owned small business concern', 'SDVOSB concern', 'COTS', 'commercial services' and 'contract means' all find their definitions. Other 2.101 paragraphs that use the term (whole words only) follow as kind='mention', each naming the definition it sits in.

When 2.101 doesn't define the term, the tool searches the rest of the FAR (chapter 1), then the DFARS (chapter 2), for "" means and returns where it is defined, with the definition text, under defined_elsewhere (for example 19.001 and 52.219-14 for 'similarly situated entity'; 204.7301 for 'covered defense information'), plus did_you_mean suggestions from 2.101.

term must be at least 3 characters. max_matches caps the number of matches returned (default 20, max 100); definitions are never cut, and truncated says whether mentions were left out.

Inputs: term (required), date, max_matches. Returns: object

find_recent_changesA
Read-only
Inspect

Find CFR sections changed since a given date, removals included.

Built on eCFR's version history: every version issued on or after since_date, newest first. Each change says whether the section was amended, removed (change='removed'), or re-issued with no text change (substantive=false). 'summary' counts each kind. A section changed twice appears twice.

since_date must be in YYYY-MM-DD format. Filter with title (default 48), chapter (Title 48: 1 = FAR, 2 = DFARS, 99 = CAS) or part. per_page (default 100, max 5000) and page step through long lists; total_pages says how many pages there are.

Common pattern: find FAR changes since a specific date to check for regulatory updates that might affect ongoing acquisitions.

Inputs: since_date (required), page, part, title, +2 more. Returns: object

get_ancestryB
Read-only
Inspect

Get the breadcrumb hierarchy path for a section, part, or appendix.

Returns ancestors from title down to the target node: title > chapter > subchapter > part > subpart > section. Useful for understanding where a section sits in the CFR hierarchy and what regulation it belongs to.

part/subpart/section/appendix accept int or string. The answer says which date it describes.

Inputs: date, part, section, subpart, +2 more. Returns: object

get_cfr_contentA
Read-only
Inspect

Get the full text of a CFR section, subpart, part, or appendix.

Returns parsed clean text by default: heading, paragraphs and citations, plus tables, notes, examples, images, pending_amendments and editorial_notes when present. Tables, notes and examples are numbered, and a marker like "[See table 1: ...]" sits in the paragraphs where each appears. [fn N] marks a footnote reference. pending_amendments means eCFR links a published amendment that may not be in effect yet. A subpart, part or appendix request returns one object per section under 'sections', each with its own section number and heading. Set raw_xml=True to get the original XML instead.

Answers longer than about 60,000 characters come in pages: the reply says page and total_pages, and page=2 (and so on) returns the rest.

Specify the narrowest scope possible to keep responses manageable:

  • section='15.305' for a single FAR section

  • subpart='15.3' for a subpart

  • part='15' for an entire part (can be large)

  • chapter='1' for an entire chapter (often >1 MB, avoid)

  • appendix='Appendix A to Chapter 2' (with chapter='2') for a DFARS appendix

Date auto-resolves to the latest available if not provided. Do NOT use today's date directly -- eCFR lags 1-2 business days and today often 404s.

Title 48 = FAR/DFARS. Chapter 1 = FAR (Parts 1-99), Chapter 2 = DFARS (Parts 200-299). Other chapters = agency FAR supplements (GSAR, VAAR, HSAR, etc.).

For DFARS clauses, use chapter='2' (e.g., section='252.227-7014').

part/subpart/section accept int or string. Common prefix mistakes like section='FAR 15.305' or '48 CFR 15.305' are stripped automatically, and trailing paragraph cites like section='15.305(a)(2)' resolve to the base section '15.305'.

Inputs: date, page, part, chapter, +5 more. Returns: object

get_cfr_structureA
Read-only
Inspect

Get the hierarchical table of contents for a CFR title or subset.

Returns a nested tree of titles, chapters, parts, subparts, and sections with identifiers, descriptions, and byte sizes, plus the date it describes.

IMPORTANT: Does NOT support section-level filtering (returns 400). Use part or subpart, then walk the children to find sections.

Common patterns:

  • part='15' for FAR Part 15 structure

  • subpart='15.3' for just that subpart's sections

  • chapter='1', depth=2 for the FAR's subchapters and parts only

  • appendix='Appendix A to Part 200' with part='200' (title 2) for one appendix

depth keeps that many levels below the node asked for (part='19', depth=1 gives Part 19's subparts); deeper levels are replaced by 'children_omitted' (how many there were). For the sections of one part, list_sections_in_part is shorter. A tree too large to send at once (a whole chapter is about 1 MB) is cut to the deepest depth that fits, and 'note' says so.

subchapter needs chapter in Title 48 (each chapter has its own subchapter A, B, ...). part/subpart/chapter/appendix accept int or string.

Inputs: date, part, depth, chapter, +4 more. Returns: object

get_correctionsA
Read-only
Inspect

Get editorial corrections for a CFR title, newest first.

Returns corrections with CFR references, corrective actions, error dates, and FR citations, sorted by the date the error was corrected, newest first. Useful for checking whether a section's current text has been corrected since its last amendment.

section (e.g. '52.204-21'), part (e.g. '52') or chapter (e.g. '2' for the DFARS) keeps only corrections that touch it. since_year keeps corrections with year >= since_year. limit caps how many are returned (default 50, max 1000); truncated says whether older ones were left out. Title 48 has ~280 corrections since 2005.

Inputs: part, limit, chapter, section, +2 more. Returns: object

get_latest_dateA
Read-only
Inspect

Get the most recent available date for a CFR title.

CRITICAL: eCFR lags 1-2 business days behind the Federal Register. Using today's date on versioner endpoints causes 404 errors. Call this first to get the safe date, then pass it to other tools.

Default title 48 = Federal Acquisition Regulations System (FAR, DFARS, and all agency supplements). Other common titles: 2 (Grants/Agreements), 5 (Administrative Personnel), 29 (Labor), 41 (Public Contracts).

Raises ValueError for titles 1-50 that are reserved (no content).

Inputs: title_number. Returns: object

get_version_historyA
Read-only
Inspect

Get the version history of a CFR section, subpart, or part.

Returns content_versions (each with date, amendment_date, issue_date, identifier, name, substantive and removed), every version eCFR lists: all of eCFR's pages are read, so Part 52's 2,264 versions are all there. Versions are grouped by section, oldest first.

since_date/until_date (YYYY-MM-DD) keep versions dated in that range. per_page (default 200, max 1000) and page step through long histories; total_count and total_pages say how many there are.

'substantive' is eCFR's flag: true when the version's text differs from the one before, including editorial edits such as citation fixes and the "Link to an amendment published at ..." notice eCFR adds when a rule is published; false when re-issued with no text change. To see what actually changed, use compare_versions on the dates.

'removed' true means the section was removed on that date.

Version metadata and text snapshots may include dates before 2017. Availability varies by title and section. Use the returned history dates for reads or comparisons; a missing old snapshot produces an availability error. A 2017-01-01 baseline often means unchanged since before 2017.

part/subpart/section accept int or string.

Inputs: page, part, section, subpart, +4 more. Returns: object

list_agenciesA
Read-only
Inspect

List all agencies with their CFR title and chapter references.

Returns agency names, slugs, and which CFR titles/chapters they own. Useful for finding which chapter corresponds to an agency's FAR supplement.

summary_only (default True) strips the children and most of cfr_references to keep the response compact (~20 KB vs ~100 KB). References owned by child agencies are merged into the parent row, so chapter lookups like DFARS (chapter 2, on a DoD child agency) still work in summary mode. Set False for the full raw payload including children.

Inputs: summary_only. Returns: object

list_sections_in_partA
Read-only
Inspect

List all sections and appendices in a CFR part with their headings.

Returns 'sections' in order, each {identifier, heading}, with type='appendix' on appendices (2 CFR 200's Appendix I-XII, for example) and reserved=true on reserved sections, plus 'subparts' (each with its heading, section_count and first and last section). Useful for seeing the scope of a part before reading specific sections.

The part number alone is enough: chapter is optional (Title 48 parts are unique: 52 = FAR, 252 = DFARS, 552 = GSAR) and the answer reports the chapter the part is in. subpart (e.g. '52.2') lists one subpart. A list too long to send at once (FAR Part 52 has 680 entries) comes in pages: page and total_pages say where you are; page=2 gets the rest. detail=True adds eCFR's label, size and received_on for each entry (received_on is when eCFR processed the text, not when it was amended; get_version_history has amendment dates).

part_number accepts int or string.

Inputs: part_number (required), date, page, detail, +3 more. Returns: object

lookup_far_clauseA
Read-only
Inspect

Convenience tool: look up the current text of a FAR, DFARS or FAR supplement section or clause.

Pass a section identifier like '15.305', '52.212-4', '2.101', 'DFARS 252.204-7012' or '552.238-81'. The chapter comes from the number (52.x = FAR, 252.x = DFARS, 552.x = GSAR, 852.x = VAAR, 1852.x = NFS, 3052.x = HSAR), so chapter is optional. Prefixes like 'FAR', 'DFARS', '§' and '48 CFR', en dashes, and trailing paragraph cites such as '(d)(11)(xviii)' are handled.

Auto-resolves the latest available date. Returns parsed clean text with heading, paragraphs and citations, plus tables, notes (such as drafting notes, which are not clause text), examples, images and pending_amendments when present; see get_cfr_content. A clause longer than about 60,000 characters comes in pages: use page=2 and so on.

Common FAR sections: 2.101 (Definitions), 9.104-1 (Responsibility), 15.305 (Proposal Evaluation), 19.502-2 (Small Business Set-Asides), 52.212-4 (Commercial Terms), 52.212-5 (Required Commercial Terms).

Inputs: section_id (required), date, page, chapter. Returns: object

search_cfrA
Read-only
Inspect

Full-text search across the Code of Federal Regulations.

Returns matching sections with excerpts, headings, scores, and hierarchy.

current_only=True (default) returns only text in effect now. eCFR's own "current" index still lists some superseded and removed versions, so each hit is checked against the section's version history: older copies of a section are dropped, and hits whose text has since been replaced or removed are dropped and listed under current_check ('superseded' with the current version's date, 'removed' with the removal date). Up to 10 parts per page are checked; any hit not checked is marked. current_only=False returns every historical version, so a section amended 5 times appears 5 times.

Search caps at 10,000 total results. Use hierarchy filters (title, chapter, part) to narrow if you hit the cap. chapter/part/subpart/section filters need a title; without one, title 48 is assumed (title_assumed says so). Labels like 'FAR Part 15', 'Subpart 15.3' or '§ 52.212-5' are read as 15, 15.3 and 52.212-5. Most titles other than 48 number chapters in Roman numerals (2 CFR chapter 'II').

order controls result ordering: 'relevance' (default), 'newest_first', 'oldest_first', 'hierarchy', or 'citations'.

agency_slugs filters to one or more agencies (single slug string or a list, e.g. 'defense-acquisition-regulations-system'). Use list_agencies() to find slugs.

last_modified_after/before use YYYY-MM-DD format and filter by the date sections were last amended. Useful for finding recent regulatory changes.

per_page accepts 1 to 5000 (default 20); paginate with page for more.

Inputs: query (required), page, part, order, +9 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 13 tools

    Disambiguation4/5

    Most tools target distinct actions: search, structure, ancestry, version history, recent changes, definitions, corrections, and agency lookup are clearly differentiated. The main overlap is get_cfr_content versus lookup_far_clause, since both retrieve current section/clause text, though lookup_far_clause is framed as a convenience wrapper and the descriptions help distinguish them.

    Naming Consistency5/5

    All tool names use snake_case and generally follow an action_scope pattern such as get_cfr_content, get_version_history, list_sections_in_part, find_recent_changes, and compare_versions. The verbs vary by purpose but remain predictable and there is no mixing of naming conventions.

    Tool Count5/5

    With 13 tools, the server is well-scoped for a read-only CFR/FAR research domain. Each tool covers a meaningful operation such as content retrieval, search, hierarchy, version history, corrections, or agency metadata, without obvious filler.

    Completeness4/5

    The surface covers the core needs of CFR research: content retrieval, search, definitions, structure, ancestry, version history, recent changes, corrections, agency mapping, and version comparison. Minor gaps remain, such as no explicit title-listing or broader metadata tool, but the main regulatory workflows are well supported.

    Maintenance

    ActivityActive
    ResponsivenessUsually handled

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      C
      maintenance
      A production-quality MCP server that exposes the official eCFR API as structured tools for AI-driven contract compliance, enabling retrieval of relevant Code of Federal Regulations by clauses extracted from contracts.
      8
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables searching, browsing, and retrieving current US Code of Federal Regulations text—including full-text search across all 50 titles, title structures, and exact section or part wording—via the official eCFR API.
      74 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables searching and reading the US Code of Federal Regulations through tools that return excerpts, full text, legal citations, and linked source URLs, with read-only, stateless access.
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables searching and retrieving U.S. Federal Register documents — final and proposed rules, notices, executive orders, and public inspection filings — plus facet counts, agency listings, open comment deadlines, and FAR/DFARS case histories, through eight tools backed by the keyless public API v1.
      53 npm
      MIT