get_communication_costs
Retrieve corporate and union communication cost data from Federal Election Commission records to analyze campaign finance expenditures.
Instructions
Get corporate/union communication costs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| committee_id | No | Optional: FEC committee ID | |
| candidate_id | No | Optional: FEC candidate ID | |
| min_date | No | Optional: Minimum communication date (YYYY-MM-DD) | |
| max_date | No | Optional: Maximum communication date (YYYY-MM-DD) | |
| min_amount | No | Optional: Minimum cost amount | |
| max_amount | No | Optional: Maximum cost amount | |
| sort | No | Optional: Sort by cost amount |
Implementation Reference
- src/server.ts:763-794 (handler)The core handler function for the 'get_communication_costs' tool. Validates input using Zod schema matching the tool's inputSchema, applies rate limiting, queries the OpenFEC API endpoint '/schedules/schedule_d' for corporate/union communication costs data with optional filters and sorting, and returns the response as a formatted JSON text content block.private async handleGetCommunicationCosts(args: any) { const schema = z.object({ committee_id: z.string().optional(), candidate_id: z.string().optional(), min_date: z.string().optional(), max_date: z.string().optional(), min_amount: z.number().optional(), max_amount: z.number().optional(), sort: z.enum(['asc', 'desc']).optional() }); const params = schema.parse(args); this.rateLimiter.consumeToken(); const response = await this.axiosInstance.get('/schedules/schedule_d', { params: { ...params, sort_hide_null: true, sort: params.sort === 'desc' ? '-cost' : 'cost', per_page: 20 } }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/server.ts:354-387 (schema)The input schema definition for the 'get_communication_costs' tool, used in ListTools response for input validation and documentation. Defines optional parameters for filtering and sorting communication costs data from the FEC API.inputSchema: { type: 'object', properties: { committee_id: { type: 'string', description: 'Optional: FEC committee ID' }, candidate_id: { type: 'string', description: 'Optional: FEC candidate ID' }, min_date: { type: 'string', description: 'Optional: Minimum communication date (YYYY-MM-DD)' }, max_date: { type: 'string', description: 'Optional: Maximum communication date (YYYY-MM-DD)' }, min_amount: { type: 'number', description: 'Optional: Minimum cost amount' }, max_amount: { type: 'number', description: 'Optional: Maximum cost amount' }, sort: { type: 'string', enum: ['asc', 'desc'], description: 'Optional: Sort by cost amount' } } }
- src/server.ts:351-388 (registration)The tool registration object returned by ListToolsRequestHandler, specifying the tool name, description, and input schema for 'get_communication_costs'.{ name: 'get_communication_costs', description: 'Get corporate/union communication costs', inputSchema: { type: 'object', properties: { committee_id: { type: 'string', description: 'Optional: FEC committee ID' }, candidate_id: { type: 'string', description: 'Optional: FEC candidate ID' }, min_date: { type: 'string', description: 'Optional: Minimum communication date (YYYY-MM-DD)' }, max_date: { type: 'string', description: 'Optional: Maximum communication date (YYYY-MM-DD)' }, min_amount: { type: 'number', description: 'Optional: Minimum cost amount' }, max_amount: { type: 'number', description: 'Optional: Maximum cost amount' }, sort: { type: 'string', enum: ['asc', 'desc'], description: 'Optional: Sort by cost amount' } } } },
- src/server.ts:465-466 (registration)The switch case in the CallToolRequestHandler that routes calls to the 'get_communication_costs' handler function.case 'get_communication_costs': return await this.handleGetCommunicationCosts(request.params.arguments);