Skip to main content
Glama
sh-patterson

fec-mcp-server

search_donors

Search FEC filings for individual donors by name, employer, or occupation to track donor patterns and identify industry contributions.

Instructions

Search for individual donors across all FEC filings by name, employer, or occupation. Essential for tracking donor patterns, identifying industry contributions, or researching specific individuals' political giving. Supports searching by employer (e.g., "Goldman Sachs") or occupation (e.g., "Lobbyist", "Government Affairs").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contributor_nameNoDonor name to search for (partial match supported)
contributor_employerNoEmployer name to search for (e.g., "Google", "Goldman Sachs")
contributor_occupationNoOccupation to search for (e.g., "Attorney", "Government Affairs", "Lobbyist")
contributor_stateNoTwo-letter state code to filter by (e.g., "CA", "NY")
min_amountNoMinimum contribution amount to include
cycleNoTwo-year election cycle (e.g., 2024)
limitNoMaximum number of results to return (default: 20)

Implementation Reference

  • The main handler function executeSearchDonors that calls the FEC client and formats results into markdown. Accepts optional search params: contributor_name, contributor_employer, contributor_occupation, contributor_state, min_amount, cycle, limit. Groups results by committee, shows per-committee totals and individual contributions.
    export async function executeSearchDonors(
      client: FECClient,
      params: {
        contributor_name?: string;
        contributor_employer?: string;
        contributor_occupation?: string;
        contributor_state?: string;
        min_amount?: number;
        cycle?: number;
        limit?: number;
      }
    ): Promise<SearchDonorsResult> {
      try {
        const response = await client.searchDonors({
          contributor_name: params.contributor_name,
          contributor_employer: params.contributor_employer,
          contributor_occupation: params.contributor_occupation,
          contributor_state: params.contributor_state,
          min_amount: params.min_amount ?? 200, // Default to itemized threshold
          two_year_transaction_period: params.cycle,
          limit: params.limit ?? 20,
        }, 60_000);
    
        // Build header
        const lines: string[] = ['## Donor Search Results'];
    
        // Show search criteria
        const criteria: string[] = [];
        if (params.contributor_name) criteria.push(`name: "${params.contributor_name}"`);
        if (params.contributor_employer) criteria.push(`employer: "${params.contributor_employer}"`);
        if (params.contributor_occupation) criteria.push(`occupation: "${params.contributor_occupation}"`);
        if (params.contributor_state) criteria.push(`state: ${params.contributor_state}`);
        if (params.min_amount) criteria.push(`minimum: ${formatCurrency(params.min_amount)}`);
        if (params.cycle) criteria.push(`cycle: ${params.cycle}`);
    
        lines.push(`*Search: ${criteria.join(', ')}*`);
        lines.push(`*Found ${response.pagination.count} contributions, showing ${response.results.length}*`);
        lines.push('');
    
        if (response.results.length === 0) {
          lines.push('No contributions found matching the criteria.');
          return {
            content: [{ type: 'text', text: lines.join('\n') }],
          };
        }
    
        // Calculate totals
        const totalAmount = response.results.reduce((sum, r) => sum + r.contribution_receipt_amount, 0);
        lines.push(`**Total (shown):** ${formatCurrency(totalAmount)}`);
        lines.push('');
    
        // Group by recipient committee for better readability
        const byCommittee = new Map<string, typeof response.results>();
        for (const result of response.results) {
          const key = result.committee_name || result.committee_id;
          if (!byCommittee.has(key)) {
            byCommittee.set(key, []);
          }
          byCommittee.get(key)!.push(result);
        }
    
        // Format results
        let index = 1;
        for (const [committeeName, contributions] of byCommittee) {
          const committeeTotal = contributions.reduce((sum, c) => sum + c.contribution_receipt_amount, 0);
          lines.push(`### ${committeeName} (${formatCurrency(committeeTotal)})`);
    
          for (const contrib of contributions) {
            const location = [contrib.contributor_city, contrib.contributor_state].filter(Boolean).join(', ');
    
            lines.push(`${index}. **${contrib.contributor_name}** - ${formatCurrency(contrib.contribution_receipt_amount)}`);
            lines.push(`   - Date: ${formatDate(contrib.contribution_receipt_date)}`);
            if (contrib.contributor_employer) {
              lines.push(`   - Employer: ${contrib.contributor_employer}`);
            }
            if (contrib.contributor_occupation) {
              lines.push(`   - Occupation: ${contrib.contributor_occupation}`);
            }
            if (location) {
              lines.push(`   - Location: ${location}`);
            }
            lines.push('');
            index++;
          }
        }
    
        return {
          content: [{ type: 'text', text: lines.join('\n') }],
        };
      } catch (error) {
        return {
          content: [{ type: 'text', text: formatErrorForToolResponse(error) }],
          isError: true,
        };
      }
    }
  • Zod input schema (searchDonorsInputSchema) defining all parameters with descriptions, and searchDonorsParamsSchema with a superRefine ensuring at least one search criterion is provided (contributor_name, contributor_employer, or contributor_occupation).
    export const searchDonorsInputSchema = {
      contributor_name: z
        .string()
        .optional()
        .describe('Donor name to search for (partial match supported)'),
      contributor_employer: z
        .string()
        .optional()
        .describe('Employer name to search for (e.g., "Google", "Goldman Sachs")'),
      contributor_occupation: z
        .string()
        .optional()
        .describe('Occupation to search for (e.g., "Attorney", "Government Affairs", "Lobbyist")'),
      contributor_state: z
        .string()
        .length(2)
        .optional()
        .describe('Two-letter state code to filter by (e.g., "CA", "NY")'),
      min_amount: z
        .number()
        .min(0)
        .optional()
        .describe('Minimum contribution amount to include'),
      cycle: z
        .number()
        .int()
        .min(2000)
        .max(2030)
        .optional()
        .describe('Two-year election cycle (e.g., 2024)'),
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .optional()
        .describe('Maximum number of results to return (default: 20)'),
    };
    
    export const searchDonorsParamsSchema = z
      .object(searchDonorsInputSchema)
      .superRefine((value, ctx) => {
        if (
          !value.contributor_name &&
          !value.contributor_employer &&
          !value.contributor_occupation
        ) {
          ctx.addIssue({
            code: z.ZodIssueCode.custom,
            message:
              'Please provide at least one search criterion: contributor_name, contributor_employer, or contributor_occupation.',
          });
        }
      });
    
    export type SearchDonorsInput = z.infer<typeof searchDonorsParamsSchema>;
  • Registration of the search_donors tool in the registerTools function. Maps SEARCH_DONORS_TOOL definition + searchDonorsParamsSchema + executeSearchDonors into an MCP server.tool() call (lines 213-229 for the generic registration loop).
        {
          def: SEARCH_DONORS_TOOL,
          paramsSchema: searchDonorsParamsSchema,
          execute: async (params) =>
            executeSearchDonors(client, params as {
              contributor_name?: string;
              contributor_employer?: string;
              contributor_occupation?: string;
              contributor_state?: string;
              min_amount?: number;
              cycle?: number;
              limit?: number;
            }),
        },
        {
          def: SEARCH_SPENDING_TOOL,
          paramsSchema: searchSpendingParamsSchema,
          execute: async (params) =>
            executeSearchSpending(client, params as {
              description?: string;
              recipient_name?: string;
              recipient_state?: string;
              min_amount?: number;
              cycle?: number;
              limit?: number;
            }),
        },
      ];
    
      for (const { def, paramsSchema, execute } of toolRegistrations) {
        server.tool(
          def.name,
          def.description,
          def.inputSchema,
          async (params): Promise<ToolResult> => {
            try {
              const validatedParams = await paramsSchema.parseAsync(params);
              const result = await execute(validatedParams);
              return { ...result } as ToolResult;
            } catch (error) {
              return {
                content: [{ type: 'text', text: formatErrorForToolResponse(error) }],
                isError: true,
              };
            }
          }
        );
      }
    }
  • Tool definition object SEARCH_DONORS_TOOL with name 'search_donors', description, and inputSchema reference.
    export const SEARCH_DONORS_TOOL = {
      name: 'search_donors',
      description: `Search for individual donors across all FEC filings by name, employer, or occupation. Essential for tracking donor patterns, identifying industry contributions, or researching specific individuals' political giving. Supports searching by employer (e.g., "Goldman Sachs") or occupation (e.g., "Lobbyist", "Government Affairs").`,
      inputSchema: searchDonorsInputSchema,
    };
  • FECClient.searchDonors() method - the API client helper that calls the FEC Schedule A endpoint with contributor filters, sorting by amount descending, and limiting to individual donors (is_individual=true).
    async searchDonors(params: SearchDonorsParams, timeout?: number): Promise<FECApiResponse<FECScheduleA>> {
      return this.get<FECScheduleA>(ENDPOINTS.SCHEDULE_A, {
        contributor_name: params.contributor_name,
        contributor_employer: params.contributor_employer,
        contributor_occupation: params.contributor_occupation,
        contributor_state: params.contributor_state,
        min_amount: params.min_amount,
        two_year_transaction_period: params.two_year_transaction_period,
        is_individual: true, // Only search individual donors
        sort: '-contribution_receipt_amount',
        per_page: params.limit || DEFAULT_PER_PAGE,
      }, timeout);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It only describes the search scope ('across all FEC filings') but does not disclose behavioral traits such as pagination, rate limits, authentication needs, or what happens with no results. The behavioral context is minimal.

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 three sentences: first states the action, second lists use cases, third provides examples. It is front-loaded and concise, with no superfluous information. Every sentence contributes to understanding.

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

Completeness3/5

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

Given the tool has 7 optional parameters and no output schema or annotations, the description adequately explains what the tool does and gives examples. However, it lacks discussion of result format, error handling, or how parameters combine, leaving some gaps for an agent.

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?

Schema description coverage is 100%, so each parameter is already documented. The description adds marginal value with examples (employer: 'Goldman Sachs', occupation: 'Lobbyist'), which clarifies usage but does not significantly deepen understanding beyond the schema.

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 'Search for individual donors' and specifies the resource as 'all FEC filings' with search dimensions name, employer, or occupation. It distinguishes from sibling tools by focusing on donors, but does not explicitly differentiate from other search tools like search_candidates.

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

Usage Guidelines3/5

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

The description provides use cases like 'tracking donor patterns' and examples of searching by employer or occupation, implying when to use. However, it lacks explicit when-not-to-use guidance or references to alternative tools for other purposes.

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/sh-patterson/fec-mcp-server'

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