get_candidate
Retrieve detailed Federal Election Commission candidate information including campaign finance data using the candidate's FEC ID, with optional filtering by election year.
Instructions
Get detailed information about a candidate
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"candidate_id": "<candidate_id>"
},
"name": "get_candidate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| candidate_id | Yes | FEC candidate ID | |
| election_year | No | Optional: Filter by election year |
Implementation Reference
- src/server.ts:489-510 (handler)The handler function that executes the get_candidate tool: validates args with Zod schema, calls OpenFEC API, returns JSON response as text content.
private async handleGetCandidate(args: any) { const schema = z.object({ candidate_id: z.string(), election_year: z.number().optional(), }); const { candidate_id, election_year } = schema.parse(args); this.rateLimiter.consumeToken(); const response = await this.axiosInstance.get(`/candidate/${candidate_id}`, { params: election_year ? { election_year } : undefined, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } - src/server.ts:93-110 (registration)Tool registration in ListTools handler, defining name, description, and input schema.
{ name: 'get_candidate', description: 'Get detailed information about a candidate', inputSchema: { type: 'object', properties: { candidate_id: { type: 'string', description: 'FEC candidate ID', }, election_year: { type: 'number', description: 'Optional: Filter by election year', }, }, required: ['candidate_id'], }, }, - src/server.ts:490-493 (schema)Zod runtime input validation schema matching the registered inputSchema.
const schema = z.object({ candidate_id: z.string(), election_year: z.number().optional(), }); - src/server.ts:447-448 (registration)Dispatch case in CallTool handler switch statement that routes to the handler.
case 'get_candidate': return await this.handleGetCandidate(request.params.arguments);