get_independent_expenditures
Retrieve independent expenditures supporting or opposing political candidates from Federal Election Commission data. Filter by candidate, committee, support/oppose status, date range, and amount.
Instructions
Get independent expenditures supporting or opposing candidates
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_independent_expenditures"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| candidate_id | No | Optional: FEC candidate ID | |
| committee_id | No | Optional: FEC committee ID | |
| support_oppose_indicator | No | Optional: S for supporting or O for opposing | |
| min_date | No | Optional: Minimum expenditure date (YYYY-MM-DD) | |
| max_date | No | Optional: Maximum expenditure date (YYYY-MM-DD) | |
| min_amount | No | Optional: Minimum expenditure amount | |
| max_amount | No | Optional: Maximum expenditure amount | |
| sort | No | Optional: Sort by expenditure amount |
Implementation Reference
- src/server.ts:663-695 (handler)The handler function that executes the tool logic: validates input parameters using Zod, queries the OpenFEC API at /schedules/schedule_e for independent expenditures data, and returns the JSON response as text content.
private async handleGetIndependentExpenditures(args: any) { const schema = z.object({ candidate_id: z.string().optional(), committee_id: z.string().optional(), support_oppose_indicator: z.enum(['S', 'O']).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_e', { params: { ...params, sort_hide_null: true, sort: params.sort === 'desc' ? '-expenditure_amount' : 'expenditure_amount', per_page: 20 } }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } - src/server.ts:233-274 (registration)Tool registration in the MCP server's tools list, defining the tool name, description, and input schema for validation.
name: 'get_independent_expenditures', description: 'Get independent expenditures supporting or opposing candidates', inputSchema: { type: 'object', properties: { candidate_id: { type: 'string', description: 'Optional: FEC candidate ID' }, committee_id: { type: 'string', description: 'Optional: FEC committee ID' }, support_oppose_indicator: { type: 'string', enum: ['S', 'O'], description: 'Optional: S for supporting or O for opposing' }, min_date: { type: 'string', description: 'Optional: Minimum expenditure date (YYYY-MM-DD)' }, max_date: { type: 'string', description: 'Optional: Maximum expenditure date (YYYY-MM-DD)' }, min_amount: { type: 'number', description: 'Optional: Minimum expenditure amount' }, max_amount: { type: 'number', description: 'Optional: Maximum expenditure amount' }, sort: { type: 'string', enum: ['asc', 'desc'], description: 'Optional: Sort by expenditure amount' } } } }, - src/server.ts:459-460 (registration)Dispatcher case in the request handler that routes calls to the specific handler function.
case 'get_independent_expenditures': return await this.handleGetIndependentExpenditures(request.params.arguments); - src/server.ts:664-673 (schema)Runtime input validation schema inside the handler, matching the registered inputSchema.
const schema = z.object({ candidate_id: z.string().optional(), committee_id: z.string().optional(), support_oppose_indicator: z.enum(['S', 'O']).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() });