Skip to main content
Glama
palhamel

46elks MCP Server

by palhamel

get_delivery_statistics

Analyze SMS delivery statistics and success rates from recent messages to monitor message performance and delivery outcomes.

Instructions

Get SMS delivery statistics and success rates from recent messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of recent messages to analyze for statistics (default: 50, max: 100)

Implementation Reference

  • Executes the get_delivery_statistics tool by fetching recent outbound messages and formatting delivery statistics.
    case 'get_delivery_statistics':
      const { limit: statsLimit = 50 } = args as {
        limit?: number;
      };
    
      // Validate and constrain limit
      const analysisLimit = Math.min(Math.max(statsLimit, 10), 100);
      
      // Get messages for analysis - only outbound messages matter for delivery stats
      const elksClientForStats = new ElksClient();
      const messagesForStats = await elksClientForStats.getMessages(analysisLimit);
      
      return {
        content: [
          {
            type: 'text',
            text: formatDeliveryStatistics(messagesForStats)
          }
        ]
      };
  • src/index.ts:131-146 (registration)
    Registers the get_delivery_statistics tool with the MCP server, including input schema definition.
    {
      name: 'get_delivery_statistics',
      description: 'Get SMS delivery statistics and success rates from recent messages',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: 'number',
            description: 'Number of recent messages to analyze for statistics (default: 50, max: 100)',
            minimum: 10,
            maximum: 100
          }
        },
        required: []
      }
    }
  • Core utility function that analyzes outbound messages to compute delivery success rates, total/average costs, status breakdowns, and provides performance recommendations.
    export const formatDeliveryStatistics = (messages: ElksMessage[]): string => {
      if (messages.length === 0) {
        return 'šŸ“Š No messages found to analyze';
      }
    
      // Filter only outbound messages (we can't analyze delivery for inbound)
      const outboundMessages = messages.filter(msg => msg.direction === 'outbound');
      
      if (outboundMessages.length === 0) {
        return 'šŸ“Š No outbound messages found to analyze delivery statistics';
      }
    
      // Count messages by status
      const statusCounts = outboundMessages.reduce((counts, msg) => {
        counts[msg.status] = (counts[msg.status] || 0) + 1;
        return counts;
      }, {} as Record<string, number>);
    
      // Calculate costs
      const totalCost = outboundMessages
        .filter(msg => msg.cost)
        .reduce((sum, msg) => sum + (msg.cost || 0), 0) / 10000;
    
      const averageCost = totalCost / Math.max(outboundMessages.filter(msg => msg.cost).length, 1);
    
      // Calculate success rate
      const deliveredCount = statusCounts.delivered || 0;
      const sentCount = statusCounts.sent || 0;
      const successfulMessages = deliveredCount + sentCount;
      const successRate = Math.round((successfulMessages / outboundMessages.length) * 100);
    
      // Build statistics output
      let output = `šŸ“Š SMS Delivery Statistics\n\n`;
      output += `šŸ“ˆ Summary (Last ${outboundMessages.length} outbound messages)\n`;
      output += `Success Rate: ${successRate}% (${successfulMessages}/${outboundMessages.length})\n`;
      output += `Total Cost: ${totalCost.toFixed(2)} SEK\n`;
      output += `Average Cost: ${averageCost.toFixed(2)} SEK per SMS\n\n`;
    
      output += `šŸ“‹ Message Status Breakdown:\n`;
      Object.entries(statusCounts).forEach(([status, count]) => {
        const percentage = Math.round((count / outboundMessages.length) * 100);
        const statusEmoji = getStatusEmoji(status);
        output += `${statusEmoji} ${status}: ${count} (${percentage}%)\n`;
      });
    
      output += `\nšŸ“… Analysis Period: ${new Date(outboundMessages[outboundMessages.length - 1].created).toLocaleDateString()} - ${new Date(outboundMessages[0].created).toLocaleDateString()}`;
    
      // Add recommendations
      if (successRate < 90) {
        output += `\n\nāš ļø  Low success rate detected. Consider:\n`;
        output += `• Verifying phone number formats\n`;
        output += `• Checking message content for blocked words\n`;
        output += `• Ensuring recipient numbers are active`;
      } else {
        output += `\n\nāœ… Good delivery performance!`;
      }
    
      return output;
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves statistics, implying a read-only operation, but doesn't cover aspects like authentication requirements, rate limits, data freshness, or what 'recent messages' entails. This leaves significant gaps in understanding the tool's behavior.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized for its function, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete. It doesn't explain what statistics are returned (e.g., success rates, delivery times), how data is formatted, or any error conditions. For a tool with one parameter but missing structured context, more detail is needed to fully guide the agent.

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?

The input schema has 100% description coverage, with the 'limit' parameter well-documented. The description adds no additional parameter details beyond what the schema provides, such as clarifying 'recent messages' or statistical metrics. This meets the baseline for high schema coverage.

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

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('SMS delivery statistics and success rates from recent messages'), making the tool's purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'check_sms_status' or 'get_sms_messages', which might also involve SMS message data, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'check_sms_status' or 'get_sms_messages'. It lacks context on prerequisites, such as needing recent messages or specific account permissions, leaving the agent with minimal usage direction.

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/palhamel/46elks-mcp-server'

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