Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

List All Contacts

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);
    }
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. It mentions 'optional pagination', which adds some context about handling large datasets, but fails to describe critical behaviors like whether this is a read-only operation, what permissions are required, rate limits, or the format/structure of returned data. For a list operation with zero annotation coverage, this leaves significant gaps.

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 front-loads the core purpose ('List all contacts') and adds only essential additional context ('with optional pagination'). There is zero wasted verbiage or redundancy, making it highly scannable and appropriately sized for a simple list tool.

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?

For a simple list tool with 100% schema coverage but no annotations or output schema, the description is minimally adequate. It covers the basic action and hints at pagination, but lacks details on behavioral traits (e.g., safety, permissions) and output format. Given the low complexity, it's passable but leaves room for improvement in transparency.

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?

The schema description coverage is 100%, with both parameters ('page_size' and 'page_token') fully documented in the schema. The description adds no additional parameter semantics beyond implying pagination is optional, which is already clear from the schema's default values and optional nature. This meets the baseline of 3 when 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 ('List') and resource ('all contacts'), making the purpose immediately understandable. It distinguishes itself from other contact-related tools like 'get_contact' (single contact) and 'search_contacts' (filtered search), though it doesn't explicitly mention these siblings. The 'all' qualifier helps differentiate it from filtered operations.

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?

The description provides no guidance on when to use this tool versus alternatives like 'search_contacts' or 'get_contact'. While 'all contacts' implies comprehensive retrieval, it doesn't specify scenarios where this is preferred over filtered searches or mention any prerequisites or limitations beyond pagination.

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