Government Contracts
company_contractsRetrieve US government contract data for companies, including awarded contracts from USAspending.gov and open opportunities from SAM.gov, using verified official sources.
Instructions
Get US government contract data for a company: awarded contracts from USAspending.gov and open opportunities from SAM.gov. Use company_search first to get an entity_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_id | Yes | CompanyLens entity ID from company_search (starts with "companylens_") |
Implementation Reference
- src/index.ts:111-152 (handler)The "company_contracts" tool is registered and implemented in src/index.ts. The implementation includes the schema definition and the async handler that fetches contract data from the API and formats it for the user.
server.registerTool( 'company_contracts', { title: 'Government Contracts', description: 'Get US government contract data for a company: awarded contracts from USAspending.gov and open opportunities from SAM.gov. Use company_search first to get an entity_id.', inputSchema: z.object({ entity_id: z.string().describe('CompanyLens entity ID from company_search (starts with "companylens_")'), }), }, async ({ entity_id }) => { const data = await apiCall(`/v1/company/${entity_id}/contracts`) as { name: string; awards: Array<{ title: string; agency: string; amount: number; date: string }>; opportunities: Array<{ title: string; agency: string; postedDate: string; responseDeadline?: string }>; total_award_value: number; agent_hint: string; }; const parts: string[] = [`${data.name} — Government Contracts\n`]; if (data.awards.length) { parts.push(`Total awarded: $${data.total_award_value.toLocaleString()}\n`); parts.push('Top awards:'); data.awards.slice(0, 10).forEach((a) => { parts.push(`- $${a.amount.toLocaleString()} from ${a.agency} (${a.date}): ${a.title}`); }); } else { parts.push('No awarded contracts found.'); } if (data.opportunities.length) { parts.push('\nOpen opportunities:'); data.opportunities.forEach((o) => { parts.push(`- ${o.title} (${o.agency}, deadline: ${o.responseDeadline || 'N/A'})`); }); } parts.push(`\n${data.agent_hint}`); return { content: [{ type: 'text' as const, text: parts.join('\n') }] }; }, );