mold_signDebug
Debug and validate API signatures by generating normalized strings, Base64 signatures, URL-encoded signatures, and final request URLs for ABLESTACK MOLD MCP Server API calls.
Instructions
정규화 문자열, 서명(Base64), URL 인코딩 서명, 최종 요청 URL을 생성해 점검합니다.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | ||
| params | No | ||
| includeResponse | No | ||
| apiKeyField | No |
Implementation Reference
- src/app/tools.js:239-255 (registration)Registers the mold_signDebug MCP tool, defining its metadata, input schema using Zod, and a thin handler function that invokes buildSignedUrlDebug and formats the response.server.registerTool( "mold_signDebug", { title: "MOLD 서명/URL 디버그", description: "정규화 문자열, 서명(Base64), URL 인코딩 서명, 최종 요청 URL을 생성해 점검합니다.", inputSchema: { command: z.string(), params: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(), includeResponse: z.boolean().optional(), apiKeyField: z.enum(["apiKey", "apikey"]).optional(), }, }, async ({ command, params, includeResponse = true, apiKeyField = "apiKey" }) => { const dbg = buildSignedUrlDebug(command, params ?? {}, { includeResponse, apiKeyField }); return { content: [{ type: "text", text: JSON.stringify(dbg, null, 2) }] }; } );
- src/app/tools.js:251-254 (handler)The MCP tool handler function for mold_signDebug, which calls the helper and returns structured content.async ({ command, params, includeResponse = true, apiKeyField = "apiKey" }) => { const dbg = buildSignedUrlDebug(command, params ?? {}, { includeResponse, apiKeyField }); return { content: [{ type: "text", text: JSON.stringify(dbg, null, 2) }] }; }
- src/api/mold.js:49-88 (helper)Core helper function implementing the debug logic: normalizes parameters, computes HMAC signature, builds and encodes the final signed URL, returns debug info.export function buildSignedUrlDebug(command, params = {}, { includeResponse = true, apiKeyField = "apiKey" } = {}) { const cfg = getConfig(); if (!cfg.endpoint || !cfg.apiKey || !cfg.secret) { throw new Error( "MOLD 연결정보가 없습니다. mold_setConfig 도구로 endpoint/apiKey/secret 을 설정하세요." ); } const baseParams = { ...(includeResponse ? { response: "json" } : {}), ...params, command }; baseParams[apiKeyField] = cfg.apiKey; const normPairs = Object.keys(baseParams) .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())) .map((k) => { const v = baseParams[k]; const encV = encodeURIComponent(String(v)).replace(/\+/g, "%20"); return `${k.toLowerCase()}=${encV.toLowerCase()}`; }); const normalized = normPairs.join("&"); const signatureBase64 = hmac(cfg.algo, cfg.secret, normalized); const signatureUrlEncoded = encodeURIComponent(signatureBase64); const query = Object.entries(baseParams) .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`) .join("&"); const sep = cfg.endpoint.includes("?") ? "&" : "?"; const finalUrl = `${cfg.endpoint}${sep}${query}&signature=${signatureUrlEncoded}`; return { endpoint: cfg.endpoint, apiKeyFieldUsed: apiKeyField, includeResponse, normalized, signatureBase64, signatureUrlEncoded, finalUrl, signedParams: baseParams, }; }