Skip to main content
Glama
Garoth

SendGrid MCP Server

by Garoth

get_contacts_by_list

Retrieve all contacts from a specific SendGrid email list using the list ID to manage and organize your email marketing recipients.

Instructions

Get all contacts in a SendGrid list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesID of the contact list

Implementation Reference

  • The handler logic within handleToolCall that executes the 'get_contacts_by_list' tool. It calls the SendGrid service method with the provided list_id and returns a formatted JSON string of the contacts (email, first_name, last_name).
    case 'get_contacts_by_list':
      const contacts = await service.getContactsByList(args.list_id);
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(contacts.map(c => ({
            email: c.email,
            first_name: c.first_name,
            last_name: c.last_name
          })), null, 2)
        }]
      };
  • Input schema and tool definition (registration) for 'get_contacts_by_list', requiring a 'list_id' string parameter.
    {
      name: 'get_contacts_by_list',
      description: 'Get all contacts in a SendGrid list',
      inputSchema: {
        type: 'object',
        properties: {
          list_id: {
            type: 'string',
            description: 'ID of the contact list'
          }
        },
        required: ['list_id']
      }
    },
  • Core helper method in SendGridService that queries the SendGrid Marketing Contacts Search API to retrieve all contacts belonging to the specified list using a CONTAINS query on list_ids.
    async getContactsByList(listId: string): Promise<SendGridContact[]> {
      const [response] = await this.client.request({
        method: 'POST',
        url: '/v3/marketing/contacts/search',
        body: {
          query: `CONTAINS(list_ids, '${listId}')`
        }
      });
      return (response.body as { result: SendGridContact[] }).result || [];
    }
  • src/index.ts:42-46 (registration)
    MCP server registration for listing tools, which includes 'get_contacts_by_list' via getToolDefinitions.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: getToolDefinitions(sendGridService)
      };
    });
  • src/index.ts:52-55 (registration)
    MCP server handler for tool calls, delegating to handleToolCall which processes 'get_contacts_by_list'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        return await handleToolCall(sendGridService, request.params.name, request.params.arguments);
      } catch (error: any) {
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states a read operation ('Get') but doesn't disclose behavioral traits like whether it requires authentication, returns paginated results, has rate limits, or what format the contacts are returned in. For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and multiple sibling tools, the description is incomplete. It doesn't explain return values, differentiate from similar tools, or cover behavioral aspects like authentication or pagination. For a tool in this context, more information is needed to guide effective use.

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%, with the single parameter 'list_id' documented in the schema. The description adds no additional meaning beyond implying the parameter is used to specify which list to get contacts from. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't enhance parameter understanding.

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 ('Get') and resource ('all contacts in a SendGrid list'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'list_contacts' or 'list_contact_lists', which could cause confusion about when to use this specific tool versus those alternatives.

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. With siblings like 'list_contacts' and 'list_contact_lists' available, the agent has no indication whether this tool is for bulk retrieval from a specific list, filtered queries, or other use cases. No exclusions or prerequisites are mentioned.

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

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