key_type
Determine the data type of a specified key in Redis, such as string, hash, list, set, or sorted set, to facilitate efficient database management and operation planning.
Instructions
获取键类型
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 键名 |
Implementation Reference
- src/services/mcpService.ts:1262-1274 (handler)Executes the 'key_type' tool: ensures Redis connection, retrieves the type of the specified key using redisService.type(), and returns the result as formatted JSON text.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:540-546 (schema)Input schema for 'key_type' tool: requires a single 'key' property of type string.inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] }
- src/services/mcpService.ts:537-547 (registration)Registration of the 'key_type' tool in the tools list passed to server.setTools(), including name, description, and input schema.{ name: 'key_type', description: '获取键类型', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] } },
- src/services/mcpService.ts:694-695 (registration)Dispatch case in the request handler switch statement that routes 'key_type' calls to handleKeyType.case 'key_type': return await this.handleKeyType(args);