key_delete
Remove specific keys or key arrays from a Redis database to manage storage and maintain data organization.
Instructions
删除键
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | Yes | 要删除的键名或键名数组 |
Implementation Reference
- src/services/mcpService.ts:1194-1206 (handler)MCP tool handler for 'key_delete' that ensures Redis connection, calls RedisService.del with the provided keys, and formats the result as MCP response content.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:483-501 (schema)Input schema definition for the 'key_delete' tool, specifying keys as string or array of strings.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:686-687 (registration)Registration of the 'key_delete' tool handler in the CallToolRequestSchema switch statement.case 'key_delete': return await this.handleKeyDelete(args);
- src/services/redisService.ts:143-153 (helper)Supporting method in RedisService that wraps the Redis client's DEL command to delete single or multiple keys.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); } }); }