Skip to main content
Glama
devlimelabs

Meilisearch MCP Server

by devlimelabs

wait-for-task

Monitor Meilisearch task completion by polling status with configurable timeout and interval settings.

Instructions

Wait for a specific task to complete

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskUidYesUnique identifier of the task to wait for
timeoutMsNoMaximum time to wait in milliseconds (default: 5000)
intervalMsNoPolling interval in milliseconds (default: 500)

Implementation Reference

  • The handler function polls the Meilisearch API for the task status at specified intervals until the task reaches a terminal state (succeeded, failed, canceled) or the timeout is reached. It returns the final task data or a timeout message.
      async ({ taskUid, timeoutMs = 5000, intervalMs = 500 }: WaitForTaskParams) => {
        try {
          const startTime = Date.now();
          let taskCompleted = false;
          let taskData = null;
          
          while (!taskCompleted && (Date.now() - startTime < timeoutMs)) {
            // Fetch the current task status
            const response = await apiClient.get(`/tasks/${taskUid}`);
            taskData = response.data;
            
            // Check if the task has completed
            if (["succeeded", "failed", "canceled"].includes(taskData.status)) {
              taskCompleted = true;
            } else {
              // Wait for the polling interval
              await new Promise(resolve => setTimeout(resolve, intervalMs));
            }
          }
          
          if (!taskCompleted) {
            return {
              content: [{ type: "text", text: `Task ${taskUid} did not complete within the timeout period of ${timeoutMs}ms` }],
            };
          }
          
          return {
            content: [{ type: "text", text: JSON.stringify(taskData, null, 2) }],
          };
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  • Zod input schema defining the parameters for the wait-for-task tool: required taskUid and optional timeoutMs and intervalMs.
    {
      taskUid: z.number().describe("Unique identifier of the task to wait for"),
      timeoutMs: z.number().min(0).optional().describe("Maximum time to wait in milliseconds (default: 5000)"),
      intervalMs: z.number().min(100).optional().describe("Polling interval in milliseconds (default: 500)"),
    },
  • Registers the 'wait-for-task' tool on the MCP server within the registerTaskTools function.
      server.tool(
        "wait-for-task",
        "Wait for a specific task to complete",
        {
          taskUid: z.number().describe("Unique identifier of the task to wait for"),
          timeoutMs: z.number().min(0).optional().describe("Maximum time to wait in milliseconds (default: 5000)"),
          intervalMs: z.number().min(100).optional().describe("Polling interval in milliseconds (default: 500)"),
        },
        async ({ taskUid, timeoutMs = 5000, intervalMs = 500 }: WaitForTaskParams) => {
          try {
            const startTime = Date.now();
            let taskCompleted = false;
            let taskData = null;
            
            while (!taskCompleted && (Date.now() - startTime < timeoutMs)) {
              // Fetch the current task status
              const response = await apiClient.get(`/tasks/${taskUid}`);
              taskData = response.data;
              
              // Check if the task has completed
              if (["succeeded", "failed", "canceled"].includes(taskData.status)) {
                taskCompleted = true;
              } else {
                // Wait for the polling interval
                await new Promise(resolve => setTimeout(resolve, intervalMs));
              }
            }
            
            if (!taskCompleted) {
              return {
                content: [{ type: "text", text: `Task ${taskUid} did not complete within the timeout period of ${timeoutMs}ms` }],
              };
            }
            
            return {
              content: [{ type: "text", text: JSON.stringify(taskData, null, 2) }],
            };
          } catch (error) {
            return createErrorResponse(error);
          }
        }
      );
    };
  • TypeScript interface defining the input parameters for the wait-for-task handler.
    interface WaitForTaskParams {
      taskUid: number;
      timeoutMs?: number;
      intervalMs?: number;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing key behaviors: it doesn't mention that this is a blocking/polling operation (implied by parameters), potential side effects (e.g., resource consumption), timeout handling, or what happens on completion/failure. This leaves significant gaps for a tool that likely involves waiting and state changes.

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

Conciseness4/5

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

The description is a single, clear sentence with no wasted words, making it highly concise. However, it's front-loaded but overly brief, potentially omitting necessary context for effective use, which slightly reduces its utility despite efficient structure.

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

Completeness2/5

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

Given the tool's complexity (involving asynchronous task monitoring), lack of annotations, and no output schema, the description is incomplete. It fails to explain the return value (e.g., task status, result, or error), behavioral nuances like polling mechanics, or interaction with sibling tools, leaving the agent under-informed for proper invocation.

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?

Schema description coverage is 100%, so the schema fully documents all parameters (taskUid, timeoutMs, intervalMs) with descriptions and constraints. The description adds no additional meaning beyond the schema, such as explaining how polling works or default behaviors, resulting in a baseline score of 3.

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

Purpose3/5

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

The description 'Wait for a specific task to complete' clearly states the action (wait) and target (task), but it's vague about what 'wait' entails (e.g., polling, blocking) and doesn't distinguish it from sibling tools like 'get-task' or 'list-tasks'. It specifies the resource (task) but lacks operational details, making it minimally adequate.

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?

No guidance is provided on when to use this tool versus alternatives such as 'get-task' (which might check status without waiting) or 'list-tasks'. The description implies usage after initiating a task, but it doesn't specify prerequisites, error conditions, or exclusions, leaving the agent with little contextual direction.

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

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/devlimelabs/meilisearch-ts-mcp'

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