Skip to main content
Glama
ycyun

ABLESTACK MOLD MCP Server

by ycyun

MOLD 모든 API 동적 등록

mold_autoRegisterApis

Automatically registers multiple MCP tools by scanning available APIs with regex-based filtering. This tool simplifies API integration by batch-processing API endpoints for cloud infrastructure management.

Instructions

listApis를 기반으로 MCP 도구를 일괄 등록합니다. include/exclude는 정규식.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeNo
excludeNo
limitNo
namespaceNo

Implementation Reference

  • Registers the 'mold_autoRegisterApis' MCP tool with input schema and a thin handler that delegates to autoRegisterApis from discovery.js.
    server.registerTool(
      "mold_autoRegisterApis",
      {
        title: "MOLD 모든 API 동적 등록",
        description: "listApis를 기반으로 MCP 도구를 일괄 등록합니다. include/exclude는 정규식.",
        inputSchema: {
          include: z.string().optional(),
          exclude: z.string().optional(),
          limit: z.number().int().optional(),
          namespace: z.string().optional(),
        },
      },
      async ({ include, exclude, limit, namespace }) => {
        const result = await autoRegisterApis(server, { include, exclude, limit, namespace });
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
      }
    );
  • Core handler logic: fetches API metadata, filters by include/exclude/limit, and registers individual tools for each matching API using registerToolForApi.
    export async function autoRegisterApis(server, { include, exclude, limit, namespace } = {}) {
      const all = await fetchApisMeta();
      const inc = include ? new RegExp(include, "i") : null;
      const exc = exclude ? new RegExp(exclude, "i") : null;
    
      const filtered = all.filter((a) => {
        if (inc && !inc.test(a.name)) return false;
        if (exc && exc.test(a.name)) return false;
        return true;
      });
    
      const slice = typeof limit === "number" ? filtered.slice(0, limit) : filtered;
      let count = 0;
      for (const meta of slice) {
        if (registerToolForApi(server, meta, { namespace })) count++;
      }
      return { total: slice.length, registered: count, namespace: namespace || "mold_" };
    }
  • Helper that dynamically registers a single MCP tool for a given MOLD API, including schema generation and async job handling.
    export function registerToolForApi(server, apiMeta, { namespace = "mold_" } = {}) {
      const rawName = `${namespace}${apiMeta.name}`;
      const toolName = sanitizeToolName(rawName);
      if (server.hasTool && server.hasTool(toolName)) return false;
    
      const inputSchema = buildInputSchemaFromParams(apiMeta.params, { isasync: apiMeta.isasync });
      const title = `${apiMeta.name}${apiMeta.isasync ? " (async)" : ""}`;
      const description = (apiMeta.description || "").trim() || `Invoke ${apiMeta.name}`;
    
      server.registerTool(
        toolName,
        { title, description, inputSchema },
        async (args = {}) => {
          const { _wait, _timeoutMs, _intervalMs, ...apiArgs } = args || {};
          const params = {};
          Object.keys(apiArgs).forEach((k) => {
            const v = apiArgs[k];
            if (v !== undefined) params[k] = normalizeParamValue(v);
          });
          const flat = flattenParamsForMold(apiArgs);
          const data = await callApi(apiMeta.name, flat);
    
          if (apiMeta.isasync && (_wait === true || _wait === "true")) {
            const resp = data[`${apiMeta.name.toLowerCase()}response`] || data;
            const jobid = resp.jobid || resp.jobId || data.jobid || data.jobId;
            if (!jobid) return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
    
            const timeoutMs = Number(_timeoutMs || 60000);
            const intervalMs = Number(_intervalMs || 2000);
            const start = Date.now();
            while (true) {
              const jr = await callApi("queryAsyncJobResult", { jobid });
              const jresp = jr.queryasyncjobresultresponse || jr.queryAsyncJobResultResponse || jr;
              const status = jresp.jobstatus;
              if (status === 1 || status === 2) {
                return { content: [{ type: "text", text: JSON.stringify(jr, null, 2) }] };
              }
              if (Date.now() - start > timeoutMs) {
                throw new Error(`timeout waiting job ${jobid} after ${timeoutMs}ms`);
              }
              await new Promise((r) => setTimeout(r, intervalMs));
            }
          }
          return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
        }
      );
      return true;
    }
  • Helper to fetch and parse listApis metadata from MOLD server.
    export async function fetchApisMeta({ name } = {}) {
      const data = await callApi("listApis", name ? { name } : {});
      const resp = data.listapisresponse || data.listApisResponse || data.listapis || data;
      const apis = resp.api || resp.apis || resp;
      if (!apis || !Array.isArray(apis)) {
        throw new Error("listApis 응답을 파싱할 수 없습니다. (api 배열 없음)");
      }
      return apis.map((a) => ({
        name: a.name,
        description: a.description,
        isasync: !!a.isasync,
        since: a.since,
        related: a.related,
        params: Array.isArray(a.params)
          ? a.params.map((p) => ({
              name: p.name,
              type: p.type,
              required: !!p.required,
              description: p.description,
              length: p.length,
            }))
          : [],
      }));
    }
  • Helper to build Zod input schema for a tool based on API param metadata.
    export function buildInputSchemaFromParams(paramsMeta, { isasync }) {
      const schema = {};
      for (const p of paramsMeta) {
        const key = p.name;
        const ztype = mapTypeToZod(p.type);
        schema[key] = ztype;
      }
      if (isasync) {
        schema["_wait"] = z.union([z.boolean(), z.string()]).optional();
        schema["_timeoutMs"] = z.union([z.number(), z.string()]).optional();
        schema["_intervalMs"] = z.union([z.number(), z.string()]).optional();
      }
      return schema;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'bulk registration' but doesn't specify what happens during registration (e.g., whether it overwrites existing tools, requires authentication, has side effects, or handles errors). The regex mention for include/exclude is a minor behavioral detail, but overall, critical traits like mutation impact and operational context are missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two concise sentences that are front-loaded with the main action. There's no unnecessary fluff, and each sentence contributes directly to the tool's functionality, making it efficient in structure.

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?

Given the complexity of a bulk registration tool with 4 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on what the tool returns, how errors are handled, and the full scope of parameters, making it inadequate for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for all 4 parameters. It only mentions include/exclude as regex patterns, leaving limit and namespace completely undocumented. This adds minimal meaning beyond the schema, failing to adequately explain parameter purposes or usage.

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 'registers MCP tools in bulk based on listApis' which provides a general purpose, but it's vague about what 'MCP tools' specifically refers to and how the registration works. It doesn't clearly distinguish this from sibling tools like mold_listApisMeta or mold_getConfig that might involve API listing or configuration.

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?

No guidance is provided on when to use this tool versus alternatives. It mentions 'based on listApis' but doesn't explain if this should be used instead of manually registering APIs or in what scenarios bulk registration is preferred over individual calls. There's no mention of prerequisites or exclusions.

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

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