Skip to main content
Glama

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
NameRequiredDescriptionDefault
secondsYesseconds it will take me to tell you to continue.

Implementation Reference

  • 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)}")]
  • 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
  • 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"],
            },
        ),
    ]
  • 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"]

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/AgentsWorkingTogether/mcp-sleep'

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