Skip to main content
Glama
ZLeventer

hubspot-mcp

hs_get_email_campaign_stats

Retrieve opens, clicks, bounces, and unsubscribes for a HubSpot marketing email using its ID.

Instructions

Get performance statistics (opens, clicks, bounces, unsubscribes) for a specific marketing email.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdYesHubSpot marketing email ID

Implementation Reference

  • The actual handler function that executes the tool logic: fetches email details and statistics via HubSpot API, then returns combined result.
    export async function getEmailCampaignStats(args: z.infer<typeof GetEmailCampaignStatsSchema>) {
      const [details, stats] = await Promise.all([
        hubspot(`/marketing-emails/v1/emails/${args.emailId}`),
        hubspot(`/marketing-emails/v1/emails/${args.emailId}/statistics/summary`),
      ]);
      return { details, stats };
    }
  • Input schema for the tool, requiring a single 'emailId' (number) describing the HubSpot marketing email ID.
    export const GetEmailCampaignStatsSchema = z.object({
      emailId: z.number().int().describe("HubSpot marketing email ID"),
    });
  • src/index.ts:225-230 (registration)
    Registration of the tool with the MCP server: name 'hs_get_email_campaign_stats', description, schema reference, and async handler calling getEmailCampaignStats.
    server.tool(
      "hs_get_email_campaign_stats",
      "Get performance statistics (opens, clicks, bounces, unsubscribes) for a specific marketing email.",
      GetEmailCampaignStatsSchema.shape,
      async (args) => { try { return ok(await getEmailCampaignStats(args)); } catch (e) { return err(e); } },
    );
  • Generic HTTP client ('hubspot') used by the handler to make GET requests to the HubSpot API.
    export async function hubspot<T = unknown>(
      path: string,
      method: "GET" | "POST" | "PATCH" | "DELETE" = "GET",
      body?: unknown,
      params?: Record<string, string | number | boolean>,
    ): Promise<T> {
      const token = getToken();
    
      let url = `${BASE_URL}${path}`;
      if (params && method === "GET") {
        const qs = new URLSearchParams(
          Object.entries(params).map(([k, v]) => [k, String(v)]),
        ).toString();
        if (qs) url += `?${qs}`;
      }
    
      const res = await fetch(url, {
        method,
        headers: {
          Authorization: `Bearer ${token}`,
          "Content-Type": "application/json",
        },
        ...(body && method !== "GET" ? { body: JSON.stringify(body) } : {}),
      });
    
      if (!res.ok) {
        const text = await res.text().catch(() => res.statusText);
        throw new HubSpotError(`HubSpot API error (${res.status}): ${text}`, res.status);
      }
    
      if (res.status === 204) return undefined as T;
      return (await res.json()) as T;
    }
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 does not mention read-only behavior, authentication needs, rate limits, or return format. For a tool that retrieves data, more behavioral context is expected beyond listing metric names.

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?

One concise sentence that efficiently conveys the tool's purpose and the metrics involved. No wasted words or redundancy.

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

Completeness4/5

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

For a simple tool with one parameter and no output schema, the description adequately covers what it does and what metrics are returned. It lacks details on return format but is sufficient for a single-purpose tool.

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% (the single parameter emailId is described as 'HubSpot marketing email ID'). The description reiterates 'specific marketing email' but adds no new semantic meaning beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 the resource 'performance statistics for a specific marketing email', listing the specific metrics (opens, clicks, bounces, unsubscribes). It distinguishes from siblings like hs_list_marketing_emails which lists emails rather than providing stats.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when stats for a specific email are needed. No explicit when-not or alternative is given, but the context is clear enough given the single purpose.

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

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