Skip to main content
Glama

get_bios_settings

Retrieve current BIOS configuration values from Cisco C-Series servers to prepare for BIOS setting modifications.

Instructions

Get all current BIOS token values. Returns token names, class names, and current values needed for set_bios_setting.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The getBiosSettings async function that implements the tool logic. It queries BIOS settings via resolveDnRaw, parses the XML response, extracts token information (className, dn, attributes) and returns a JSON result with all BIOS tokens.
    export async function getBiosSettings(): Promise<string> {
      const result = await resolveDnRaw("sys/rack-unit-1/bios/bios-settings", true);
      const root = parseResponse(result, "configResolveDn");
      const outConfig = root.outConfig;
    
      if (!outConfig || typeof outConfig !== "object") {
        return JSON.stringify({ tokens: [], message: "No BIOS settings returned" });
      }
    
      // outConfig contains biosSettings which contains individual token classes
      const settings = (outConfig as Record<string, unknown>).biosSettings;
      if (!settings || typeof settings !== "object") {
        return JSON.stringify({ tokens: [], message: "No BIOS settings found" });
      }
    
      const tokens: Array<{
        className: string;
        dn: string;
        attributes: Record<string, string>;
      }> = [];
    
      const settingsObj = settings as Record<string, unknown>;
      for (const className of Object.keys(settingsObj)) {
        if (className === "dn" || className === "rn") continue;
    
        const value = settingsObj[className];
        if (value && typeof value === "object" && !Array.isArray(value)) {
          const attrs = value as Record<string, string>;
          tokens.push({
            className,
            dn: attrs.dn || "",
            attributes: attrs,
          });
        } else if (Array.isArray(value)) {
          for (const item of value) {
            if (item && typeof item === "object") {
              const attrs = item as Record<string, string>;
              tokens.push({
                className,
                dn: attrs.dn || "",
                attributes: attrs,
              });
            }
          }
        }
      }
    
      return JSON.stringify({ total: tokens.length, tokens }, null, 2);
    }
  • The getBiosSettingsDef object defines the tool's name, description, and inputSchema. The tool takes no input parameters (empty z.object) and is described as returning BIOS token values needed for set_bios_setting.
    export const getBiosSettingsDef = {
      name: "get_bios_settings",
      description:
        "Get all current BIOS token values. Returns token names, class names, and current values needed for set_bios_setting.",
      inputSchema: z.object({}),
    };
  • src/index.ts:117-122 (registration)
    Registration of the get_bios_settings tool with the MCP server. Uses server.tool() to register the name, description, inputSchema shape, and wraps the handler with error handling.
    server.tool(
      getBiosSettingsDef.name,
      getBiosSettingsDef.description,
      getBiosSettingsDef.inputSchema.shape,
      wrapHandler(getBiosSettings),
    );
  • The resolveDnRaw helper function used by getBiosSettings to query a DN with hierarchical children. It constructs and sends a configResolveDn XML request to the CIMC API.
    export async function resolveDnRaw(
      dn: string,
      hierarchical = true,
    ): Promise<Record<string, unknown>> {
      const xml = `<configResolveDn cookie="{cookie}" dn="${dn}" inHierarchical="${hierarchical}"/>`;
      return authenticatedRequest(xml);
    }
  • The parseResponse helper function used by getBiosSettings to validate and extract data from the XML response. It checks for errors and returns the root element from the parsed response.
    export function parseResponse(
      parsed: Record<string, unknown>,
      expectedRoot: string,
    ): Record<string, string> {
      const root = parsed[expectedRoot] as Record<string, string> | undefined;
      if (!root) {
        // Try to find any error in the response
        const keys = Object.keys(parsed);
        for (const key of keys) {
          const val = parsed[key] as Record<string, string>;
          if (val && typeof val === "object" && val.errorCode) {
            throw new Error(
              `CIMC error (${val.errorCode}): ${val.errorDescr || "Unknown error"}`,
            );
          }
        }
        throw new Error(
          `Unexpected CIMC response: missing <${expectedRoot}> element. Got keys: ${keys.join(", ")}`,
        );
      }
    
      if (root.errorCode && root.errorCode !== "0") {
        throw new Error(
          `CIMC error (${root.errorCode}): ${root.errorDescr || "Unknown error"}`,
        );
      }
    
      return root;
    }

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