get_candidate_financials
Retrieve campaign finance data for a specific candidate and election year from Federal Election Commission records.
Instructions
Get financial data for a candidate
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| candidate_id | Yes | FEC candidate ID | |
| election_year | Yes | Election year to get data for |
Implementation Reference
- src/server.ts:562-583 (handler)The handler function for 'get_candidate_financials' tool. Validates input using Zod schema, consumes rate limit token, fetches financial totals from OpenFEC API endpoint `/candidate/{candidate_id}/totals` for the specified election year, and returns the JSON response as text content.private async handleGetCandidateFinancials(args: any) { const schema = z.object({ candidate_id: z.string(), election_year: z.number(), }); const { candidate_id, election_year } = schema.parse(args); this.rateLimiter.consumeToken(); const response = await this.axiosInstance.get(`/candidate/${candidate_id}/totals`, { params: { election_year } }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/server.ts:114-127 (schema)Input schema definition for the 'get_candidate_financials' tool, specifying required candidate_id (string) and election_year (number).inputSchema: { type: 'object', properties: { candidate_id: { type: 'string', description: 'FEC candidate ID', }, election_year: { type: 'number', description: 'Election year to get data for', }, }, required: ['candidate_id', 'election_year'], },
- src/server.ts:111-128 (registration)Registration of the 'get_candidate_financials' tool in the ListTools response, including name, description, and input schema.{ name: 'get_candidate_financials', description: 'Get financial data for a candidate', inputSchema: { type: 'object', properties: { candidate_id: { type: 'string', description: 'FEC candidate ID', }, election_year: { type: 'number', description: 'Election year to get data for', }, }, required: ['candidate_id', 'election_year'], }, },
- src/server.ts:453-454 (registration)Switch case in CallToolRequest handler that dispatches to the specific tool handler.case 'get_candidate_financials': return await this.handleGetCandidateFinancials(request.params.arguments);