mold_waitForJob
Waits for an async job to complete or fail by periodically polling queryAsyncJobResult until the job finishes.
Instructions
queryAsyncJobResult를 주기적으로 호출하여 완료(1)/실패(2)까지 대기.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobid | Yes | ||
| timeoutMs | No | ||
| intervalMs | No |
Implementation Reference
- src/app/tools.js:157-169 (handler)Handler function that polls the asynchronous job status using queryAsyncJobResult until it completes (status 1) or fails (status 2), with configurable timeout and polling interval.async ({ jobid, timeoutMs = 60000, intervalMs = 2000 }) => { const start = Date.now(); while (true) { const data = await callApi("queryAsyncJobResult", { jobid }); const resp = data.queryasyncjobresultresponse ?? data.queryasyncjobresult ?? data; const status = resp.jobstatus; if (status === 1 || status === 2) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } if (Date.now() - start > timeoutMs) throw new Error(`timeout after ${timeoutMs}ms`); await new Promise((r) => setTimeout(r, intervalMs)); } }
- src/app/tools.js:146-170 (registration)Registration of the mold_waitForJob tool within the registerCoreTools function, including title, description, input schema, and inline handler.server.registerTool( "mold_waitForJob", { title: "비동기 잡 완료 대기", description: "queryAsyncJobResult를 주기적으로 호출하여 완료(1)/실패(2)까지 대기.", inputSchema: { jobid: z.string(), timeoutMs: z.number().int().optional(), intervalMs: z.number().int().optional(), }, }, async ({ jobid, timeoutMs = 60000, intervalMs = 2000 }) => { const start = Date.now(); while (true) { const data = await callApi("queryAsyncJobResult", { jobid }); const resp = data.queryasyncjobresultresponse ?? data.queryasyncjobresult ?? data; const status = resp.jobstatus; if (status === 1 || status === 2) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } if (Date.now() - start > timeoutMs) throw new Error(`timeout after ${timeoutMs}ms`); await new Promise((r) => setTimeout(r, intervalMs)); } } );
- src/app/tools.js:151-155 (schema)Zod input schema defining jobid (required string), timeoutMs and intervalMs (optional integers).inputSchema: { jobid: z.string(), timeoutMs: z.number().int().optional(), intervalMs: z.number().int().optional(), },