Skip to main content
Glama
psalzman

MCP OpenFEC Server

by psalzman

search_candidates

Find U.S. political candidates by name, state, office, or election year to access Federal Election Commission campaign finance data.

Instructions

Search for candidates by name or other criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCandidate name search string
stateNoOptional: Two-letter state code
officeNoOptional: H for House, S for Senate, P for President
election_yearNoOptional: Filter by election year

Implementation Reference

  • The handler function that implements the search_candidates tool logic: validates arguments using Zod, queries the OpenFEC API endpoint /candidates/search, and returns the response as JSON text content.
    private async handleSearchCandidates(args: any) {
      const schema = z.object({
        name: z.string(),
        state: z.string().optional(),
        office: z.enum(['H', 'S', 'P']).optional(),
        election_year: z.number().optional(),
      });
    
      const { name, state, office, election_year } = schema.parse(args);
      this.rateLimiter.consumeToken();
    
      const response = await this.axiosInstance.get('/candidates/search', {
        params: {
          q: name,
          state,
          office,
          election_year,
        },
      });
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(response.data, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the search_candidates tool, defining parameters like name (required), state, office, and election_year.
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Candidate name search string',
        },
        state: {
          type: 'string',
          description: 'Optional: Two-letter state code',
        },
        office: {
          type: 'string',
          description: 'Optional: H for House, S for Senate, P for President',
          enum: ['H', 'S', 'P'],
        },
        election_year: {
          type: 'number',
          description: 'Optional: Filter by election year',
        },
      },
      required: ['name'],
    },
  • src/server.ts:129-155 (registration)
    Registration of the search_candidates tool in the ListTools response, including name, description, and input schema.
    {
      name: 'search_candidates',
      description: 'Search for candidates by name or other criteria',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Candidate name search string',
          },
          state: {
            type: 'string',
            description: 'Optional: Two-letter state code',
          },
          office: {
            type: 'string',
            description: 'Optional: H for House, S for Senate, P for President',
            enum: ['H', 'S', 'P'],
          },
          election_year: {
            type: 'number',
            description: 'Optional: Filter by election year',
          },
        },
        required: ['name'],
      },
    },
  • src/server.ts:449-450 (registration)
    Dispatch case in CallToolRequest handler that routes search_candidates calls to the handleSearchCandidates method.
    case 'search_candidates':
      return await this.handleSearchCandidates(request.params.arguments);
  • Zod runtime validation schema used inside the handler, matching the tool's inputSchema.
    const schema = z.object({
      name: z.string(),
      state: z.string().optional(),
      office: z.enum(['H', 'S', 'P']).optional(),
      election_year: z.number().optional(),
    });
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 of behavioral disclosure. It states the action ('search') but doesn't describe key traits like whether results are paginated, sorted, or limited; authentication needs; rate limits; or what the output looks like (e.g., list of candidates). This leaves significant gaps for a search tool.

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 front-loads the core purpose ('search for candidates') and adds just enough detail ('by name or other criteria') without redundancy. Every word earns its place, 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 complexity of a search tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., result format, pagination), usage context, and output expectations, which are critical for effective tool invocation. It relies too heavily on the schema alone.

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 the schema fully documents all parameters (name, state, office, election_year). The description adds minimal value beyond the schema, mentioning 'name or other criteria' which loosely maps to parameters but doesn't provide additional syntax, format, or usage details. Baseline 3 is appropriate as the 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 ('search') and resource ('candidates'), specifying search criteria ('by name or other criteria'). It distinguishes from siblings like 'get_candidate' (singular retrieval) by indicating a search operation, though it doesn't explicitly contrast with other search-like tools (none listed).

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?

No guidance on when to use this tool versus alternatives is provided. It doesn't mention when to prefer this over 'get_candidate' (for specific retrieval) or other sibling tools, nor does it specify prerequisites or exclusions. Usage is implied by the search functionality but not explicitly framed.

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