Skip to main content
Glama

string_decr

Decrease the value of a Redis string by a specified integer, defaulting to 1 if no value is provided. Ideal for decrementing counters or managing numeric data.

Instructions

递减数值

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
decrementNo减量值(可选,默认为 1)
keyYes键名

Implementation Reference

  • MCP tool handler for 'string_decr': ensures Redis connection, calls RedisService.decr(), and returns formatted JSON response.
    private async handleStringDecr(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.decr(args.key, args.decrement); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
  • Tool registration including name, description, and input schema definition for 'string_decr'.
    { name: 'string_decr', description: '递减数值', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' }, decrement: { type: 'number', description: '减量值(可选,默认为 1)' } }, required: ['key'] }
  • Dispatch case in the CallToolRequestSchema handler that routes 'string_decr' calls to the handler method.
    case 'string_decr': return await this.handleStringDecr(args);
  • Core Redis decrement implementation using client.decr() or decrBy() wrapped in error handling and connection management.
    async decr(key: string, decrement: number = 1): Promise<RedisOperationResult<number>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); if (decrement === 1) { return await this.client.decr(key); } else { return await this.client.decrBy(key, decrement); } }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickstar-2002/redis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server