Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

search_contacts

Find contacts in SendGrid using search queries with segment conditions to locate specific email addresses or contact groups without creating segments.

Instructions

Search for contacts using query conditions without creating a segment

Input Schema

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

Implementation Reference

  • The handler function that implements the tool logic by constructing a request body with the query and optional pagination parameters, then sending a POST request to the SendGrid /marketing/contacts/search endpoint.
    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) }] }; },
  • Zod schema for input validation: required 'query' string for search conditions, optional 'page_size' (default 50), optional 'page_token' for pagination.
    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)
    Registers all tools from allTools object with the MCP server by iterating and calling server.registerTool for each, including 'search_contacts'.
    for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }
  • Combines contactTools (containing search_contacts) with other tool sets into allTools, which is then imported and registered in src/index.ts.
    export const allTools = { ...automationTools, ...campaignTools, ...contactTools,

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