Skip to main content
Glama

get_cfr_structure

Read-only

Retrieve the hierarchical table of contents for a CFR title or subset, returning a nested tree of titles, chapters, parts, subparts, and sections with identifiers and descriptions.

Instructions

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.

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

Common patterns:

  • chapter='1' for all FAR parts

  • chapter='2' for all DFARS parts

  • part='15' for FAR Part 15 structure

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

part/subpart/chapter accept int or string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
title_numberNo
dateNo
chapterNo
subchapterNo
partNo
subpartNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler function for 'get_cfr_structure'. Validates inputs, resolves the date, builds a request to the eCFR structure API endpoint, and returns the hierarchical table of contents as JSON.
    @mcp.tool(annotations={"title": "Get CFR Structure", "readOnlyHint": True, "destructiveHint": False})
    async def get_cfr_structure(
        title_number: int = 48,
        date: str | None = None,
        chapter: Any = None,
        subchapter: Any = None,
        part: Any = None,
        subpart: Any = None,
    ) -> dict[str, Any]:
        """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.
    
        IMPORTANT: Does NOT support section-level filtering (returns 400).
        Use part or subpart, then walk the children to find sections.
    
        Common patterns:
        - chapter='1' for all FAR parts
        - chapter='2' for all DFARS parts
        - part='15' for FAR Part 15 structure
        - subpart='15.3' for just that subpart's sections
    
        part/subpart/chapter accept int or string.
        """
        title_number = _validate_title_number(title_number)
        date = _validate_date_ymd(date, field="date")
        chapter = _validate_chapter(chapter, title_number=title_number)
        subchapter = _coerce_cfr_str(subchapter, field="subchapter", maxlen=8)
        part = _coerce_cfr_str(part, field="part", strip_prefixes=True)
        subpart = _coerce_cfr_str(subpart, field="subpart", strip_prefixes=True)
    
        if date is None:
            date = await _resolve_date(title_number)
    
        path = f"/api/versioner/v1/structure/{date}/title-{title_number}.json"
        params: dict[str, str] = {}
        if chapter:
            params["chapter"] = chapter
        if subchapter:
            params["subchapter"] = subchapter
        if part:
            params["part"] = part
        if subpart:
            params["subpart"] = subpart
    
        return await _get_json(path, params, timeout=DEFAULT_TIMEOUT_STRUCTURE)
  • Registration of 'get_cfr_structure' as an MCP tool via the @mcp.tool decorator. The mcp instance is created as FastMCP('ecfr') on line 36.
    @mcp.tool(annotations={"title": "Get CFR Structure", "readOnlyHint": True, "destructiveHint": False})
  • Input validation/schema enforcement for parameters: validates title_number (1-50), date (YYYY-MM-DD), chapter (validated against known chapters for title 48), and coerce/normalize subchapter, part, subpart strings.
    title_number = _validate_title_number(title_number)
    date = _validate_date_ymd(date, field="date")
    chapter = _validate_chapter(chapter, title_number=title_number)
    subchapter = _coerce_cfr_str(subchapter, field="subchapter", maxlen=8)
    part = _coerce_cfr_str(part, field="part", strip_prefixes=True)
    subpart = _coerce_cfr_str(subpart, field="subpart", strip_prefixes=True)
  • Helper used by get_cfr_structure to resolve the latest available date when none is provided by the caller.
    async def _resolve_date(title_number: int) -> str:
        """Resolve the latest available date for a CFR title.
    
        Called before any versioner endpoint. Using today's date often returns
        404 because eCFR lags 1-2 business days.
    
        Raises ValueError with an actionable message for reserved titles
        (which have null up_to_date_as_of) rather than building a URL with
        'None' in it.
        """
        data = await _get_json("/api/versioner/v1/titles.json")
        titles = _as_list(_safe_dict(data).get("titles"))
        for title in titles:
            t = _safe_dict(title)
            if _safe_int(t.get("number")) == title_number:
                utd = t.get("up_to_date_as_of")
                if not isinstance(utd, str) or not utd.strip():
                    reason = "this title is marked 'reserved'" if t.get("reserved") else (
                        "the API did not return up_to_date_as_of"
                    )
                    raise ValueError(
                        f"Cannot resolve a date for title {title_number}: {reason}. "
                        f"Reserved or un-issued titles have no published content."
                    )
                return utd
        raise ValueError(f"Title {title_number} not found in eCFR titles list.")
  • HTTP GET helper for JSON endpoints used by get_cfr_structure to fetch the structure data from the eCFR API.
    async def _get_json(
        path: str,
        params: dict[str, Any] | None = None,
        timeout: float = DEFAULT_TIMEOUT_JSON,
    ) -> dict[str, Any]:
        """GET helper for JSON endpoints. Always returns a dict (empty if API returned null)."""
        try:
            r = await _get_client().get(path, params=params or {}, timeout=timeout)
        except httpx.RequestError as e:
            raise RuntimeError(f"Network error calling eCFR: {e}") from e
        if r.status_code >= 400:
            raise RuntimeError(_format_error(r.status_code, r.text))
        try:
            data = r.json()
        except (ValueError, _json.JSONDecodeError) as e:
            preview = _clean_error_body(r.text or "(empty body)")[:200]
            ct = r.headers.get("content-type", "?")
            raise RuntimeError(
                f"eCFR returned a non-JSON response (status {r.status_code}, "
                f"content-type={ct!r}): {preview}"
            ) from e
        if data is None:
            return {}
        if not isinstance(data, (dict, list)):
            raise RuntimeError(
                f"eCFR returned unexpected JSON type {type(data).__name__}: {str(data)[:200]}"
            )
        return data if isinstance(data, dict) else {"_list": data}
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already mark it as readonly and non-destructive. The description adds crucial behavioral context: the return format (nested tree), error on section-level filtering, and that parameters can be int or string. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

7 sentences, front-loaded with purpose and return type, followed by a warning and common patterns. Every sentence adds unique value. No fluff or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of hierarchical CFR data and the presence of an output schema, the description sufficiently covers what the tool does, its limitations, and parameter usage. An agent can confidently determine when to invoke this tool based on the provided information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description carries full burden. It explains the purpose of chapter, part, subpart with concrete examples and type flexibility (int or string). However, it omits explanation for title_number (default 48) and date, and subchapter is not mentioned at all.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it retrieves a hierarchical table of contents for a CFR title or subset, with specific return content (nested tree of identifiers, descriptions, byte sizes). It distinguishes itself from siblings like get_cfr_content and list_sections_in_part by focusing on structure.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit warning against section-level filtering ('Does NOT support section-level filtering (returns 400)') and offers common patterns for FAR, DFARS, Part 15, etc. However, it could more directly compare with sibling tools like get_cfr_content or list_sections_in_part to clarify when to use each.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/1102tools/federal-contracting-mcps'

If you have feedback or need assistance with the MCP directory API, please join our Discord server