Skip to main content
Glama
AgentX-ai

Mailchimp MCP Server

by AgentX-ai

get_template

Retrieve detailed information about a specific Mailchimp email template by providing its template ID for email marketing management.

Instructions

Get details of a specific template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_idYesThe template ID

Implementation Reference

  • The core handler function that executes the tool logic by making an API request to retrieve the specific Mailchimp template using the provided template ID.
    async getTemplate(templateId: number): Promise<MailchimpTemplate> {
      return await this.makeRequest(`/templates/${templateId}`);
    }
  • The MCP tool dispatch handler case for 'get_template' that invokes the service method and formats the JSON response as MCP content.
    case "get_template":
      const template = await service.getTemplate(args.template_id);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(template, null, 2),
          },
        ],
      };
  • The input schema and metadata definition for the 'get_template' tool, including name, description, and required template_id parameter.
    {
      name: "get_template",
      description: "Get details of a specific template",
      inputSchema: {
        type: "object",
        properties: {
          template_id: {
            type: "number",
            description: "The template ID",
          },
        },
        required: ["template_id"],
      },
    },
  • src/index.ts:52-74 (registration)
    MCP server registration of the CallToolRequest handler that routes tool calls (including get_template) to the handleToolCall function.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        return await handleToolCall(
          mailchimpService,
          request.params.name,
          request.params.arguments
        );
      } catch (error: any) {
        console.error("Mailchimp Error:", error);
    
        // Handle Mailchimp API errors
        if (error.message && error.message.includes("Mailchimp API Error:")) {
          throw new McpError(ErrorCode.InternalError, error.message);
        }
    
        // Handle other errors
        if (error instanceof Error) {
          throw new McpError(ErrorCode.InternalError, error.message);
        }
    
        throw new McpError(ErrorCode.InternalError, "An unexpected error occurred");
      }
    });
  • TypeScript interface defining the structure of a MailchimpTemplate, used for type safety in the tool's return value.
    export interface MailchimpTemplate {
      id: number;
      type: "user" | "base" | "gallery";
      name: string;
      drag_and_drop: boolean;
      responsive: boolean;
      category?: string;
      date_created: string;
      created_by: string;
      active: boolean;
      folder_id?: string;
      thumbnail?: string;
      share_url?: string;
      _links?: Array<{
        rel: string;
        href: string;
        method: string;
        targetSchema?: string;
        schema?: string;
      }>;
    }

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/AgentX-ai/mailchimp-mcp'

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