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
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 键名 |
Implementation Reference
- src/services/redisService.ts:515-530 (handler)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 }; }); }
- src/services/mcpService.ts:1279-1291 (handler)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) } ] }; }
- src/services/mcpService.ts:548-558 (registration)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'] } },
- src/types/index.ts:43-48 (schema)Type definition for RedisKeyInfo returned by the key_info tool.export interface RedisKeyInfo { key: string; type: string; ttl: number; size?: number; }