key_type
Determine the Redis data type of a specified key to understand how to interact with stored values.
Instructions
获取键类型
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 键名 |
Implementation Reference
- src/services/mcpService.ts:1262-1274 (handler)MCP tool handler for 'key_type': ensures Redis connection, calls RedisService.type(key), and formats result as MCP content response.private async handleKeyType(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.type(args.key); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/mcpService.ts:537-547 (registration)Tool registration in ListTools response: defines name 'key_type', description, and input schema requiring 'key' parameter.{ name: 'key_type', description: '获取键类型', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] } },
- src/services/mcpService.ts:694-695 (registration)Dispatch registration in CallToolRequestSchema switch statement: routes 'key_type' calls to handleKeyType method.case 'key_type': return await this.handleKeyType(args);
- src/services/redisService.ts:505-510 (helper)RedisService helper method implementing the core Redis TYPE key command via the redis client.async type(key: string): Promise<RedisOperationResult<string>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); return await this.client.type(key); }); }