Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Search Contacts

search_contacts

Search SendGrid contacts using query conditions to find specific recipients without creating segments, enabling targeted contact management.

Instructions

Search for contacts using query conditions without creating a segment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query using segment conditions (e.g., 'email LIKE "@example.com"')
page_sizeNoNumber of results to return (max 100)
page_tokenNoToken for pagination

Implementation Reference

  • The handler function that executes the search_contacts tool. It builds the request body from input parameters and sends a POST request to SendGrid's /marketing/contacts/search endpoint, returning the search results as JSON.
    handler: async ({ query, page_size, page_token }: { query: string; page_size?: number; page_token?: string }): Promise<ToolResult> => {
      const requestBody: any = {
        query: query
      };
      
      if (page_size) requestBody.page_size = page_size;
      if (page_token) requestBody.page_token = page_token;
      
      const result = await makeRequest("https://api.sendgrid.com/v3/marketing/contacts/search", {
        method: "POST",
        body: JSON.stringify(requestBody),
      });
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    },
  • The tool configuration including title, description, and Zod inputSchema defining the parameters for search_contacts: query (string), page_size (number optional default 50), page_token (string optional).
    config: {
      title: "Search Contacts",
      description: "Search for contacts using query conditions without creating a segment",
      inputSchema: {
        query: z.string().describe("Search query using segment conditions (e.g., 'email LIKE \"@example.com\"')"),
        page_size: z.number().optional().default(50).describe("Number of results to return (max 100)"),
        page_token: z.string().optional().describe("Token for pagination"),
      },
    },
  • src/index.ts:21-23 (registration)
    Registration of all tools via loop over allTools object, calling server.registerTool for each, including search_contacts by its name key.
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
  • Aggregation of all tool sets into allTools by spreading contactTools (containing search_contacts) with other tool modules.
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,
      ...mailTools,
      ...miscTools,
      ...statsTools,
      ...templateTools,
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. The description mentions the search functionality and that it doesn't create segments, but doesn't disclose important behavioral traits: whether this is a read-only operation, what permissions might be required, whether there are rate limits, what the return format looks like (especially with pagination), or error conditions. For a search tool with no annotation coverage, this is a significant gap.

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 that communicates the core functionality and a key distinction ('without creating a segment'). It's appropriately sized for the tool's complexity and front-loads the essential information. There's no wasted verbiage or redundant information.

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's moderate complexity (search with pagination), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and distinguishes from segment creation tools, but doesn't provide enough context about behavioral aspects, return values, or detailed usage scenarios. The absence of output schema means the description should ideally explain what the search returns, but it doesn't.

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 already documents all three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. It mentions 'query conditions' which aligns with the schema's description of the query parameter, but provides no additional syntax examples, format details, or usage guidance beyond what the schema already states. Baseline 3 is appropriate when 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 tool's purpose: 'Search for contacts using query conditions' - a specific verb ('Search') and resource ('contacts'). It distinguishes from siblings by mentioning 'without creating a segment', which differentiates it from segment-related tools like create_segment or open_segment_creator. However, it doesn't explicitly differentiate from other search/list tools like list_contacts or search_contacts_by_emails.

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 some usage guidance by stating 'without creating a segment', which implies this is for ad-hoc searching rather than persistent segment creation. However, it doesn't explicitly state when to use this tool versus alternatives like list_contacts (which might list all contacts without filtering) or search_contacts_by_emails (which appears to search specifically by email addresses). No explicit when-not-to-use guidance or prerequisite information is provided.

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/deyikong/sendgrid-mcp'

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