Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

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, };

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