Skip to main content
Glama

get_business_metrics

Retrieve high-level business metrics like Revenue, Conversion, and Customers from the Semantic Layer. Specify time windows to analyze performance data.

Instructions

Retrieve high-level business metrics (Revenue, Conversion, Customers) from the Semantic Layer.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
windowNoAnalytics window (today, 7d, 30d, all)

Implementation Reference

  • The handler function `getBusinessMetrics` that aggregates data from billing, telemetry, and feedback to calculate metrics.
    async function getBusinessMetrics(options = {}) {
      const window = resolveAnalyticsWindow(options);
      const billing = getBillingSummary(window);
      const { getFeedbackPaths } = require('./feedback-loop');
      const feedbackDir = options.feedbackDir || getFeedbackPaths().FEEDBACK_DIR;
      const telemetry = getTelemetryAnalytics(feedbackDir, window);
    
      const uniqueVisitors = telemetry.visitors.uniqueVisitors || 0;
      const paidCustomers = billing.revenue.paidCustomers || 0;
      const bookedRevenueCents = billing.revenue.bookedRevenueCents || 0;
    
      return {
        generatedAt: new Date().toISOString(),
        window: billing.window,
        metrics: {
          uniqueVisitors,
          checkoutStarts: telemetry.ctas.checkoutStarts || 0,
          acquisitionLeads: billing.signups.uniqueLeads || 0,
          paidCustomers,
          bookedRevenueCents,
          bookedRevenueFormatted: `$${(bookedRevenueCents / 100).toFixed(2)}`,
          conversionRate: safeRate(paidCustomers, uniqueVisitors),
          leadToPaidRate: safeRate(paidCustomers, billing.signups.uniqueLeads || 0),
          activeProKeys: billing.keys.active || 0,
          totalUsage: billing.keys.totalUsage || 0,
        },
        attribution: billing.attribution,
        status: {
          isPostFirstDollar: paidCustomers > 0 || bookedRevenueCents > 0,
          hasActivePipeline: (telemetry.ctas.checkoutStarts || 0) > 0 || billing.signups.uniqueLeads > 0,
        }
      };
    }
  • Registration of the `get_business_metrics` tool in the tool registry.
    readOnlyTool({
      name: 'get_business_metrics',
      description: 'Retrieve high-level business metrics (Revenue, Conversion, Customers) from the Semantic Layer.',
      inputSchema: {
        type: 'object',
        properties: {
          window: { type: 'string', description: 'Analytics window (today, 7d, 30d, all)' },
  • MCP server-stdio handler dispatching the `get_business_metrics` request to the semantic layer.
    case 'get_business_metrics': {
      const { getBusinessMetrics } = require('../../scripts/semantic-layer');
      const metrics = await getBusinessMetrics(args);
      return toTextResult(metrics);

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/IgorGanapolsky/mcp-memory-gateway'

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