Search Government Contracts
search_contractsSearch federal contract awards by agency, vendor, NAICS code, or keyword to retrieve award details including value, period of performance, 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
| Name | Required | Description | Default |
|---|---|---|---|
| agency | No | Awarding agency name or abbreviation (e.g. DOD, HHS) | |
| vendor | No | Vendor/contractor name (partial match) | |
| naics | No | NAICS code filter | |
| keyword | No | Keyword search in award description | |
| min_value | No | Minimum award value in USD | |
| limit | No | Maximum results (default 25) |
Implementation Reference
- src/tools/contracts.ts:69-99 (handler)The async handler function that executes the search_contracts tool logic: calls apiGet to /api/v1/contracts with query parameters (agency, vendor, naics, keyword, min_value, limit), handles errors, formats the response with count and JSON data.
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}` }], }; }, - src/tools/contracts.ts:39-67 (schema)Input schema for search_contracts tool using Zod: optional fields for agency, vendor, naics, keyword, min_value (number), limit (1-100 integer).
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)"), }, - src/tools/contracts.ts:31-100 (registration)Registration of the search_contracts tool via server.registerTool('search_contracts', ...) with title/description, inputSchema, and handler.
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}` }], }; }, ); - src/index.ts:53-53 (registration)Top-level registration call to registerContractTools(server) which registers all contract tools including search_contracts.
registerContractTools(server); - src/client.ts:44-76 (helper)The apiGet helper function used by the handler to make HTTP GET requests to the Verilex API with headers and payment token support.
export async function apiGet<T = unknown>( path: string, params?: Record<string, string | number | undefined>, ): Promise<ApiResponse<T>> { const url = buildUrl(path, params); const headers: Record<string, string> = { Accept: "application/json", "User-Agent": "verilex-mcp-server/0.1.0", }; // Forward x402 payment token if present in env (for paid endpoints) const paymentToken = process.env.VERILEX_PAYMENT_TOKEN; if (paymentToken) { headers["X-Payment-Token"] = paymentToken; } const res = await fetch(url, { headers }); const data = (await res.json()) as T; const stale = res.headers.get("X-Data-Stale"); const lastUpdated = res.headers.get("X-Data-Last-Updated"); const ageSeconds = res.headers.get("X-Data-Age-Seconds"); return { ok: res.ok, status: res.status, data, stale: stale === "true", lastUpdated: lastUpdated ?? undefined, ageSeconds: ageSeconds ? Number(ageSeconds) : undefined, }; }