Skip to main content
Glama
psalzman

MCP OpenFEC Server

by psalzman

get_independent_expenditures

Retrieve independent expenditures supporting or opposing political candidates from Federal Election Commission data. Filter by candidate, committee, support/oppose status, date range, and amount.

Instructions

Get independent expenditures supporting or opposing candidates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
candidate_idNoOptional: FEC candidate ID
committee_idNoOptional: FEC committee ID
support_oppose_indicatorNoOptional: S for supporting or O for opposing
min_dateNoOptional: Minimum expenditure date (YYYY-MM-DD)
max_dateNoOptional: Maximum expenditure date (YYYY-MM-DD)
min_amountNoOptional: Minimum expenditure amount
max_amountNoOptional: Maximum expenditure amount
sortNoOptional: Sort by expenditure amount

Implementation Reference

  • The handler function that executes the tool logic: validates input parameters using Zod, queries the OpenFEC API at /schedules/schedule_e for independent expenditures data, and returns the JSON response as text content.
    private async handleGetIndependentExpenditures(args: any) {
      const schema = z.object({
        candidate_id: z.string().optional(),
        committee_id: z.string().optional(),
        support_oppose_indicator: z.enum(['S', 'O']).optional(),
        min_date: z.string().optional(),
        max_date: z.string().optional(),
        min_amount: z.number().optional(),
        max_amount: z.number().optional(),
        sort: z.enum(['asc', 'desc']).optional()
      });
    
      const params = schema.parse(args);
      this.rateLimiter.consumeToken();
    
      const response = await this.axiosInstance.get('/schedules/schedule_e', {
        params: {
          ...params,
          sort_hide_null: true,
          sort: params.sort === 'desc' ? '-expenditure_amount' : 'expenditure_amount',
          per_page: 20
        }
      });
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(response.data, null, 2),
          },
        ],
      };
    }
  • src/server.ts:233-274 (registration)
    Tool registration in the MCP server's tools list, defining the tool name, description, and input schema for validation.
      name: 'get_independent_expenditures',
      description: 'Get independent expenditures supporting or opposing candidates',
      inputSchema: {
        type: 'object',
        properties: {
          candidate_id: {
            type: 'string',
            description: 'Optional: FEC candidate ID'
          },
          committee_id: {
            type: 'string',
            description: 'Optional: FEC committee ID'
          },
          support_oppose_indicator: {
            type: 'string',
            enum: ['S', 'O'],
            description: 'Optional: S for supporting or O for opposing'
          },
          min_date: {
            type: 'string',
            description: 'Optional: Minimum expenditure date (YYYY-MM-DD)'
          },
          max_date: {
            type: 'string',
            description: 'Optional: Maximum expenditure date (YYYY-MM-DD)'
          },
          min_amount: {
            type: 'number',
            description: 'Optional: Minimum expenditure amount'
          },
          max_amount: {
            type: 'number',
            description: 'Optional: Maximum expenditure amount'
          },
          sort: {
            type: 'string',
            enum: ['asc', 'desc'],
            description: 'Optional: Sort by expenditure amount'
          }
        }
      }
    },
  • src/server.ts:459-460 (registration)
    Dispatcher case in the request handler that routes calls to the specific handler function.
    case 'get_independent_expenditures':
      return await this.handleGetIndependentExpenditures(request.params.arguments);
  • Runtime input validation schema inside the handler, matching the registered inputSchema.
    const schema = z.object({
      candidate_id: z.string().optional(),
      committee_id: z.string().optional(),
      support_oppose_indicator: z.enum(['S', 'O']).optional(),
      min_date: z.string().optional(),
      max_date: z.string().optional(),
      min_amount: z.number().optional(),
      max_amount: z.number().optional(),
      sort: z.enum(['asc', 'desc']).optional()
    });

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