Skip to main content
Glama
alloufj

Grips Intelligence MCP Server

by alloufj

Get device mix (mobile / desktop / tablet)

grips_get_devices
Read-onlyIdempotent

Retrieve device-level revenue, sessions, transactions, conversion rate, and average order value for competitor domains to compare mobile and desktop performance over a date window.

Instructions

Returns device-level revenue, sessions, transactions, CR, and AOV for one or more domains aggregated over a date window. Use this to understand where a competitor's traffic and conversions come from — mobile vs desktop split, AOV by device, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainsYesOne or more domains (e.g. ['adidas.com', 'nike.com']). Protocol and trailing slash are stripped automatically.
date_fromYesStart of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-01-01'.
date_toYesEnd of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-12-31'.
countryNoOptional country filter. Defaults to the server's GRIPS_DEFAULT_COUNTRY (usually 'US').
formatNoResponse format. 'markdown' is human-readable; 'json' is machine-parseable.markdown

Implementation Reference

  • Main handler function `runDevices` for the grips_get_devices tool. Queries the Grips API for device-mix data, handles two possible response shapes (dict and array), deduplicates results, and formats output as JSON or Markdown.
    export async function runDevices(
      client: GripsApiClient,
      args: DevicesInput,
      defaultCountry: string,
    ): Promise<string> {
      const country = args.country ?? defaultCountry;
      const variables = buildFilters({
        domains: args.domains,
        date_from: args.date_from,
        date_to: args.date_to,
        country,
      });
    
      let raw: {
        data?: unknown;
        aggregated?: unknown;
      } = {};
      try {
        raw = await client.query<{ data?: unknown; aggregated?: unknown }>({
          query: DEVICES_QUERY,
          variables,
        });
      } catch (err) {
        const msg = formatUpstreamError(err);
        const hint = errorHint(err);
        return `Error: ${msg}${hint ? `\n\nHint: ${hint}` : ""}`;
      }
    
      // Grips devices has been observed in two shapes:
      //   (a) { data: { mobile: {...}, desktop: {...} } }  (per public docs)
      //   (b) { aggregated: [{ device: 'mobile', ... }, ...] }  (observed at runtime)
      // Handle both robustly.
      const shapeA = toObject<Record<string, DeviceMetrics>>(raw.data);
      const shapeB = toArray<{ device: string } & DeviceMetrics>(raw.aggregated);
    
      const deviceRows: Array<{ device: string } & DeviceMetrics> = [];
    
      for (const [device, metrics] of Object.entries(shapeA)) {
        const m = toObject<DeviceMetrics>(metrics);
        deviceRows.push({ device, ...m });
      }
      for (const row of shapeB) {
        const m = toObject<{ device?: string } & DeviceMetrics>(row);
        const device = typeof m.device === "string" ? m.device : "(unknown)";
        // Don't double-count if a device was already in shapeA.
        if (deviceRows.some((r) => r.device === device)) continue;
        deviceRows.push({ device, ...m });
      }
    
      if (deviceRows.length === 0) {
        return `**Grips device mix — ${args.domains.join(", ")} (${country}, ${args.date_from} → ${args.date_to})**\n\n_No device data returned by Grips for this filter set._`;
      }
    
      if (args.format === "json") {
        return toJson({
          domains: args.domains,
          country,
          date_from: args.date_from,
          date_to: args.date_to,
          devices: deviceRows.map((r) => ({
            device: r.device,
            sessions: safeNumberOrNull(r.sessions),
            transactions: safeNumberOrNull(r.transactions),
            cr: safeNumberOrNull(r.cr),
            aov: safeNumberOrNull(r.aov),
            transactionrevenue: safeNumberOrNull(r.transactionrevenue),
          })),
        });
      }
    
      const table = toMarkdownTable(
        deviceRows.map((r) => ({
          Device: r.device,
          Revenue: formatCurrency(r.transactionrevenue),
          Sessions: formatInt(r.sessions),
          Transactions: formatInt(r.transactions),
          CR: formatPercent(r.cr),
          AOV: formatCurrency(r.aov),
        })),
      );
    
      const header = `**Grips device mix — ${args.domains.join(", ")} (${country}, ${args.date_from} → ${args.date_to})**`;
      return truncateIfNeeded(`${header}\n\n${table}`);
    }
  • Input schema definition `baseFilterFields` shared by all tools, including grips_get_devices. Defines domains, date_from, date_to, country, and format fields.
    export const baseFilterFields = {
      domains: domainsArray.describe(
        "One or more domains (e.g. ['adidas.com', 'nike.com']). Protocol and trailing slash are stripped automatically.",
      ),
      date_from: isoDate.describe(
        "Start of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-01-01'.",
      ),
      date_to: isoDate.describe(
        "End of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-12-31'.",
      ),
      country: countryEnum
        .optional()
        .describe("Optional country filter. Defaults to the server's GRIPS_DEFAULT_COUNTRY (usually 'US')."),
      format: outputFormat,
    };
  • Type definition `DeviceMetrics` for per-device metrics (sessions, transactions, CR, AOV, revenue).
    export interface DeviceMetrics {
      sessions?: number | string | null;
      transactions?: number | string | null;
      cr?: number | string | null;
      aov?: number | string | null;
      transactionrevenue?: number | string | null;
    }
  • src/index.ts:114-123 (registration)
    Registration of the grips_get_devices tool using `server.registerTool()` with devicesToolDef.name, schema, and handler.
    server.registerTool(
      devicesToolDef.name,
      {
        title: devicesToolDef.title,
        description: devicesToolDef.description,
        inputSchema: devicesToolDef.inputSchema,
        annotations: devicesToolDef.annotations,
      },
      async (args) => asText(await runDevices(client, args as any, defaultCountry)),
    );
  • Tool definition object `devicesToolDef` with name 'grips_get_devices', title, description, inputSchema, and annotations.
    export const devicesToolDef = {
      name: "grips_get_devices",
      title: "Get device mix (mobile / desktop / tablet)",
      description:
        "Returns device-level revenue, sessions, transactions, CR, and AOV for one or more domains aggregated over a date window. Use this to understand where a competitor's traffic and conversions come from — mobile vs desktop split, AOV by device, etc.",
      inputSchema: baseFilterFields,
      annotations: {
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
    };
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description adds specific metrics returned (revenue, sessions, etc.) and the aggregation over a date window, which extends beyond the annotations.

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 sentences with no wasted words. The first sentence states functionality, the second provides usage context.

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?

The tool lacks an output schema, but the description lists the key metrics. No mention of pagination or date range limits, but overall it is sufficiently complete for a read-only data retrieval 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 coverage is 100% with descriptions for all 5 parameters. The description does not add new parameter details beyond the schema, so it meets the baseline.

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 it returns device-level metrics (revenue, sessions, transactions, CR, AOV) for domains over a date window, and explicitly says 'Use this to understand where a competitor's traffic and conversions come from', which distinguishes it from siblings like grips_get_domain_performance.

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 provides clear when-to-use guidance ('Use this to understand where a competitor's traffic...') but does not explicitly mention when not to use or list 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/alloufj/grips-mcp-server'

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