Skip to main content
Glama
psalzman

MCP OpenFEC Server

by psalzman

get_candidate_contributions

Retrieve individual campaign contributions for a specific candidate using their FEC ID and election year. Sort results by contribution amount to analyze donor support patterns.

Instructions

Get individual contributions for a candidate

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
candidate_idYesFEC candidate ID
election_yearNoElection year
sortNoOptional: Sort by contribution_receipt_amount (desc for highest first)

Implementation Reference

  • The primary handler function for the 'get_candidate_contributions' tool. It validates the input parameters using Zod schema, consumes a rate limit token, fetches the principal committee ID for the candidate, queries the OpenFEC API endpoint for Schedule A (itemized contributions), and returns the response data as formatted JSON text.
    private async handleGetCandidateContributions(args: any) {
      const schema = z.object({
        candidate_id: z.string(),
        election_year: z.number().optional(),
        sort: z.enum(['desc', 'asc']).optional()
      });
    
      const { candidate_id, election_year, sort } = schema.parse(args);
      this.rateLimiter.consumeToken();
    
      const response = await this.axiosInstance.get(`/schedules/schedule_a/`, {
        params: {
          committee_id: await this.getCommitteeId(candidate_id),
          two_year_transaction_period: election_year,
          sort: sort === 'desc' ? '-contribution_receipt_amount' : 'contribution_receipt_amount',
          per_page: 10
        }
      });
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(response.data, null, 2),
          },
        ],
      };
    }
  • Zod runtime validation schema for the tool's input parameters inside the handler.
    const schema = z.object({
      candidate_id: z.string(),
      election_year: z.number().optional(),
      sort: z.enum(['desc', 'asc']).optional()
    });
  • src/server.ts:170-192 (registration)
    Registration of the 'get_candidate_contributions' tool in the ListTools handler, including the tool name, description, and JSON input schema definition.
    {
      name: 'get_candidate_contributions',
      description: 'Get individual contributions for a candidate',
      inputSchema: {
        type: 'object',
        properties: {
          candidate_id: {
            type: 'string',
            description: 'FEC candidate ID'
          },
          election_year: {
            type: 'number',
            description: 'Election year'
          },
          sort: {
            type: 'string',
            description: 'Optional: Sort by contribution_receipt_amount (desc for highest first)',
            enum: ['desc', 'asc']
          }
        },
        required: ['candidate_id']
      },
    },
  • Helper method used by the handler to fetch the principal campaign committee ID (designation 'P') for the given candidate ID, necessary because contributions are queried by committee.
    private async getCommitteeId(candidate_id: string): Promise<string> {
      const response = await this.axiosInstance.get(`/candidate/${candidate_id}/committees`, {
        params: {
          designation: 'P'
        }
      });
      
      if (response.data.results && response.data.results.length > 0) {
        return response.data.results[0].committee_id;
      }
      throw new McpError(
        ErrorCode.InvalidRequest,
        'No principal campaign committee found for candidate'
      );
    }
  • src/server.ts:455-456 (registration)
    Dispatcher case in the CallToolRequest handler that routes calls to the specific handler method.
    case 'get_candidate_contributions':
      return await this.handleGetCandidateContributions(request.params.arguments);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action 'Get' but does not describe traits like whether it's read-only, requires authentication, has rate limits, or what the output format looks like. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It is appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no annotations, no output schema, and the description lacks behavioral and usage details, it is incomplete. For a tool with 3 parameters and potential complexity in contributions data, the description should provide more context on output format, limitations, or how it fits with siblings, but it does not.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents all parameters (candidate_id, election_year, sort). The description adds no additional meaning beyond what the schema provides, such as clarifying the scope of 'individual contributions' or how parameters interact. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'individual contributions for a candidate', making the purpose understandable. However, it does not differentiate from siblings like 'get_candidate_financials' or 'search_candidates', which might also involve candidate data, so it lacks specific distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. For example, it does not mention how it differs from 'get_candidate_financials' or when to prefer it over 'search_candidates' for contribution-related queries, leaving usage context implied at best.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/psalzman/mcp-openfec'

If you have feedback or need assistance with the MCP directory API, please join our Discord server