Top Government Contract Vendors
top_vendorsQuery vendor rankings by total award value from USAspending.gov. Filter by agency and time period to get top contractors with award amounts and contract counts.
Instructions
Get vendor rankings by total award value. Shows top contractors by agency, total awards, and contract counts. Cost: $0.03 per query. Source: USAspending.gov.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agency | No | Filter by awarding agency | |
| period | No | Time period for ranking (default: 1y) | |
| limit | No | Maximum results (default 25) |
Implementation Reference
- src/tools/contracts.ts:171-199 (handler)The async handler function for 'top_vendors' tool. Calls apiGet to /api/v1/contracts/vendors with agency, period, and limit params, then formats the response as text.
async ({ agency, period, limit }) => { const res = await apiGet<ContractQueryResponse>("/api/v1/contracts/vendors", { agency, period: period ?? "1y", 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} vendor(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/tools/contracts.ts:153-169 (schema)Input schema for 'top_vendors': optional agency (string), period (enum: 1y/3y/5y/all), and limit (number, 1-100).
inputSchema: { agency: z .string() .optional() .describe("Filter by awarding agency"), period: z .enum(["1y", "3y", "5y", "all"]) .optional() .describe("Time period for ranking (default: 1y)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, - src/tools/contracts.ts:145-199 (registration)Registration of 'top_vendors' tool via server.registerTool(), including title, description, inputSchema, and handler.
server.registerTool( "top_vendors", { title: "Top Government Contract Vendors", description: "Get vendor rankings by total award value. Shows top contractors by agency, " + "total awards, and contract counts. " + "Cost: $0.03 per query. Source: USAspending.gov.", inputSchema: { agency: z .string() .optional() .describe("Filter by awarding agency"), period: z .enum(["1y", "3y", "5y", "all"]) .optional() .describe("Time period for ranking (default: 1y)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, }, async ({ agency, period, limit }) => { const res = await apiGet<ContractQueryResponse>("/api/v1/contracts/vendors", { agency, period: period ?? "1y", 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} vendor(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)The registerContractTools(server) call that wires up the contract tools including 'top_vendors' into the MCP server.
registerContractTools(server); - src/client.ts:44-76 (helper)The apiGet helper used by the handler to make HTTP GET requests to the Verilex API.
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, }; }