Skip to main content
Glama

key_delete_pattern

Delete multiple Redis keys matching a specified pattern using wildcards (*, ?, []) for efficient batch cleanup operations.

Instructions

批量删除匹配的键

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYes匹配模式(支持通配符 * ? [])

Implementation Reference

  • MCP tool handler that ensures Redis connection, calls deleteByPattern on RedisService with the input pattern, and formats the result as MCP response.
    private async handleKeyDeletePattern(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.deleteByPattern(args.pattern);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Implements the core logic: retrieves keys matching the pattern using Redis KEYS command, then deletes them using DEL if any found.
    async deleteByPattern(pattern: string): Promise<RedisOperationResult<number>> {
      return this.executeCommand(async () => {
        if (!this.client) throw new Error('Redis client not initialized');
        
        const keys = await this.client.keys(pattern);
        if (keys.length === 0) {
          return 0;
        }
        
        return await this.client.del(keys);
      });
    }
  • Input schema defining the 'pattern' parameter as a required string for matching keys with wildcards (* ? []).
    inputSchema: {
      type: 'object',
      properties: {
        pattern: { type: 'string', description: '匹配模式(支持通配符 * ? [])' }
      },
      required: ['pattern']
    }
  • Registration in the tool dispatch switch statement that routes calls to the handler.
    case 'key_delete_pattern':
      return await this.handleKeyDeletePattern(args);
  • Tool registration in the MCP server's tools list, including name, description, and schema.
    {
      name: 'key_delete_pattern',
      description: '批量删除匹配的键',
      inputSchema: {
        type: 'object',
        properties: {
          pattern: { type: 'string', description: '匹配模式(支持通配符 * ? [])' }
        },
        required: ['pattern']
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states '批量删除匹配的键' (batch delete matching keys), implying a destructive mutation operation, but doesn't mention critical aspects like irreversible deletion, performance impact on large datasets, permissions required, or error handling. For a destructive tool with zero annotation coverage, this is a significant gap in transparency.

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 with a single phrase '批量删除匹配的键', which is front-loaded and wastes no words. Every part of the phrase contributes essential meaning: '批量' (batch), '删除' (delete), '匹配的' (matching), and '键' (keys), making it efficient and well-structured.

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 destructive nature (deletion), lack of annotations, no output schema, and multiple sibling tools, the description is incomplete. It doesn't address safety concerns, return values, or differentiation from similar tools like 'key_delete'. For a batch deletion tool in a Redis context with many alternatives, more context is needed to guide the agent effectively.

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 input schema has 100% description coverage, with the 'pattern' parameter documented as supporting wildcards (* ? []). The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints on pattern usage. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 '批量删除匹配的键' clearly states the action (delete) and resource (keys) in Chinese, meaning 'batch delete matching keys'. It specifies the batch nature and matching criteria, which distinguishes it from the sibling tool 'key_delete' (likely for single-key deletion). However, it doesn't explicitly mention Redis or the data store context, which could slightly reduce specificity.

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 like 'key_delete' (for single keys), 'db_flush' (for all keys), or 'key_search' (for finding keys without deletion). It lacks context about prerequisites, risks, or typical scenarios for pattern-based deletion, leaving the agent with minimal usage 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/pickstar-2002/redis-mcp'

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