string_incr
Increase a numerical value stored in a Redis key by a specified or default increment. Simplify data manipulation in Redis MCP for efficient caching, counters, and real-time updates.
Instructions
递增数值
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| increment | No | 增量值(可选,默认为 1) | |
| key | Yes | 键名 |
Implementation Reference
- src/services/mcpService.ts:854-866 (handler)The handler function that implements the core logic of the 'string_incr' tool. It ensures a Redis connection, calls the RedisService.incr method, and returns the result as MCP content.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) } ] }; }
- src/services/mcpService.ts:129-136 (schema)The input schema definition for the 'string_incr' tool, specifying required 'key' and optional 'increment' parameters.inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' }, increment: { type: 'number', description: '增量值(可选,默认为 1)' } }, required: ['key'] }
- src/services/mcpService.ts:126-137 (registration)The tool registration object returned by ListToolsRequestHandler, defining name, description, and inputSchema for 'string_incr'.{ name: 'string_incr', description: '递增数值', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' }, increment: { type: 'number', description: '增量值(可选,默认为 1)' } }, required: ['key'] } },
- src/services/mcpService.ts:636-637 (registration)The dispatch case in the CallToolRequestHandler switch statement that routes 'string_incr' calls to the handler function.case 'string_incr': return await this.handleStringIncr(args);