Skip to main content
Glama
ycyun

ABLESTACK MOLD MCP Server

by ycyun

mold_call

Execute MOLD API commands with specified parameters to manage cloud infrastructure through the ABLESTACK MCP Server.

Instructions

임의의 MOLD API 명령을 호출합니다. (command + params)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
paramsNo

Implementation Reference

  • The handler function for the 'mold_call' tool. It flattens the input parameters and calls the generic callApi function to execute the MOLD API request, returning the JSON response as text.
    async ({ command, params }) => {
      const flat = flattenParamsForMold(params ?? {});
      const data = await callApi(command, flat);
      return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
    }
  • Zod input schema for the 'mold_call' tool, defining 'command' as string and optional 'params' as record of string keys to union of primitives or nested records.
    inputSchema: {
      command: z.string(),
      params: z
        .record(
          z.string(),
          z.union([
            z.string(),
            z.number(),
            z.boolean(),
            z.record(
              z.string(),
              z.union([
                z.string(),
                z.number(),
                z.boolean(),
                z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])),
              ])
            ),
          ])
        )
        .optional(),
    },
  • src/app/tools.js:45-78 (registration)
    Full registration of the 'mold_call' tool in registerCoreTools, specifying name, metadata, input schema, and handler function.
    server.registerTool(
      "mold_call",
      {
        title: "MOLD API 호출(범용)",
        description: "임의의 MOLD API 명령을 호출합니다. (command + params)",
        inputSchema: {
          command: z.string(),
          params: z
            .record(
              z.string(),
              z.union([
                z.string(),
                z.number(),
                z.boolean(),
                z.record(
                  z.string(),
                  z.union([
                    z.string(),
                    z.number(),
                    z.boolean(),
                    z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])),
                  ])
                ),
              ])
            )
            .optional(),
        },
      },
      async ({ command, params }) => {
        const flat = flattenParamsForMold(params ?? {});
        const data = await callApi(command, flat);
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Core helper function called by the handler to perform the actual signed API request to MOLD using fetch.
    export async function callApi(command, params = {}) {
      const url = buildSignedUrl({ command, ...params });
      const res = await fetch(url);
      if (!res.ok) {
        const text = await res.text();
        throw new Error(`HTTP ${res.status}: ${text} from: ${url} and params: ${JSON.stringify(params, null, 2)}`);
      }
      return res.json();
    }
  • Helper function to flatten nested parameters into flat object with bracket and dot notation suitable for MOLD API.
    export function flattenParamsForMold(params = {}) {
      const out = {};
    
      const put = (k, v) => {
        if (v === undefined || v === null) return;
        out[k] = String(v);
      };
    
      const walkNested = (val, base) => {
        if (val === undefined || val === null) return;
        if (Array.isArray(val)) {
          if (val.length && typeof val[0] === "object") {
            val.forEach((item, i) => walkNested(item, `${base}[${i}]`));
          } else {
            put(base, val.map((x) => String(x)).join(","));
          }
          return;
        }
        if (typeof val === "object") {
          for (const [sk, sv] of Object.entries(val)) {
            if (sv === undefined || sv === null) continue;
            if (typeof sv === "object" && !Array.isArray(sv)) {
              walkNested(sv, `${base}.${sk}`);
            } else {
              put(`${base}.${sk}`, sv);
            }
          }
          return;
        }
        put(base, val);
      };
    
      for (const [key, val] of Object.entries(params)) {
        if (val === undefined || val === null) continue;
        if (/[.\[]/.test(key)) {
          put(key, val);
          continue;
        }
        if (Array.isArray(val)) {
          if (val.length && typeof val[0] === "object") {
            val.forEach((item, i) => {
              for (const [sk, sv] of Object.entries(item || {})) {
                if (sv === undefined || sv === null) continue;
                if (typeof sv === "object" && !Array.isArray(sv)) {
                  walkNested(sv, `${key}[${i}].${sk}`);
                } else {
                  put(`${key}[${i}].${sk}`, sv);
                }
              }
            });
          } else {
            put(key, val.map((x) => String(x)).join(","));
          }
          continue;
        }
        if (typeof val === "object") {
          for (const [sk, sv] of Object.entries(val)) {
            if (sv === undefined || sv === null) continue;
            if (typeof sv === "object" && !Array.isArray(sv)) {
              walkNested(sv, `${key}[0].${sk}`);
            } else {
              put(`${key}[0].${sk}`, sv);
            }
          }
          continue;
        }
        put(key, val);
      }
      return out;
    }

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/ycyun/ablestack-MCP-server'

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