Skip to main content
Glama

string_incr

Increment numeric values stored in Redis keys by a specified amount or by default of 1. Use this tool to update counters, scores, or any numerical data in your Redis database.

Instructions

递增数值

Input Schema

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

Implementation Reference

  • The main handler function for the 'string_incr' MCP tool. Ensures Redis connection and delegates to RedisService.incr method.
    private async handleStringIncr(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.incr(args.key, args.increment); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
  • Input schema definition and tool registration entry for 'string_incr' in the ListTools handler.
    { name: 'string_incr', description: '递增数值', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' }, increment: { type: 'number', description: '增量值(可选,默认为 1)' } }, required: ['key'] } },
  • Dispatch registration in the CallToolRequestSchema handler switch statement.
    case 'string_incr': return await this.handleStringIncr(args);
  • Supporting method in RedisService that implements the core Redis increment logic using client.incr or incrBy.
    async incr(key: string, increment: number = 1): Promise<RedisOperationResult<number>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); if (increment === 1) { return await this.client.incr(key); } else { return await this.client.incrBy(key, increment); } }); }

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