sleep
Pause task execution for a specified duration to control workflow timing. Introduces timed delays for managing sequences in automation, ensuring tasks proceed as planned after waiting periods.
Instructions
If you need to wait for a few seconds to continue with the task you are performing .
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seconds | Yes | seconds it will take me to tell you to continue. |
Implementation Reference
- src/mcp_sleep/server.py:75-108 (handler)The main handler function for MCP tool calls, specifically executes the 'sleep' tool by validating input, respecting config timeout, calling SleepFetcher.wait(), and returning success message.@app.call_tool() async def call_tool(name: str, arguments: Any) -> Sequence[TextContent]: """Handle tool calls for Sleep.""" ctx = app.request_context.lifespan_context try: if name == "sleep": if not ctx: raise ValueError("Sleep is not configured.") seconds = arguments.get("seconds") if not seconds: raise ValueError("Seconds is required.") if seconds > int(ctx.sleep.config.timeout): return [ TextContent( type="text", text=f"My configuration does not allow me to make you wait more than {ctx.sleep.config.timeout} seconds", # noqa: E501 ) ] # Sleep seconds value await ctx.sleep.wait(seconds) return [ TextContent( type="text", text=f"You can continue to do your task after you've been waiting {seconds} seconds", # noqa: E501 ) ] raise ValueError(f"Unknown tool: {name}") except Exception as e: logger.error(f"Tool execution error: {str(e)}") return [TextContent(type="text", text=f"Error: {str(e)}")]
- src/mcp_sleep/server.py:44-72 (registration)Registers the 'sleep' tool by providing its schema and description in the list_tools handler.@app.list_tools() async def list_tools() -> list[Tool]: """List available Sleep tools.""" tools = [] ctx = app.request_context.lifespan_context # Add Sleep tools if Sleep is configured if ctx: tools.extend( [ Tool( name="sleep", description="If you need to wait for a few seconds to continue with the task you are performing .", # noqa: E501 inputSchema={ "type": "object", "properties": { "seconds": { "type": "number", "minimum": 0, "maximum": ctx.sleep.config.timeout, "description": "seconds it will take me to tell you to continue." # noqa: E501 } }, "required": ["seconds"], }, ), ] ) return tools
- src/mcp_sleep/server.py:54-70 (schema)Defines the input schema for the 'sleep' tool, including seconds parameter with min/max bounds from config.Tool( name="sleep", description="If you need to wait for a few seconds to continue with the task you are performing .", # noqa: E501 inputSchema={ "type": "object", "properties": { "seconds": { "type": "number", "minimum": 0, "maximum": ctx.sleep.config.timeout, "description": "seconds it will take me to tell you to continue." # noqa: E501 } }, "required": ["seconds"], }, ), ]
- src/mcp_sleep/sleep/wait.py:11-23 (helper)Helper class providing the wait method that executes asyncio.sleep(seconds), the core sleep logic.class WaitMixin(SleepClient): """Mixin for Sleep waits operations.""" async def wait(self, seconds: int) -> None: """ Get an aggregated overview of findings and resources grouped by providers. Returns: Dictionary containing provider information with results and metadata """ # noqa: E501 await asyncio.sleep(seconds) return
- The SleepFetcher class that inherits WaitMixin, used by the server to perform the sleep operation.class SleepFetcher(WaitMixin): """Main entry point for Sleep operations, providing backward compatibility. This class combines functionality from various mixins to maintain the same API as the original SleepFetcher class. """ pass __all__ = ["SleepFetcher","SleepConfig", "SleepClient"]