Skip to main content
Glama
Garoth

Sleep MCP Server

by Garoth

sleep

Pause operations for a specified duration in milliseconds. Use this tool to add delays between tasks, such as waiting between API calls or testing eventually consistent systems.

Instructions

Wait for a specified duration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
millisecondsYesDuration to wait in milliseconds

Implementation Reference

  • Core handler logic for the sleep tool: validates input milliseconds and performs the sleep using setTimeout.
    async sleep(ms: number): Promise<void> {
      if (isNaN(ms) || ms < 0) {
        throw new Error("milliseconds must be a non-negative number");
      }
      
      return new Promise(resolve => setTimeout(resolve, ms));
    }
  • MCP server handler for CallToolRequestSchema, specifically handles the 'sleep' tool by extracting milliseconds, calling the service, and returning success content.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== "sleep") {
        throw new McpError(ErrorCode.MethodNotFound, "Unknown tool");
      }
    
      try {
        const ms = Number(request.params.arguments?.milliseconds);
        await service.sleep(ms);
    
        return {
          content: [{
            type: "text",
            text: `Waited for ${ms} milliseconds`
          }]
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InvalidParams,
          error instanceof Error ? error.message : "Unknown error"
        );
      }
    });
  • Input schema definition for the sleep tool: requires 'milliseconds' as a non-negative number.
        {
          name: "sleep",
          description: "Wait for a specified duration",
          inputSchema: {
            type: "object",
            properties: {
              milliseconds: {
                type: "number",
                description: "Duration to wait in milliseconds",
                minimum: 0
              }
            },
            required: ["milliseconds"]
          }
        }
      ]
    };
  • src/index.ts:30-50 (registration)
    Registration of the sleep tool via the ListToolsRequestSchema handler, which returns the tool metadata including schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "sleep",
            description: "Wait for a specified duration",
            inputSchema: {
              type: "object",
              properties: {
                milliseconds: {
                  type: "number",
                  description: "Duration to wait in milliseconds",
                  minimum: 0
                }
              },
              required: ["milliseconds"]
            }
          }
        ]
      };
    });
  • SleepService class providing the sleep functionality as a helper for the main handler.
    export class SleepService {
      /**
       * Wait for the specified duration
       * @param ms Duration to wait in milliseconds
       * @returns Promise that resolves after the duration
       */
      async sleep(ms: number): Promise<void> {
        if (isNaN(ms) || ms < 0) {
          throw new Error("milliseconds must be a non-negative number");
        }
        
        return new Promise(resolve => setTimeout(resolve, ms));
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions waiting but doesn't specify whether this is blocking, if it affects system resources, what happens during the wait, or any error conditions. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just four words, front-loaded with the core function, and contains zero wasted information. Every word earns its place in communicating the essential purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter with full schema coverage, no output schema), the description is minimally adequate but lacks context about behavioral aspects like blocking nature or error handling. It's complete enough for basic understanding but misses deeper operational details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'milliseconds' fully documented in the schema. The description adds no additional parameter semantics beyond what's already in the schema, so it meets the baseline of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Wait for a specified duration' clearly states the tool's function with a specific verb ('Wait') and resource ('duration'), making the purpose immediately understandable. However, it doesn't differentiate from siblings since there are none, so it can't achieve a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It simply states what the tool does without any usage instructions or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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