Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Update Segment

update_segment

Modify an existing email segment's name or query criteria in SendGrid to refine contact targeting and improve campaign personalization.

Instructions

Update an existing segment's name or query criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
segment_idYesID of the segment to update
nameNoNew name for the segment
query_dslNoNew query criteria for the segment (JSON string)

Implementation Reference

  • Handler function that performs the PATCH request to update the segment name or query DSL via SendGrid API, with readonly check and input validation.
      handler: async ({ segment_id, name, query_dsl }: { segment_id: string; name?: string; query_dsl?: string }): Promise<ToolResult> => {
        const readOnlyCheck = checkReadOnlyMode();
        if (readOnlyCheck.blocked) {
          return { content: [{ type: "text", text: readOnlyCheck.message! }] };
        }
        
        const updateData: any = {};
        if (name) updateData.name = name;
        if (query_dsl) {
          try {
            updateData.query_dsl = JSON.parse(query_dsl);
          } catch (error) {
            return { content: [{ type: "text", text: "Error: query_dsl must be valid JSON. Please provide a properly formatted query." }] };
          }
        }
        
        if (Object.keys(updateData).length === 0) {
          return { content: [{ type: "text", text: "Error: Please provide either 'name' or 'query_dsl' to update." }] };
        }
        
        const result = await makeRequest(`https://api.sendgrid.com/v3/marketing/segments/2.0/${segment_id}`, {
          method: "PATCH",
          body: JSON.stringify(updateData),
        });
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
      },
    },
  • Configuration including Zod input schema for the update_segment tool parameters.
    config: {
      title: "Update Segment",
      description: "Update an existing segment's name or query criteria",
      inputSchema: {
        segment_id: z.string().describe("ID of the segment to update"),
        name: z.string().optional().describe("New name for the segment"),
        query_dsl: z.string().optional().describe("New query criteria for the segment (JSON string)"),
      },
    },
  • src/index.ts:21-23 (registration)
    MCP server registration loop that registers all tools from allTools, including update_segment.
    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, including contactTools which contains update_segment.
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a mutation operation ('Update'), but doesn't disclose permissions needed, whether changes are reversible, rate limits, or what happens if only partial parameters are provided. This is inadequate for a mutation tool without annotation support.

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 with no wasted words. It front-loads the core purpose and specifies updatable fields directly, 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?

For a mutation tool with no annotations and no output schema, the description is insufficient. It lacks critical context such as error conditions, response format, side effects, or how updates interact with existing data. Given the complexity of modifying segments, more behavioral transparency is needed.

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%, so parameters are fully documented in the schema. The description adds marginal value by mentioning 'name or query criteria', which aligns with the 'name' and 'query_dsl' parameters, but doesn't provide additional context like format examples or constraints beyond the schema.

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 action ('Update') and resource ('an existing segment'), specifying what can be updated ('name or query criteria'). It distinguishes from siblings like 'delete_segment' by focusing on modification rather than removal, but doesn't explicitly differentiate from other update tools like 'update_contact'.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing segment ID), compare to 'create_segment' (which isn't in the sibling list), or specify scenarios where updates are appropriate versus deletion or creation.

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