Lookup Contract Award
lookup_contractRetrieve complete details of a federal contract award by its ID, including modifications, sub-awards, and performance history.
Instructions
Look up a single federal contract award by its ID. Returns full award details including modifications, sub-awards, and performance history. Cost: $0.018 per query. Source: USAspending.gov.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contract_id | Yes | Contract award ID |
Implementation Reference
- src/tools/contracts.ts:118-140 (handler)The async handler function for lookup_contract. Takes { contract_id } input, makes an API GET request to `/api/v1/contracts/{contract_id}`, and returns formatted JSON with the contract award details. Handles 404 specially (not found, not an error) and other errors normally.
async ({ contract_id }) => { const res = await apiGet<{ dataset: string; data: Record<string, unknown> }>( `/api/v1/contracts/${encodeURIComponent(contract_id)}`, ); if (!res.ok) { const msg = res.status === 404 ? `Contract ${contract_id} not found.` : `API error (${res.status}): ${JSON.stringify(res.data)}`; return { content: [{ type: "text" as const, text: msg }], isError: res.status !== 404, }; } const warn = stalenessWarning(res); return { content: [ { type: "text" as const, text: `${warn}${JSON.stringify(res.data.data, null, 2)}` }, ], }; }, - src/tools/contracts.ts:112-116 (schema)Input schema for lookup_contract: a single required string parameter 'contract_id' validated with Zod.
inputSchema: { contract_id: z .string() .describe("Contract award ID"), }, - src/tools/contracts.ts:104-141 (registration)Registration of the lookup_contract tool via server.registerTool() with title, description, inputSchema, and the handler callback.
server.registerTool( "lookup_contract", { title: "Lookup Contract Award", description: "Look up a single federal contract award by its ID. Returns full award details " + "including modifications, sub-awards, and performance history. " + "Cost: $0.018 per query. Source: USAspending.gov.", inputSchema: { contract_id: z .string() .describe("Contract award ID"), }, }, async ({ contract_id }) => { const res = await apiGet<{ dataset: string; data: Record<string, unknown> }>( `/api/v1/contracts/${encodeURIComponent(contract_id)}`, ); if (!res.ok) { const msg = res.status === 404 ? `Contract ${contract_id} not found.` : `API error (${res.status}): ${JSON.stringify(res.data)}`; return { content: [{ type: "text" as const, text: msg }], isError: res.status !== 404, }; } const warn = stalenessWarning(res); return { content: [ { type: "text" as const, text: `${warn}${JSON.stringify(res.data.data, null, 2)}` }, ], }; }, ); - src/index.ts:53-53 (registration)The function call registerContractTools(server) which registers all contract tools including lookup_contract.
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. Also stalenessWarning (lines 35-41) for adding stale data warnings to output.
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, }; }