Skip to main content
Glama
cliwant

mcp-sam-gov

by cliwant

ecfr_search

Search the Code of Federal Regulations by title and query. Use for compliance questions—returns excerpt, section path, and eCFR link. Supports all 50 titles, including FAR (48) and federal financial assistance (2).

Instructions

Full-text search across the entire CFR (Code of Federal Regulations). Use for compliance questions — pass titleNumber=48 for FAR (Federal Acquisition Regulation), titleNumber=2 for federal financial assistance, etc. Returns excerpt + section path + ecfrUrl.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
titleNumberNoCFR title (1-50). e.g. 48 = FAR (Federal Acquisition Regulation), 2 = Federal financial assistance.
perPageNo

Implementation Reference

  • The `search` function that executes the ecfr_search tool logic. Makes a request to eCFR /search/v1/results API with query, optional titleNumber (via hierarchy[title]), and perPage, then maps results to include type, hierarchy info, excerpt, score, and ecfrUrl.
    export async function search(args: {
      query: string;
      titleNumber?: number;
      perPage?: number;
    }) {
      const url = new URL(`${ECFR}/search/v1/results`);
      url.searchParams.set("query", args.query);
      url.searchParams.set("per_page", String(args.perPage ?? 5));
      if (args.titleNumber) {
        // eCFR search filter: hierarchy[title]=N (NOT just title=N — that's
        // an "unpermitted parameter" error from the eCFR API).
        url.searchParams.set("hierarchy[title]", String(args.titleNumber));
      }
    
      type Resp = {
        results?: {
          starts_on?: string;
          ends_on?: string | null;
          type?: string;
          hierarchy?: {
            title?: string;
            chapter?: string;
            subchapter?: string;
            part?: string;
            subpart?: string;
            section?: string;
          };
          hierarchy_headings?: Record<string, string | null>;
          headings?: Record<string, string | null>;
          full_text_excerpt?: string;
          score?: number;
        }[];
      };
      const json = await fetchJson<Resp>(url.toString());
      return {
        results: (json.results ?? []).map((r) => ({
          type: r.type ?? "",
          title: r.hierarchy?.title ?? "",
          chapter: r.hierarchy?.chapter,
          part: r.hierarchy?.part,
          subpart: r.hierarchy?.subpart,
          section: r.hierarchy?.section,
          headingPath: Object.values(r.hierarchy_headings ?? {})
            .filter(Boolean)
            .join(" › "),
          excerpt: stripHtml(r.full_text_excerpt ?? ""),
          score: r.score ?? 0,
          // Stable ecfr.gov URL pattern from the hierarchy
          ecfrUrl: r.hierarchy
            ? buildEcfrUrl(r.hierarchy)
            : "",
          effectiveOn: r.starts_on ?? "",
        })),
      };
    }
  • Zod schema `EcfrSearchInput` defining validation for the tool: query (required string), titleNumber (optional number 1-50), perPage (optional number 1-20).
    const EcfrSearchInput = z.object({
      query: z.string(),
      titleNumber: z
        .number()
        .optional()
        .describe(
          "CFR title (1-50). e.g. 48 = FAR (Federal Acquisition Regulation), 2 = Federal financial assistance.",
        ),
      perPage: z.number().min(1).max(20).optional(),
    });
  • src/server.ts:492-498 (registration)
    Tool registration in the MCP server tool list: name 'ecfr_search', description explaining CFR search use cases, inputSchema referencing EcfrSearchInput.
    // ━━━ eCFR (2) ━━━
    {
      name: "ecfr_search",
      description:
        "Full-text search across the entire CFR (Code of Federal Regulations). Use for compliance questions — pass titleNumber=48 for FAR (Federal Acquisition Regulation), titleNumber=2 for federal financial assistance, etc. Returns excerpt + section path + ecfrUrl.",
      inputSchema: EcfrSearchInput,
    },
  • src/server.ts:779-780 (registration)
    Case handler in the tool dispatch switch statement that routes 'ecfr_search' to ecfr.search() after parsing input via EcfrSearchInput.parse(args).
    case "ecfr_search":
      return await ecfr.search(EcfrSearchInput.parse(args));
  • Helper functions `stripHtml` (removes HTML tags) and `buildEcfrUrl` (constructs stable ecfr.gov URL from hierarchy) used by the search handler.
    function stripHtml(s: string): string {
      return s
        .replace(/<[^>]+>/g, "")
        .replace(/\s+/g, " ")
        .trim();
    }
    
    function buildEcfrUrl(h: {
      title?: string;
      chapter?: string;
      part?: string;
      section?: string;
    }): string {
      const base = `https://www.ecfr.gov/current/title-${h.title}`;
      if (h.section) return `${base}/section-${h.section}`;
      if (h.part) return `${base}/part-${h.part}`;
      if (h.chapter) return `${base}/chapter-${h.chapter}`;
      return base;
    }
Behavior4/5

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

No annotations are provided, but the description discloses the return format (excerpt, section path, ecfrUrl). It implies a read operation with no destructive effects, which is appropriate for a search tool.

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?

The description is two sentences with no waste. It front-loads the core purpose and efficiently includes usage tips and return info.

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

Completeness4/5

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

Given no output schema, the description adequately summarizes return values. It lacks details on pagination, but for a search tool this is acceptable. The parameter coverage is sufficient for most use cases.

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

Parameters3/5

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

Schema description coverage is only 33% (titleNumber has a description). The description adds value by explaining titleNumber examples and the query parameter implicitly, but perPage is not addressed. It partially compensates for the missing schema details.

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 the tool performs full-text search across the CFR and distinguishes it from siblings like ecfr_list_titles. It gives specific examples of title numbers for common compliance categories.

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?

The description advises using the tool for compliance questions and provides concrete examples (titleNumber=48 for FAR, etc.). It does not explicitly exclude other use cases, but the context is clear enough.

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/cliwant/mcp-sam-gov'

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