Skip to main content
Glama
gcorroto

Asterisk S2S MCP Server

by gcorroto

phone_get_metrics

Retrieve system metrics and statistics for automated phone call operations within the Asterisk S2S MCP Server to monitor and analyze telephony performance.

Instructions

Obtener métricas y estadísticas del sistema telefónico

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • index.ts:98-112 (registration)
    Registers the 'phone_get_metrics' MCP tool with empty input schema and an inline handler that fetches metrics via phoneTools.getCallMetrics() and returns formatted text output.
    server.tool(
      "phone_get_metrics",
      "Obtener métricas y estadísticas del sistema telefónico",
      {},
      async () => {
        const result = await phoneTools.getCallMetrics();
    
        return {
          content: [{ 
            type: "text", 
            text: `📊 **Métricas del Sistema Telefónico**\n\n**Total de llamadas:** ${result.totalCalls}\n**Llamadas exitosas:** ${result.successfulCalls}\n**Llamadas fallidas:** ${result.failedCalls}\n**Tasa de éxito:** ${result.successRate}%\n**Duración promedio:** ${Math.round(result.averageDuration)} segundos\n\n**Top propósitos:**\n${result.topPurposes.map(p => `- ${p.proposito}: ${p.count} llamadas`).join('\n')}`
          }],
        };
      }
    );
  • Core implementation of getCallMetrics(): computes comprehensive phone call metrics from in-memory activeCalls and conversationHistory, including totals, success/failure counts, average duration, daily stats, and top purposes.
    export function getCallMetrics(): CallMetrics {
      const now = new Date();
      const calls = Array.from(activeCalls.values()).concat(
        conversationHistory.map(h => ({
          callId: h.callId,
          status: 'completed' as const,
          lastUpdate: now.toISOString(),
          usuario: '',
          telefono: '',
          proposito: ''
        }))
      );
      
      const totalCalls = calls.length;
      const successfulCalls = calls.filter(c => c.status === 'completed').length;
      const failedCalls = calls.filter(c => c.status === 'failed').length;
      
      const durations = calls.filter(c => c.duration).map(c => c.duration!);
      const averageDuration = durations.length > 0 
        ? durations.reduce((a, b) => a + b, 0) / durations.length 
        : 0;
      
      const callsByStatus = calls.reduce((acc, call) => {
        acc[call.status] = (acc[call.status] || 0) + 1;
        return acc;
      }, {} as Record<CallStatus['status'], number>);
      
      // Stats diarias (últimos 7 días)
      const dailyStats = [];
      for (let i = 6; i >= 0; i--) {
        const date = new Date(now);
        date.setDate(date.getDate() - i);
        const dateStr = date.toISOString().split('T')[0];
        
        const dayCalls = calls.filter(c => 
          c.lastUpdate.startsWith(dateStr)
        );
        
        const dayDurations = dayCalls.filter(c => c.duration).map(c => c.duration!);
        const dayAvgDuration = dayDurations.length > 0 
          ? dayDurations.reduce((a, b) => a + b, 0) / dayDurations.length 
          : 0;
        
        dailyStats.push({
          date: dateStr,
          calls: dayCalls.length,
          successRate: dayCalls.length > 0 
            ? dayCalls.filter(c => c.status === 'completed').length / dayCalls.length * 100 
            : 0,
          averageDuration: dayAvgDuration
        });
      }
      
      // Top propósitos
      const purposeCounts: Record<string, number> = {};
      calls.forEach(call => {
        if (call.proposito) {
          purposeCounts[call.proposito] = (purposeCounts[call.proposito] || 0) + 1;
        }
      });
      
      const topPurposes = Object.entries(purposeCounts)
        .map(([proposito, count]) => ({ proposito, count }))
        .sort((a, b) => b.count - a.count)
        .slice(0, 5);
      
      return {
        totalCalls,
        successfulCalls,
        failedCalls,
        averageDuration,
        callsByStatus,
        dailyStats,
        topPurposes
      };
    }
  • Helper wrapper getCallMetrics() that invokes the operations-level getCallMetrics() and adds successRate calculation to the returned metrics.
    export async function getCallMetrics(): Promise<{
      totalCalls: number;
      successfulCalls: number;
      failedCalls: number;
      averageDuration: number;
      successRate: number;
      dailyStats: Array<{
        date: string;
        calls: number;
        successRate: number;
        averageDuration: number;
      }>;
      topPurposes: Array<{
        proposito: string;
        count: number;
      }>;
    }> {
      const metrics = phoneOps.getCallMetrics();
      
      const successRate = metrics.totalCalls > 0 
        ? (metrics.successfulCalls / metrics.totalCalls) * 100 
        : 0;
    
      return {
        ...metrics,
        successRate: Math.round(successRate * 100) / 100
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Obtener' implies a read-only operation, it doesn't specify whether authentication is required, if there are rate limits, what format the metrics are returned in, or if the data is real-time or historical. For a metrics tool with zero annotation coverage, this leaves significant gaps in understanding its 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 in Spanish that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, with every word contributing to understanding what the tool does.

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?

Given the tool's simplicity (0 parameters, no output schema), the description is adequate but not complete. It clearly states what the tool retrieves but lacks context about the metrics' scope, format, or behavioral traits. Without annotations or output schema, the agent doesn't know what to expect from the response. The description meets minimum viability but has clear gaps.

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 tool has 0 parameters, and schema description coverage is 100% (since there are no parameters to describe). The description doesn't need to add parameter semantics beyond what the schema provides. A baseline of 4 is appropriate for a zero-parameter tool where the schema fully covers the input structure.

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 'Obtener métricas y estadísticas del sistema telefónico' clearly states the tool's purpose: to retrieve metrics and statistics from the phone system. It uses specific verbs ('Obtener') and identifies the resource ('sistema telefónico'). However, it doesn't explicitly differentiate from siblings like phone_get_status or phone_get_logs, which likely provide different types of phone system information.

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. It doesn't mention what distinguishes it from sibling tools like phone_get_status or phone_get_logs, nor does it specify prerequisites, appropriate contexts, or exclusions. The agent must infer usage from the tool name alone.

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

Related 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/gcorroto/mcp-s2s-asterisk'

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