wait
Pause execution for a specified duration (0-300 seconds) to synchronize tasks, ensuring dependent processes complete before proceeding. Ideal for task orchestration and workflow management.
Instructions
Wait for a specified number of seconds, useful for waiting for other tasks to finish
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seconds | Yes | The number of seconds to wait (0-300) |
Implementation Reference
- src/index.ts:27-45 (handler)The execute handler for the 'wait' tool, which waits for the specified seconds, reports progress every 10%, and returns a success message.execute: async (args, { reportProgress }) => { const { seconds } = args; const ms = seconds * 1000; console.log(`Waiting for ${seconds} seconds...`); // Report progress in 10% increments const interval = ms / 10; for (let i = 0; i < 10; i++) { await sleep(interval); reportProgress({ progress: (i + 1) * 10, total: 100, }); } return `Waited for ${seconds} seconds successfully.`; },
- src/index.ts:24-26 (schema)Zod schema defining the input parameters for the 'wait' tool: seconds (number, 0-30000).parameters: z.object({ seconds: z.number().min(0).max(30000).describe("The number of seconds to wait (0-30000)"), }),
- src/index.ts:21-46 (registration)Registration of the 'wait' tool using server.addTool, including name, description, schema, and handler.server.addTool({ name: "wait", description: "Wait for a specified number of seconds, useful for waiting for other tasks to finish", parameters: z.object({ seconds: z.number().min(0).max(30000).describe("The number of seconds to wait (0-30000)"), }), execute: async (args, { reportProgress }) => { const { seconds } = args; const ms = seconds * 1000; console.log(`Waiting for ${seconds} seconds...`); // Report progress in 10% increments const interval = ms / 10; for (let i = 0; i < 10; i++) { await sleep(interval); reportProgress({ progress: (i + 1) * 10, total: 100, }); } return `Waited for ${seconds} seconds successfully.`; }, });
- src/index.ts:16-18 (helper)Helper sleep function used by the wait handler to pause execution.function sleep(ms: number): Promise<void> { return new Promise(resolve => setTimeout(resolve, ms)); }