key_delete
Remove specific keys or arrays of keys from a Redis database to manage storage efficiently. Supports batch deletions for streamlined data handling in Redis MCP.
Instructions
删除键
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | Yes | 要删除的键名或键名数组 |
Implementation Reference
- src/services/mcpService.ts:1194-1206 (handler)Executes the key_delete tool: ensures Redis connection, calls RedisService.del on the keys, formats and returns the result in MCP response format.private async handleKeyDelete(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.del(args.keys); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/mcpService.ts:482-502 (registration)Registers the key_delete tool in the MCP listTools response, including name, description, and input schema allowing single key or array of keys.{ name: 'key_delete', description: '删除键', inputSchema: { type: 'object', properties: { keys: { oneOf: [ { type: 'string', description: '键名' }, { type: 'array', items: { type: 'string' }, description: '键名数组' } ], description: '要删除的键名或键名数组' } }, required: ['keys'] } },
- src/services/mcpService.ts:485-501 (schema)Input schema for key_delete tool: requires 'keys' which can be a string or array of strings.inputSchema: { type: 'object', properties: { keys: { oneOf: [ { type: 'string', description: '键名' }, { type: 'array', items: { type: 'string' }, description: '键名数组' } ], description: '要删除的键名或键名数组' } }, required: ['keys'] }
- src/services/redisService.ts:143-153 (helper)RedisService.del method: core implementation that calls the Redis client's del command on single or multiple keys, wrapped with connection handling and error management.async del(key: string | string[]): Promise<RedisOperationResult<number>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); if (Array.isArray(key)) { return await this.client.del(key); } else { return await this.client.del(key); } }); }