Skip to main content
Glama
sh-patterson

fec-mcp-server

search_spending

Search campaign spending records by description keyword or recipient name to find questionable expenditures and detect potential misuse of funds.

Instructions

Search campaign spending (Schedule B) across all committees by description or recipient. Use to find questionable expenditures like "steak dinner", "event tickets", "travel", "Disney", "golf", or payments to specific vendors. Essential for identifying spending patterns and potential misuse of campaign funds.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoSearch disbursement descriptions for keywords (e.g., "dinner", "travel", "event tickets", "Disney")
recipient_nameNoSearch for payments to a specific recipient/vendor
recipient_stateNoTwo-letter state code to filter by (e.g., "FL", "NV")
min_amountNoMinimum disbursement amount to include
cycleNoTwo-year election cycle (e.g., 2024)
limitNoMaximum number of results to return (default: 20)

Implementation Reference

  • The main handler function for the search_spending tool. Calls the FEC API client's searchSpending method, groups results by committee, formats disbursements into a readable text output including recipient, amount, date, purpose, category, and location.
    export async function executeSearchSpending(
      client: FECClient,
      params: {
        description?: string;
        recipient_name?: string;
        recipient_state?: string;
        min_amount?: number;
        cycle?: number;
        limit?: number;
      }
    ): Promise<SearchSpendingResult> {
      try {
        const response = await client.searchSpending({
          description: params.description,
          recipient_name: params.recipient_name,
          recipient_state: params.recipient_state,
          min_amount: params.min_amount ?? 500, // Default to $500 to filter noise
          two_year_transaction_period: params.cycle,
          limit: params.limit ?? 20,
        }, 60_000);
    
        // Build header
        const lines: string[] = ['## Spending Search Results'];
    
        // Show search criteria
        const criteria: string[] = [];
        if (params.description) criteria.push(`description: "${params.description}"`);
        if (params.recipient_name) criteria.push(`recipient: "${params.recipient_name}"`);
        if (params.recipient_state) criteria.push(`state: ${params.recipient_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} disbursements, showing ${response.results.length}*`);
        lines.push('');
    
        if (response.results.length === 0) {
          lines.push('No disbursements found matching the criteria.');
          return {
            content: [{ type: 'text', text: lines.join('\n') }],
          };
        }
    
        // Calculate totals
        const totalAmount = response.results.reduce((sum, r) => sum + r.disbursement_amount, 0);
        lines.push(`**Total (shown):** ${formatCurrency(totalAmount)}`);
        lines.push('');
    
        // Group by spending committee
        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, disbursements] of byCommittee) {
          const committeeTotal = disbursements.reduce((sum, d) => sum + d.disbursement_amount, 0);
          lines.push(`### ${committeeName} (${formatCurrency(committeeTotal)})`);
    
          for (const disb of disbursements) {
            const location = [disb.recipient_city, disb.recipient_state].filter(Boolean).join(', ');
    
            lines.push(`${index}. **${disb.recipient_name}** - ${formatCurrency(disb.disbursement_amount)}`);
            lines.push(`   - Date: ${formatDate(disb.disbursement_date)}`);
            if (disb.disbursement_description) {
              lines.push(`   - Purpose: ${disb.disbursement_description}`);
            }
            if (disb.disbursement_purpose_category) {
              lines.push(`   - Category: ${disb.disbursement_purpose_category}`);
            }
            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-based input schema defining parameters: description (string), recipient_name (string), recipient_state (2-letter string), min_amount (number >= 0), cycle (int 2000-2030), limit (int 1-100). Includes a superRefine ensuring at least one of description or recipient_name is provided.
    /**
     * search_spending Input Schema
     */
    
    import { z } from 'zod';
    
    export const searchSpendingInputSchema = {
      description: z
        .string()
        .optional()
        .describe('Search disbursement descriptions for keywords (e.g., "dinner", "travel", "event tickets", "Disney")'),
      recipient_name: z
        .string()
        .optional()
        .describe('Search for payments to a specific recipient/vendor'),
      recipient_state: z
        .string()
        .length(2)
        .optional()
        .describe('Two-letter state code to filter by (e.g., "FL", "NV")'),
      min_amount: z
        .number()
        .min(0)
        .optional()
        .describe('Minimum disbursement 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 searchSpendingParamsSchema = z
      .object(searchSpendingInputSchema)
      .superRefine((value, ctx) => {
        if (!value.description && !value.recipient_name) {
          ctx.addIssue({
            code: z.ZodIssueCode.custom,
            message:
              'Please provide at least one search criterion: description or recipient_name.',
          });
        }
      });
    
    export type SearchSpendingInput = z.infer<typeof searchSpendingParamsSchema>;
  • Registers the search_spending tool in the MCP server's tool registry by mapping SEARCH_SPENDING_TOOL, searchSpendingParamsSchema, and executeSearchSpending to the server.tool() call.
    {
      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;
        }),
    },
  • Tool definition object with name 'search_spending', description, and inputSchema. Used for registration.
    export const SEARCH_SPENDING_TOOL = {
      name: 'search_spending',
      description: `Search campaign spending (Schedule B) across all committees by description or recipient. Use to find questionable expenditures like "steak dinner", "event tickets", "travel", "Disney", "golf", or payments to specific vendors. Essential for identifying spending patterns and potential misuse of campaign funds.`,
      inputSchema: searchSpendingInputSchema,
    };
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It only implies a read operation via the word 'search' and notes that it operates 'across all committees'. It does not disclose potential rate limits, pagination, data freshness, or whether it requires authentication. This is minimal for a tool with no other behavioral hints.

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 extremely concise: two sentences and a line, front-loading the core purpose and specific search examples. Every sentence adds value, and there is no redundant or vague language.

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?

Despite having 6 parameters and no output schema, the description does not mention the return format or structure (e.g., list of disbursements). It also lacks information on default behavior, such as ordering or result limit details beyond what the 'limit' parameter specifies. This leaves the agent uncertain about what to expect from the response.

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 covers all 6 parameters with descriptions (100% coverage). The description adds value by providing concrete examples for the 'description' parameter (e.g., 'dinner', 'travel', 'Disney') but does not add meaning beyond the schema for other parameters. Baseline 3 is appropriate.

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 it searches campaign spending by description or recipient across all committees, with specific examples like 'steak dinner' and 'Disney'. However, it does not explicitly differentiate from the sibling tool 'get_disbursements', which also searches disbursements, missing an opportunity to clarify distinct use cases.

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 clear usage context by listing example searches (e.g., 'event tickets', 'golf') and states its purpose for identifying spending patterns. However, it does not mention when to use this tool versus alternatives like 'get_disbursements' or 'get_committee_finances', nor does it specify when not to use it.

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