Skip to main content
Glama

get_power_stats

Retrieve power consumption statistics for Cisco C-Series rack servers, including voltage, current, consumed power, and power budget data.

Instructions

Detailed power consumption statistics: input voltage, current, consumed power, and power budget.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The getPowerStats async function is the handler that implements the tool logic. It queries three CIMC classes (computeMbPowerStats, equipmentPsu, powerBudget) using resolveClass and returns formatted JSON with power consumption statistics including motherboard power, power supplies, and power budget data.
    export async function getPowerStats(): Promise<string> {
      const mbPower = await resolveClass("computeMbPowerStats");
      const psus = await resolveClass("equipmentPsu");
      const budget = await resolveClass("powerBudget");
    
      return JSON.stringify(
        {
          motherboardPower: mbPower.map((p) => ({
            dn: p.dn,
            consumedPower: p.consumedPower,
            inputCurrent: p.inputCurrent,
            inputVoltage: p.inputVoltage,
          })),
          powerSupplies: psus.map((p) => ({
            dn: p.dn,
            id: p.id,
            power: p.power,
            voltage: p.voltage,
            thermal: p.thermal,
            operability: p.operability,
          })),
          powerBudget: budget.map((b) => ({
            dn: b.dn,
            powerConsumed: b.powerConsumed,
            powerAvailable: b.powerAvailable,
            powerCap: b.powerCap,
            powerCharacterization: b.powerCharacterization,
          })),
        },
        null,
        2,
      );
    }
  • The getPowerStatsDef object defines the tool's metadata: name 'get_power_stats', description about power consumption statistics, and an empty inputSchema (z.object({})) indicating the tool takes no parameters.
    export const getPowerStatsDef = {
      name: "get_power_stats",
      description:
        "Detailed power consumption statistics: input voltage, current, consumed power, and power budget.",
      inputSchema: z.object({}),
    };
  • src/index.ts:159-164 (registration)
    The tool is registered with the MCP server using server.tool(), passing the definition's name, description, inputSchema.shape, and wrapping the handler with error handling via wrapHandler(getPowerStats).
    server.tool(
      getPowerStatsDef.name,
      getPowerStatsDef.description,
      getPowerStatsDef.inputSchema.shape,
      wrapHandler(getPowerStats),
    );
  • The resolveClass helper function queries all objects of a given class from the CIMC API. It's used by getPowerStats to fetch computeMbPowerStats, equipmentPsu, and powerBudget data via authenticated XML requests.
    export async function resolveClass(
      classId: string,
      hierarchical = false,
    ): Promise<Record<string, string>[]> {
      const xml = `<configResolveClass cookie="{cookie}" inHierarchical="${hierarchical}" classId="${classId}"/>`;
      const result = await authenticatedRequest(xml);
      return extractOutConfigs(result, "configResolveClass");
    }

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/schwarztim/cimc-mcp'

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