Skip to main content
Glama
haasonsaas

MCP Utility Tools

by haasonsaas

rate_limit_check

Check whether an operation exceeds the allowed request count within a configurable time window to prevent excessive API calls and ensure fair usage.

Instructions

Check if an operation should be rate-limited

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceYesResource identifier (e.g., 'api.github.com')
max_requestsNoMaximum requests allowed
window_secondsNoTime window in seconds
incrementNoIncrement the counter if allowed

Implementation Reference

  • The handler logic for the rate_limit_check tool. It extracts args (resource, max_requests, window_seconds, increment), checks/initializes rate limit state from the rateLimits Map, determines if the operation is allowed based on count vs max_requests, optionally increments the counter, and returns a JSON response with allowed status, current count, remaining, reset time, etc.
    case "rate_limit_check": {
      const {
        resource,
        max_requests = 60,
        window_seconds = 60,
        increment = true
      } = args as any;
    
      const now = Date.now();
      const windowMs = window_seconds * 1000;
      
      let limit = rateLimits.get(resource);
      
      // Initialize or reset if window expired
      if (!limit || limit.resetAt <= now) {
        limit = {
          count: 0,
          resetAt: now + windowMs
        };
        rateLimits.set(resource, limit);
      }
      
      const allowed = limit.count < max_requests;
      const remaining = Math.max(0, max_requests - limit.count);
      const resetIn = Math.ceil((limit.resetAt - now) / 1000);
      
      if (allowed && increment) {
        limit.count++;
      }
      
      return {
        content: [{
          type: "text",
          text: JSON.stringify({
            allowed,
            resource,
            current_count: limit.count,
            max_requests,
            remaining,
            reset_in_seconds: resetIn,
            reset_at: new Date(limit.resetAt).toISOString()
          })
        }]
      };
    }
  • The schema/definition for the rate_limit_check tool, defining its name, description, and inputSchema with properties: resource (string, required), max_requests (number, default 60), window_seconds (number, default 60), and increment (boolean, default true).
    {
      name: "rate_limit_check",
      description: "Check if an operation should be rate-limited",
      inputSchema: {
        type: "object",
        properties: {
          resource: {
            type: "string",
            description: "Resource identifier (e.g., 'api.github.com')"
          },
          max_requests: {
            type: "number",
            description: "Maximum requests allowed",
            default: 60
          },
          window_seconds: {
            type: "number",
            description: "Time window in seconds",
            default: 60
          },
          increment: {
            type: "boolean",
            description: "Increment the counter if allowed",
            default: true
          }
        },
        required: ["resource"]
      }
    }
  • Tool registration via server.setRequestHandler(ListToolsRequestSchema) which returns the tools array containing the rate_limit_check definition.
    // Register list handler
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
  • The rateLimits Map used by the rate_limit_check handler to store per-resource rate limit state (count and resetAt).
    // Rate limiting storage
    const rateLimits = new Map<string, { count: number; resetAt: number }>();
Behavior2/5

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

Description implies a read-only check ('check if'), but the increment parameter can mutate state. Without annotations, this discrepancy is not disclosed.

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

Conciseness3/5

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

Single sentence is concise but under-specified for a 4-parameter tool. Lacks structured details.

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?

No output schema; description does not explain return value (e.g., boolean or status). Incomplete for understanding tool behavior.

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 coverage is 100%, so baseline 3. Description adds no extra meaning beyond parameter names and default values.

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 'Check if an operation should be rate-limited' clearly states the verb (check) and resource (operation), but does not differentiate from siblings like retry_operation.

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 on when to use this tool vs alternatives (e.g., retry_operation). The description lacks context for appropriate invocation.

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/haasonsaas/mcp-utility-tools'

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