Skip to main content
Glama

key_expire

Set expiration time for Redis keys to automatically remove data after a specified duration, managing memory and data lifecycle.

Instructions

设置键过期时间

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes键名
secondsYes过期时间(秒)

Implementation Reference

  • The main handler function for the 'key_expire' MCP tool. It ensures Redis connection and calls RedisService.expire to set key expiration time.
    private async handleKeyExpire(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.expire(args.key, args.seconds);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • The input schema definition for the 'key_expire' tool, registered in the ListTools response.
    {
      name: 'key_expire',
      description: '设置键过期时间',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string', description: '键名' },
          seconds: { type: 'number', description: '过期时间(秒)' }
        },
        required: ['key', 'seconds']
      }
    },
  • The dispatch/registration case in the CallToolRequestHandler switch statement that routes 'key_expire' calls to the handler.
    case 'key_expire':
      return await this.handleKeyExpire(args);
  • Supporting utility method in RedisService that implements the actual Redis EXPIRE command via the redis client.
    async expire(key: string, seconds: number): Promise<RedisOperationResult<boolean>> {
      return this.executeCommand(async () => {
        if (!this.client) throw new Error('Redis client not initialized');
        const result = await this.client.expire(key, seconds);
        return Boolean(result);
      });
    }
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 the action ('设置键过期时间') but doesn't describe key behaviors such as whether it overwrites existing expiration, returns a confirmation, requires specific permissions, or has side effects (e.g., error if key doesn't exist). This leaves significant gaps for an agent to understand how the tool operates beyond the basic action.

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, efficient sentence ('设置键过期时间') that directly states the purpose without unnecessary words. It's appropriately sized for a simple tool, though it could be more informative. There's no waste, but it's borderline under-specified rather than concise.

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 (a mutation operation with no annotations and no output schema), the description is incomplete. It doesn't explain what happens on success or failure, return values, or error conditions. For a tool that modifies data in a Redis-like context, more detail is needed to guide an agent effectively, especially without annotations to cover behavioral aspects.

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 clear parameter descriptions ('键名' for key, '过期时间(秒)' for seconds). The description adds no additional meaning beyond what the schema provides, such as explaining parameter interactions or constraints. Since schema coverage is high, 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.

Purpose3/5

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

The description '设置键过期时间' (Set key expiration time) clearly states the action (set expiration) and target (key), but it's vague about the specific mechanism or context. It doesn't distinguish this tool from sibling tools like key_ttl (which retrieves expiration) or key_delete (which removes keys), leaving ambiguity about its exact role in the Redis-like toolset.

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. For example, it doesn't clarify if this is for setting a new expiration, updating an existing one, or how it differs from key_ttl (which checks expiration) or key_delete (which removes keys immediately). The description lacks context about prerequisites or typical use cases.

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