Skip to main content
Glama

key_info

Retrieve detailed information about a specific key in a Redis database, including its type, TTL, and associated data, to support effective database management.

Instructions

获取键信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes键名

Implementation Reference

  • Core handler function that executes the key_info tool logic by retrieving the key type and TTL using Redis client commands.
    async getKeyInfo(key: string): Promise<RedisOperationResult<RedisKeyInfo>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); const [type, ttl] = await Promise.all([ this.client.type(key), this.client.ttl(key) ]); return { key, type, ttl }; }); }
  • MCP service handler for 'key_info' tool that ensures connection and delegates to RedisService.getKeyInfo.
    private async handleKeyInfo(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.getKeyInfo(args.key); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
  • Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema for 'key_info'.
    { name: 'key_info', description: '获取键信息', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] } },
  • Type definition for RedisKeyInfo returned by the key_info tool.
    export interface RedisKeyInfo { key: string; type: string; ttl: number; size?: number; }

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