Skip to main content
Glama

search_contracts

Search federal contract awards by agency, vendor, NAICS code, or keyword to find award details including value, performance period, and competition type.

Instructions

Search federal contract awards by agency, vendor, NAICS code, or keyword. Returns award details including value, period of performance, and competition type. Cost: $0.018 per query. Source: USAspending.gov, updated daily.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agencyNoAwarding agency name or abbreviation (e.g. DOD, HHS)
vendorNoVendor/contractor name (partial match)
naicsNoNAICS code filter
keywordNoKeyword search in award description
min_valueNoMinimum award value in USD
limitNoMaximum results (default 25)

Implementation Reference

  • The handler function for the `search_contracts` tool, which fetches data from the API based on provided filter parameters.
    async ({ agency, vendor, naics, keyword, min_value, limit }) => {
      const res = await apiGet<ContractQueryResponse>("/api/v1/contracts", {
        agency,
        vendor,
        naics,
        keyword,
        min_value,
        limit: limit ?? 25,
      });
    
      if (!res.ok) {
        return {
          content: [
            {
              type: "text" as const,
              text: `API error (${res.status}): ${JSON.stringify(res.data)}`,
            },
          ],
          isError: true,
        };
      }
    
      const { count, data } = res.data;
      const warn = stalenessWarning(res);
      const summary = `${warn}Found ${count} contract award(s).`;
      const json = JSON.stringify(data, null, 2);
    
      return {
        content: [{ type: "text" as const, text: `${summary}\n\n${json}` }],
      };
    },
  • The input schema validation using Zod for the `search_contracts` tool parameters.
    inputSchema: {
      agency: z
        .string()
        .optional()
        .describe("Awarding agency name or abbreviation (e.g. DOD, HHS)"),
      vendor: z
        .string()
        .optional()
        .describe("Vendor/contractor name (partial match)"),
      naics: z
        .string()
        .optional()
        .describe("NAICS code filter"),
      keyword: z
        .string()
        .optional()
        .describe("Keyword search in award description"),
      min_value: z
        .number()
        .optional()
        .describe("Minimum award value in USD"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .optional()
        .describe("Maximum results (default 25)"),
    },
  • Registration of the `search_contracts` tool within the MCP server using server.registerTool.
    server.registerTool(
      "search_contracts",
      {
        title: "Search Government Contracts",
        description:
          "Search federal contract awards by agency, vendor, NAICS code, or keyword. " +
          "Returns award details including value, period of performance, and competition type. " +
          "Cost: $0.018 per query. Source: USAspending.gov, updated daily.",
        inputSchema: {
          agency: z
            .string()
            .optional()
            .describe("Awarding agency name or abbreviation (e.g. DOD, HHS)"),
          vendor: z
            .string()
            .optional()
            .describe("Vendor/contractor name (partial match)"),
          naics: z
            .string()
            .optional()
            .describe("NAICS code filter"),
          keyword: z
            .string()
            .optional()
            .describe("Keyword search in award description"),
          min_value: z
            .number()
            .optional()
            .describe("Minimum award value in USD"),
          limit: z
            .number()
            .int()
            .min(1)
            .max(100)
            .optional()
            .describe("Maximum results (default 25)"),
        },
      },
      async ({ agency, vendor, naics, keyword, min_value, limit }) => {
        const res = await apiGet<ContractQueryResponse>("/api/v1/contracts", {
          agency,
          vendor,
          naics,
          keyword,
          min_value,
          limit: limit ?? 25,
        });
    
        if (!res.ok) {
          return {
            content: [
              {
                type: "text" as const,
                text: `API error (${res.status}): ${JSON.stringify(res.data)}`,
              },
            ],
            isError: true,
          };
        }
    
        const { count, data } = res.data;
        const warn = stalenessWarning(res);
        const summary = `${warn}Found ${count} contract award(s).`;
        const json = JSON.stringify(data, null, 2);
    
        return {
          content: [{ type: "text" as const, text: `${summary}\n\n${json}` }],
        };
      },
    );

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/carrierone/verilexdata-mcp'

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