Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

list_contacts

Retrieve and manage your SendGrid contact list with pagination support to organize email marketing recipients effectively.

Instructions

List all contacts with optional pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_sizeNoNumber of contacts to return (max 1000)
page_tokenNoToken for pagination

Implementation Reference

  • The handler function implements the core logic for listing contacts. It constructs a paginated API URL for SendGrid's marketing/contacts endpoint and fetches the results using makeRequest, returning formatted JSON.
    handler: async ({ page_size, page_token }: { page_size?: number; page_token?: string }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/marketing/contacts?page_size=${page_size || 100}`; if (page_token) url += `&page_token=${page_token}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Tool configuration including title, description, and Zod-based inputSchema for validating pagination parameters (page_size and page_token).
    config: { title: "List All Contacts", description: "List all contacts with optional pagination", inputSchema: { page_size: z.number().optional().default(100).describe("Number of contacts to return (max 1000)"), page_token: z.string().optional().describe("Token for pagination"), }, },
  • The list_contacts tool is defined and registered as a property within the exported contactTools object.
    list_contacts: { config: { title: "List All Contacts", description: "List all contacts with optional pagination", inputSchema: { page_size: z.number().optional().default(100).describe("Number of contacts to return (max 1000)"), page_token: z.string().optional().describe("Token for pagination"), }, }, handler: async ({ page_size, page_token }: { page_size?: number; page_token?: string }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/marketing/contacts?page_size=${page_size || 100}`; if (page_token) url += `&page_token=${page_token}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, },
  • src/index.ts:21-23 (registration)
    Final MCP server registration of all tools, including list_contacts, by iterating over allTools and calling registerTool for each.
    for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }

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