Skip to main content
Glama
cliwant

mcp-sam-gov

by cliwant

grants_search

Search federal grant opportunities on Grants.gov. Filter by keyword, CFDA number, agency code, or opportunity number. Includes forecasted and posted opportunities by default.

Instructions

Search Grants.gov federal grant opportunities (financial assistance, distinct from contracts on SAM.gov). Filter by keyword / CFDA / agency / opportunity number. Default status = forecasted + posted.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordNo
cfdaNoCFDA program number, e.g. '10.500'
agencyNoGrants.gov agency code, e.g. 'DHS-FEMA'
oppNumNoSpecific opportunity number
oppStatusesNoDefaults to forecasted+posted
rowsNo

Implementation Reference

  • The searchGrants function that executes the "grants_search" tool logic. It calls the Grants.gov /v1/api/search2 endpoint with keyword, CFDA, agency, oppNum, oppStatuses, and rows parameters, then returns filtered grant results.
    export async function searchGrants(args: {
      keyword?: string;
      cfda?: string; // CFDA program number, e.g. "10.500"
      agency?: string; // agency code, e.g. "DHS-FEMA"
      oppNum?: string; // opportunity number
      oppStatuses?: GrantStatus[];
      rows?: number;
    }) {
      const body: Record<string, unknown> = {
        rows: args.rows ?? 10,
        keyword: args.keyword ?? "",
        cfda: args.cfda ?? "",
        agencies: args.agency ?? "",
        oppNum: args.oppNum ?? "",
        oppStatuses: (args.oppStatuses ?? ["forecasted", "posted"]).join("|"),
      };
      type Resp = {
        errorcode?: number;
        msg?: string;
        data?: {
          hitCount?: number;
          oppHits?: {
            id?: string;
            number?: string;
            title?: string;
            agencyCode?: string;
            agencyName?: string;
            openDate?: string;
            closeDate?: string;
            oppStatus?: string;
            docType?: string;
            cfdaList?: string;
          }[];
        };
      };
      const json = await postJson<Resp>("search2", body);
      if (json.errorcode && json.errorcode !== 0) {
        throw new Error(`Grants.gov error: ${json.msg ?? "unknown"}`);
      }
      return {
        totalRecords: json.data?.hitCount ?? 0,
        grants: (json.data?.oppHits ?? []).map((g) => ({
          id: g.id ?? "",
          opportunityNumber: g.number ?? "",
          title: g.title ?? "",
          agencyCode: g.agencyCode ?? "",
          agencyName: g.agencyName ?? "",
          openDate: g.openDate,
          closeDate: g.closeDate,
          status: g.oppStatus,
          docType: g.docType,
          cfdaList: g.cfdaList,
        })),
      };
    }
  • Zod schema for the grants_search tool input: keyword (optional string), cfda (optional string), agency (optional string), oppNum (optional string), oppStatuses (optional array of forecasted/posted/closed/archived), rows (optional number 1-50).
    const GrantsSearchInput = z.object({
      keyword: z.string().optional(),
      cfda: z.string().optional().describe("CFDA program number, e.g. '10.500'"),
      agency: z
        .string()
        .optional()
        .describe("Grants.gov agency code, e.g. 'DHS-FEMA'"),
      oppNum: z.string().optional().describe("Specific opportunity number"),
      oppStatuses: z
        .array(z.enum(["forecasted", "posted", "closed", "archived"]))
        .optional()
        .describe("Defaults to forecasted+posted"),
      rows: z.number().min(1).max(50).optional(),
    });
  • src/server.ts:506-512 (registration)
    Tool registration entry for "grants_search" in the tools array, with description and inputSchema reference to GrantsSearchInput.
    // ━━━ Grants.gov (2) ━━━
    {
      name: "grants_search",
      description:
        "Search Grants.gov federal grant opportunities (financial assistance, distinct from contracts on SAM.gov). Filter by keyword / CFDA / agency / opportunity number. Default status = forecasted + posted.",
      inputSchema: GrantsSearchInput,
    },
  • The postJson helper function used by searchGrants to POST JSON requests to Grants.gov API with a 15-second timeout.
    async function postJson<T>(
      endpoint: string,
      body: Record<string, unknown>,
    ): Promise<T> {
      const r = await fetch(`${GRANTS}/${endpoint}`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(15_000),
      });
      if (!r.ok) {
        throw new Error(`Grants.gov ${endpoint} returned ${r.status}`);
      }
      return (await r.json()) as T;
    }
  • The call handler dispatch case for "grants_search" which parses args with GrantsSearchInput and calls grants.searchGrants().
    // Grants.gov
    case "grants_search":
      return await grants.searchGrants(GrantsSearchInput.parse(args));
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It mentions default status behavior but lacks details on rate limits, pagination, sorting, or result fields. The behavior is partially transparent but leaves gaps.

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?

Two concise sentences effectively communicate purpose, differentiation, filter options, and defaults. No wasted words; every sentence adds value.

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

Completeness3/5

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

For a tool with six optional parameters and no output schema, the description covers main usage but does not describe return format or pagination. Context is adequate but could be more complete given the tool's complexity.

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?

The description mentions four of six parameters (keyword, CFDA, agency, oppNum, oppStatuses) but omits 'rows'. It adds value with an example ('10.500') and default status, but does not fully compensate for the 67% schema description coverage.

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 searches Grants.gov for federal grant opportunities, explicitly distinguishes from contracts on SAM.gov, and specifies it is for financial assistance. This effectively differentiates it from siblings like sam_search_opportunities.

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 provides clear usage context by listing filter options and default status ('forecasted + posted'). It mentions the distinction from SAM.gov but does not explicitly state when to use this tool versus grants_get_opportunity for a single opportunity.

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