Skip to main content
Glama
hdmt
by hdmt

create_draft_email

Create draft emails in HubSpot by defining campaign details, content, and recipient settings for marketing communications.

Instructions

メールの下書きを作成。既存メールを複製する場合はget_emailで取得したcontent等を渡す

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesキャンペーン名
subjectYesメール件名
htmlBodyNoHTML本文(シンプルなメール用)
contentNoメールコンテンツ構造(flexAreas, widgets等を含む詳細設定)
fromNo送信者情報 { fromName, replyTo }
subscriptionDetailsNo配信設定 { officeLocationId }
toNo送信先設定 { contactIlsLists, suppressGraymail }

Implementation Reference

  • The MCP tool handler that executes create_draft_email. It parses the request arguments using CreateDraftEmailSchema, calls the HubSpot client's createDraftEmail method, and returns a success message with the email ID, name, and subject.
    case 'create_draft_email': { const args = CreateDraftEmailSchema.parse(request.params.arguments); const result = await this.hubspot.createDraftEmail( args.name, args.subject, { htmlBody: args.htmlBody, content: args.content, from: args.from, subscriptionDetails: args.subscriptionDetails, to: args.to, } ); return { content: [ { type: 'text', text: `✅ メール下書きを作成しました\nID: ${result.id}\n名前: ${args.name}\n件名: ${args.subject}`, }, ], }; }
  • The HubSpot API client implementation of createDraftEmail. Constructs the email data object with name, subject, emailType 'BATCH_EMAIL', and state 'DRAFT', then optionally adds htmlBody, content, from, subscriptionDetails, and to fields before calling the createEmail method.
    async createDraftEmail( name: string, subject: string, options?: { htmlBody?: string; content?: any; from?: any; subscriptionDetails?: any; to?: any; } ) { const data: any = { name, subject, emailType: 'BATCH_EMAIL', state: 'DRAFT', }; if (options?.htmlBody) { data.emailBody = options.htmlBody; } if (options?.content) { data.content = options.content; } if (options?.from) { data.from = options.from; } if (options?.subscriptionDetails) { data.subscriptionDetails = options.subscriptionDetails; } if (options?.to) { data.to = options.to; } return this.createEmail(data); }
  • Zod schema definition for CreateDraftEmailSchema. Validates the input parameters including required fields (name, subject) and optional fields (htmlBody, content, from, subscriptionDetails, to).
    export const CreateDraftEmailSchema = z.object({ name: z.string().describe('メールキャンペーンの名前'), subject: z.string().describe('メールの件名'), htmlBody: z.string().optional().describe('HTMLメール本文(シンプルなメール用)'), content: z.any().optional().describe('メールコンテンツ構造(flexAreas, widgets等を含む詳細設定)'), from: z.any().optional().describe('送信者情報 { fromName, replyTo }'), subscriptionDetails: z.any().optional().describe('配信設定 { officeLocationId }'), to: z.any().optional().describe('送信先設定 { contactIlsLists, suppressGraymail }'), });
  • src/server.ts:64-78 (registration)
    Tool registration in the MCP server's tools list. Defines the create_draft_email tool with its description and input schema including required fields (name, subject) and optional fields (htmlBody, content, from, subscriptionDetails, to).
    name: 'create_draft_email', description: 'メールの下書きを作成。既存メールを複製する場合はget_emailで取得したcontent等を渡す', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'キャンペーン名' }, subject: { type: 'string', description: 'メール件名' }, htmlBody: { type: 'string', description: 'HTML本文(シンプルなメール用)' }, content: { type: 'object', description: 'メールコンテンツ構造(flexAreas, widgets等を含む詳細設定)' }, from: { type: 'object', description: '送信者情報 { fromName, replyTo }' }, subscriptionDetails: { type: 'object', description: '配信設定 { officeLocationId }' }, to: { type: 'object', description: '送信先設定 { contactIlsLists, suppressGraymail }' }, }, required: ['name', 'subject'], },
  • Helper method createEmail that performs the actual POST request to HubSpot's /marketing/v3/emails endpoint with the provided data. Called by createDraftEmail after constructing the email data object.
    async createEmail(data: any) { return this.request('/marketing/v3/emails', { method: 'POST', body: JSON.stringify(data), }); }

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/hdmt/hubspot-email-mcp'

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