top_vendors
Identify leading government contractors by analyzing total award values, agency-specific rankings, and contract counts using USAspending.gov data.
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
TableJSON 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:145-199 (handler)Handler implementation for the "top_vendors" tool, including its registration, Zod schema definition for inputs, and the API call logic.
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}` }], }; }, );