Skip to main content
Glama
sh-patterson

fec-mcp-server

get_independent_expenditures

Retrieve independent expenditures by PACs and Super PACs, filtered by candidate, committee, support/oppose indicator, or amount. Track outside money influencing federal elections.

Instructions

Retrieve independent expenditures (Schedule E) - money spent by PACs and Super PACs to support or oppose candidates without coordinating with campaigns. Critical for understanding outside money influence in elections. Can filter by candidate targeted, committee spending, or support/oppose indicator.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
candidate_idNoFEC candidate ID to find expenditures targeting this candidate
committee_idNoFEC committee ID to find expenditures made by this committee
support_opposeNoFilter by support or oppose indicator
min_amountNoMinimum expenditure amount to include
cycleNoTwo-year election cycle (e.g., 2024)
limitNoMaximum number of results to return (default: 20)

Implementation Reference

  • Main handler function that executes the get_independent_expenditures tool logic. Calls the FEC API's getScheduleE, formats results using formatIndependentExpenditureText, and returns a formatted response.
    export async function executeGetIndependentExpenditures(
      client: FECClient,
      params: {
        candidate_id?: string;
        committee_id?: string;
        support_oppose?: 'support' | 'oppose';
        min_amount?: number;
        cycle?: number;
        limit?: number;
      }
    ): Promise<GetIndependentExpendituresResult> {
      try {
        // Map support/oppose to FEC indicator
        let supportOpposeIndicator: 'S' | 'O' | undefined;
        if (params.support_oppose === 'support') {
          supportOpposeIndicator = 'S';
        } else if (params.support_oppose === 'oppose') {
          supportOpposeIndicator = 'O';
        }
    
        const response = await client.getScheduleE({
          candidate_id: params.candidate_id,
          committee_id: params.committee_id,
          support_oppose_indicator: supportOpposeIndicator,
          min_amount: params.min_amount,
          two_year_transaction_period: params.cycle,
          limit: params.limit ?? 20,
        });
    
        // Build header based on search type
        let targetCandidate: string | undefined;
        if (params.candidate_id && response.results.length > 0) {
          targetCandidate = response.results[0].candidate_name || params.candidate_id;
        }
    
        // Format response
        const lines: string[] = [];
    
        // Add context header
        if (params.candidate_id) {
          lines.push(`## Independent Expenditures Targeting ${targetCandidate || params.candidate_id}`);
        } else if (params.committee_id) {
          const committeeName = response.results[0]?.committee_name || params.committee_id;
          lines.push(`## Independent Expenditures by ${committeeName}`);
        }
    
        // Add filter info
        const filters: string[] = [];
        if (params.support_oppose) {
          filters.push(`${params.support_oppose} only`);
        }
        if (params.min_amount) {
          filters.push(`minimum $${params.min_amount.toLocaleString()}`);
        }
        if (params.cycle) {
          filters.push(`${params.cycle} cycle`);
        }
    
        if (filters.length > 0) {
          lines.push(`*Filters: ${filters.join(', ')}*`);
        }
    
        lines.push(`*Showing ${response.results.length} of ${response.pagination.count} results*`);
        lines.push('');
    
        // Format the expenditures
        const expendituresText = formatIndependentExpenditureText(response.results, targetCandidate);
        lines.push(expendituresText);
    
        return {
          content: [{ type: 'text', text: lines.join('\n') }],
        };
      } catch (error) {
        return {
          content: [{ type: 'text', text: formatErrorForToolResponse(error) }],
          isError: true,
        };
      }
    }
  • Input schema definition using Zod for validation. Defines fields: candidate_id, committee_id, support_oppose, min_amount, cycle, limit. Uses superRefine to require at least one of candidate_id or committee_id.
    export const getIndependentExpendituresInputSchema = {
      candidate_id: z
        .string()
        .regex(
          candidateIdPattern,
          'Candidate ID must be in format like H8CA15053 or P00009423'
        )
        .optional()
        .describe('FEC candidate ID to find expenditures targeting this candidate'),
      committee_id: z
        .string()
        .regex(committeeIdPattern, 'Committee ID must be in format like C00123456')
        .optional()
        .describe('FEC committee ID to find expenditures made by this committee'),
      support_oppose: z
        .enum(['support', 'oppose'])
        .optional()
        .describe('Filter by support or oppose indicator'),
      min_amount: z
        .number()
        .min(0)
        .optional()
        .describe('Minimum expenditure 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 getIndependentExpendituresParamsSchema = z
      .object(getIndependentExpendituresInputSchema)
      .superRefine((value, ctx) => {
        if (!value.candidate_id && !value.committee_id) {
          ctx.addIssue({
            code: z.ZodIssueCode.custom,
            message:
              'Please provide either a candidate_id or committee_id to search for independent expenditures.',
          });
        }
      });
    
    export type GetIndependentExpendituresInput = z.infer<
      typeof getIndependentExpendituresParamsSchema
    >;
  • Registration of the GET_INDEPENDENT_EXPENDITURES_TOOL in the tools index. Maps the tool definition, paramsSchema, and execute function together for server registration.
          def: GET_INDEPENDENT_EXPENDITURES_TOOL,
          paramsSchema: getIndependentExpendituresParamsSchema,
          execute: async (params) =>
            executeGetIndependentExpenditures(client, params as {
              candidate_id?: string;
              committee_id?: string;
              support_oppose?: 'support' | 'oppose';
              min_amount?: number;
              cycle?: number;
              limit?: number;
            }),
        },
        {
          def: GET_COMMITTEE_FLAGS_TOOL,
          paramsSchema: getCommitteeFlagsParamsSchema,
          execute: async (params) =>
            executeGetCommitteeFlags(client, params as {
              committee_id: string;
              cycle?: number;
            }),
        },
        {
          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 with name 'get_independent_expenditures', description, and inputSchema reference.
    export const GET_INDEPENDENT_EXPENDITURES_TOOL = {
      name: 'get_independent_expenditures',
      description: `Retrieve independent expenditures (Schedule E) - money spent by PACs and Super PACs to support or oppose candidates without coordinating with campaigns. Critical for understanding outside money influence in elections. Can filter by candidate targeted, committee spending, or support/oppose indicator.`,
      inputSchema: getIndependentExpendituresInputSchema,
    };
  • Helper function to format independent expenditure results for display. Groups by support/oppose, shows totals, and lists each expenditure with committee name, amount, candidate, date, purpose, and payee.
    export function formatIndependentExpenditureText(
      expenditures: FECScheduleE[],
      targetCandidate?: string
    ): string {
      if (expenditures.length === 0) {
        return 'No independent expenditures found matching the criteria.';
      }
    
      const lines: string[] = [];
    
      if (targetCandidate) {
        lines.push(`## Independent Expenditures Targeting ${targetCandidate}`);
      } else {
        lines.push('## Independent Expenditures');
      }
      lines.push('');
    
      // Group by support/oppose
      const supporting = expenditures.filter(e => e.support_oppose_indicator === 'S');
      const opposing = expenditures.filter(e => e.support_oppose_indicator === 'O');
    
      const totalSupport = supporting.reduce((sum, e) => sum + e.expenditure_amount, 0);
      const totalOppose = opposing.reduce((sum, e) => sum + e.expenditure_amount, 0);
    
      lines.push(`**Total Supporting:** ${formatCurrency(totalSupport)} (${supporting.length} expenditures)`);
      lines.push(`**Total Opposing:** ${formatCurrency(totalOppose)} (${opposing.length} expenditures)`);
      lines.push('');
    
      expenditures.forEach((exp, index) => {
        const indicator = exp.support_oppose_indicator === 'S' ? '✓ SUPPORT' : '✗ OPPOSE';
        lines.push(`${index + 1}. **${exp.committee_name}** - ${formatCurrency(exp.expenditure_amount)} [${indicator}]`);
        if (exp.candidate_name) {
          lines.push(`   - Candidate: ${exp.candidate_name} (${exp.candidate_party || 'Unknown party'})`);
        }
        lines.push(`   - Date: ${formatDate(exp.expenditure_date)}`);
        if (exp.expenditure_description) {
          lines.push(`   - Purpose: ${exp.expenditure_description}`);
        }
        if (exp.payee_name) {
          lines.push(`   - Paid to: ${exp.payee_name}`);
        }
        lines.push('');
      });
    
      return lines.join('\n');
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It explains the nature of the data (outside money, no coordination) but does not disclose behavioral traits like read-only nature, rate limits, pagination, or response format. Some transparency is gained through the context, but it is incomplete.

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?

Three sentences, each earning its place: first defines purpose, second adds importance, third lists key filters. No wasted words, front-loaded with the action.

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?

For a tool with 6 parameters (all documented), no output schema, and no annotations, the description adequately explains the use case and filters. However, it omits any description of the output format (e.g., what fields are returned), which is a gap given the absence of an output schema.

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 coverage is 100%, so baseline is 3. The description mentions 'candidate targeted' (candidate_id), 'committee spending' (committee_id), and 'support/oppose indicator' (support_oppose), adding minimal context beyond the schema. It does not cover min_amount or cycle, but these are well-documented in the schema.

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

Purpose5/5

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

The description clearly states the verb 'retrieve' and the resource 'independent expenditures (Schedule E)', explaining that they are money spent by PACs and Super PACs to support or oppose candidates. This distinguishes it from sibling tools like 'get_committee_finances' or 'get_receipts'.

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

Usage Guidelines4/5

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

The description says 'Critical for understanding outside money influence in elections' and lists filters like candidate targeted and support/oppose indicator, implying when to use the tool. However, it does not explicitly state when not to use it or compare it to alternatives.

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