Skip to main content
Glama
jginorio

Sprout Social MCP Server

by jginorio

get_profile_analytics

Retrieve owned profile analytics, including impressions and engagements, for specified profiles within a date range up to one year.

Instructions

Get owned profile-level analytics (impressions, engagements, etc.) for one or more profiles over a reporting period. Requires a reporting_period filter in the format 'YYYY-MM-DD...YYYY-MM-DD' (max 1 year span).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
profile_idsYesArray of customer_profile_id values to query. Use get_profiles to discover available IDs.
metricsYesMetrics to retrieve, e.g. ['impressions', 'engagements', 'reactions', 'post_link_clicks']. Available metrics depend on profile type.
reporting_period_startYesStart date in YYYY-MM-DD format.
reporting_period_endYesEnd date in YYYY-MM-DD format.
pageNoPage number for paginated results (default: 1).

Implementation Reference

  • Handler function that builds the request body with filters (profile_ids, reporting_period) and metrics, optionally adds pagination, then POSTs to /analytics/profiles and returns the result.
    async ({ profile_ids, metrics, reporting_period_start, reporting_period_end, page }) => {
      const body: Record<string, unknown> = {
        filters: [
          `customer_profile_id.eq(${profile_ids.join(", ")})`,
          `reporting_period.in(${reporting_period_start}...${reporting_period_end})`,
        ],
        metrics,
      };
      if (page) body.page = page;
    
      const data = await sproutRequest("POST", "/analytics/profiles", body);
      return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
    }
  • Zod schema defining input parameters: profile_ids (string array), metrics (string array), reporting_period_start (string), reporting_period_end (string), and optional page (number).
    {
      profile_ids: z
        .array(z.string())
        .describe(
          "Array of customer_profile_id values to query. Use get_profiles to discover available IDs."
        ),
      metrics: z
        .array(z.string())
        .describe(
          "Metrics to retrieve, e.g. ['impressions', 'engagements', 'reactions', 'post_link_clicks']. " +
            "Available metrics depend on profile type."
        ),
      reporting_period_start: z
        .string()
        .describe("Start date in YYYY-MM-DD format."),
      reporting_period_end: z
        .string()
        .describe("End date in YYYY-MM-DD format."),
      page: z
        .number()
        .optional()
        .describe("Page number for paginated results (default: 1)."),
    },
  • src/index.ts:172-212 (registration)
    Registration of 'get_profile_analytics' tool on the MCP server with tool name, description, Zod schema, and async handler.
    server.tool(
      "get_profile_analytics",
      "Get owned profile-level analytics (impressions, engagements, etc.) for one or more profiles over a reporting period. " +
        "Requires a reporting_period filter in the format 'YYYY-MM-DD...YYYY-MM-DD' (max 1 year span).",
      {
        profile_ids: z
          .array(z.string())
          .describe(
            "Array of customer_profile_id values to query. Use get_profiles to discover available IDs."
          ),
        metrics: z
          .array(z.string())
          .describe(
            "Metrics to retrieve, e.g. ['impressions', 'engagements', 'reactions', 'post_link_clicks']. " +
              "Available metrics depend on profile type."
          ),
        reporting_period_start: z
          .string()
          .describe("Start date in YYYY-MM-DD format."),
        reporting_period_end: z
          .string()
          .describe("End date in YYYY-MM-DD format."),
        page: z
          .number()
          .optional()
          .describe("Page number for paginated results (default: 1)."),
      },
      async ({ profile_ids, metrics, reporting_period_start, reporting_period_end, page }) => {
        const body: Record<string, unknown> = {
          filters: [
            `customer_profile_id.eq(${profile_ids.join(", ")})`,
            `reporting_period.in(${reporting_period_start}...${reporting_period_end})`,
          ],
          metrics,
        };
        if (page) body.page = page;
    
        const data = await sproutRequest("POST", "/analytics/profiles", body);
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Helper function sproutRequest that constructs and executes HTTP requests to the Sprout Social API with authentication and error handling.
    async function sproutRequest(
      method: "GET" | "POST",
      path: string,
      body?: Record<string, unknown>
    ): Promise<unknown> {
      const { apiKey, customerId } = getConfig();
      const url = `${SPROUT_API_BASE}/v1/${customerId}${path}`;
    
      const headers: Record<string, string> = {
        Authorization: `Bearer ${apiKey}`,
        Accept: "application/json",
      };
    
      const options: RequestInit = { method, headers };
    
      if (body) {
        headers["Content-Type"] = "application/json";
        options.body = JSON.stringify(body);
      }
    
      const response = await fetch(url, options);
    
      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(
          `Sprout Social API error (${response.status}): ${errorText}`
        );
      }
    
      return response.json();
    }
Behavior3/5

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

No annotations are provided, so the description must carry the full burden. It mentions the 'owned' scope implying access requirements, and the date format/span constraints. However, it does not disclose pagination behavior, rate limits, or error handling for invalid IDs, which are relevant for a query tool.

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 two concise sentences with no wasted words, efficiently conveying the core functionality and key constraints.

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

Completeness3/5

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

The description covers the main purpose and constraints but lacks details on pagination, return format (no output schema), or what happens with invalid parameters. Given the tool's complexity (5 params) and no output schema, more completeness would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already describes all parameters with 100% coverage. The description adds value by specifying the format and max span for the reporting period and referencing get_profiles for ID discovery, which aids understanding beyond the schema.

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 tool retrieves owned profile-level analytics (impressions, engagements, etc.) for one or more profiles over a period, using specific verbs and resources. It differentiates from siblings like get_post_analytics by specifying 'profile-level'.

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 explicitly requires a reporting_period filter with format and max span, and suggests using get_profiles to discover IDs. However, it does not explicitly mention when not to use this tool or compare to alternative tools.

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/jginorio/sprout-social-mcp'

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