Skip to main content
Glama

key_ttl

Retrieve the remaining time before a Redis key expires to manage data lifecycle and optimize memory usage.

Instructions

获取键过期时间

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes键名

Implementation Reference

  • The handler function that implements the key_ttl MCP tool. It ensures a Redis connection exists and calls the RedisService.ttl method with the provided key argument, returning the result as formatted text content.
    private async handleKeyTtl(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.ttl(args.key);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
  • Input schema definition for the key_ttl tool, specifying that a 'key' string parameter is required.
    inputSchema: {
      type: 'object',
      properties: {
        key: { type: 'string', description: '键名' }
      },
      required: ['key']
    }
  • Tool registration in the ListTools response, defining name, description, and input schema for key_ttl.
    {
      name: 'key_ttl',
      description: '获取键过期时间',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string', description: '键名' }
        },
        required: ['key']
      }
    },
  • Dispatcher case in CallToolRequest handler that routes key_ttl calls to the handleKeyTtl method.
    case 'key_ttl':
      return await this.handleKeyTtl(args);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('获取' - get) but doesn't disclose behavioral traits: it doesn't specify what happens if the key doesn't exist (e.g., returns -2), if it has no expiration (returns -1), or if there are permission/connection issues. For a read operation with zero annotation coverage, this leaves critical gaps in understanding how the tool behaves in edge cases.

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 a single, efficient phrase ('获取键过期时间') with zero waste. It's front-loaded and appropriately sized for a simple tool, avoiding unnecessary elaboration. Every word contributes directly to the purpose without redundancy.

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 simplicity (1 parameter, 100% schema coverage) but lack of annotations and output schema, the description is incomplete. It doesn't explain return values (e.g., TTL in seconds, -1 for no expiry, -2 for non-existent key), error conditions, or dependencies like requiring Redis connectivity. For a tool that interacts with a data store, more context is needed despite the minimal parameter set.

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% (the 'key' parameter is documented as '键名' - key name), so the baseline is 3. The description adds no additional meaning beyond the schema—it doesn't explain key naming conventions, allowed characters, or that this refers to a Redis key. It relies entirely on the schema for parameter documentation.

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 '获取键过期时间' (Get key expiration time) clearly states the verb ('获取' - get) and resource ('键过期时间' - key expiration time). It distinguishes from siblings like key_delete (deletes keys), key_expire (sets expiration), and key_info (gets general key info) by focusing specifically on expiration time retrieval. However, it doesn't explicitly mention this is for Redis keys, though context suggests it.

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. It doesn't mention when to use key_ttl versus key_info (which might include TTL) or key_expire (which sets TTL), nor does it specify prerequisites like requiring an active Redis connection. The agent must infer usage from the name and sibling tools alone.

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