Skip to main content
Glama
code-alchemist01

MCP Cloud Services Server

get_metrics

Retrieve performance metrics for cloud resources across AWS, Azure, and GCP to monitor system health and analyze operational data over specified time periods.

Instructions

Get metrics for a cloud resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerYesCloud provider
resourceIdYesResource ID
metricNameYesMetric name (e.g., CPUUtilization, NetworkIn)
startTimeYesStart time (ISO 8601)
endTimeYesEnd time (ISO 8601)
periodNoPeriod in seconds

Implementation Reference

  • Core handler function that retrieves metrics from AWS CloudWatch for the specified resource, metric, and time period, returning sorted Metric objects.
    async function getAWSMetrics(
      resourceId: string,
      metricName: string,
      startTime: string,
      endTime: string,
      period: number
    ): Promise<Metric[]> {
      try {
        const credentials = await credentialManager.getCredentials('aws');
        if (!credentials) {
          throw new Error('AWS credentials not found');
        }
    
        const client = new CloudWatchClient({
          region: credentials.region || 'us-east-1',
          credentials: credentials.accessKeyId && credentials.secretAccessKey
            ? {
                accessKeyId: credentials.accessKeyId,
                secretAccessKey: credentials.secretAccessKey,
              }
            : undefined,
        });
    
        // Determine namespace based on resource type
        let namespace = 'AWS/EC2';
        if (resourceId.includes('lambda')) {
          namespace = 'AWS/Lambda';
        } else if (resourceId.includes('rds')) {
          namespace = 'AWS/RDS';
        }
    
        const command = new GetMetricStatisticsCommand({
          Namespace: namespace,
          MetricName: metricName,
          Dimensions: [
            {
              Name: namespace === 'AWS/EC2' ? 'InstanceId' : 'FunctionName',
              Value: resourceId,
            },
          ],
          StartTime: new Date(startTime),
          EndTime: new Date(endTime),
          Period: period,
          Statistics: ['Average', 'Maximum', 'Minimum'],
        });
    
        const response = await client.send(command);
    
        const metrics: Metric[] = [];
        if (response.Datapoints) {
          for (const datapoint of response.Datapoints) {
            if (datapoint.Timestamp && datapoint.Average !== undefined) {
              metrics.push({
                name: metricName,
                value: datapoint.Average,
                unit: datapoint.Unit || 'Count',
                timestamp: datapoint.Timestamp,
              });
            }
          }
        }
    
        return metrics.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
      } catch (error) {
        throw new Error(`Failed to get AWS metrics: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema defining the parameters for the get_metrics tool, including provider, resource ID, metric name, time range, and optional period.
    inputSchema: {
      type: 'object',
      properties: {
        provider: {
          type: 'string',
          enum: ['aws', 'azure', 'gcp'],
          description: 'Cloud provider',
        },
        resourceId: {
          type: 'string',
          description: 'Resource ID',
        },
        metricName: {
          type: 'string',
          description: 'Metric name (e.g., CPUUtilization, NetworkIn)',
        },
        startTime: {
          type: 'string',
          description: 'Start time (ISO 8601)',
        },
        endTime: {
          type: 'string',
          description: 'End time (ISO 8601)',
        },
        period: {
          type: 'number',
          description: 'Period in seconds',
          default: 3600,
        },
      },
      required: ['provider', 'resourceId', 'metricName', 'startTime', 'endTime'],
    },
  • Tool registration object for 'get_metrics' included in the monitoringTools array.
    {
      name: 'get_metrics',
      description: 'Get metrics for a cloud resource',
      inputSchema: {
        type: 'object',
        properties: {
          provider: {
            type: 'string',
            enum: ['aws', 'azure', 'gcp'],
            description: 'Cloud provider',
          },
          resourceId: {
            type: 'string',
            description: 'Resource ID',
          },
          metricName: {
            type: 'string',
            description: 'Metric name (e.g., CPUUtilization, NetworkIn)',
          },
          startTime: {
            type: 'string',
            description: 'Start time (ISO 8601)',
          },
          endTime: {
            type: 'string',
            description: 'End time (ISO 8601)',
          },
          period: {
            type: 'number',
            description: 'Period in seconds',
            default: 3600,
          },
        },
        required: ['provider', 'resourceId', 'metricName', 'startTime', 'endTime'],
      },
    },
  • Dispatch handler within handleMonitoringTool that processes get_metrics requests and calls the AWS-specific implementation.
    case 'get_metrics': {
      const resourceId = params.resourceId as string;
      const metricName = params.metricName as string;
      const startTime = params.startTime as string;
      const endTime = params.endTime as string;
      const period = (params.period as number) || 3600;
    
      if (provider === 'aws') {
        return await getAWSMetrics(resourceId, metricName, startTime, endTime, period);
      }
      return { message: `Metrics not yet implemented for ${provider}` };
    }
  • src/server.ts:74-76 (registration)
    MCP server request handler routes tool calls matching monitoringTools (including get_metrics) to the appropriate handler.
    } else if (monitoringTools.some((t) => t.name === name)) {
      result = await handleMonitoringTool(name, args || {});
    } else if (securityTools.some((t) => t.name === name)) {
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Get metrics' implies a read operation, but the description doesn't specify whether this requires specific permissions, has rate limits, returns real-time vs. aggregated data, or what format the metrics come in. For a tool with 6 parameters and no annotation coverage, this is a significant gap in behavioral context.

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 states the core purpose without unnecessary words. It's appropriately sized for what it communicates, though what it communicates is limited. Every word earns its place, making it structurally sound despite content gaps.

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?

For a tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'metrics' means in this context, what format they return in, whether there are aggregation options, or how this differs from sibling monitoring tools. The agent would need to guess about the tool's behavior and output based solely on the parameter schema.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what's in the schema - it doesn't explain relationships between parameters (e.g., that provider determines resourceId format) or provide examples beyond what's in the schema's metricName description. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose3/5

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

The description states the tool's purpose as 'Get metrics for a cloud resource', which is clear but vague. It specifies the verb 'Get' and resource 'metrics', but doesn't distinguish it from siblings like 'get_resource_health' or 'list_alarms' that might also retrieve monitoring data. The purpose is understandable but lacks specificity about what types of metrics or granularity.

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. With siblings like 'get_resource_health', 'list_alarms', and various provider-specific listing tools, there's no indication whether this is for real-time metrics, historical data, or how it differs from other monitoring-related tools. 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

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/code-alchemist01/Cloud-mcp_server'

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