Skip to main content
Glama

string_set

Set string key-value pairs in Redis with optional expiration time to store and manage data efficiently.

Instructions

设置字符串键值

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes键名
valueYes
expireSecondsNo过期时间(秒)(可选)

Implementation Reference

  • Handler function that implements the string_set tool logic: ensures Redis connection, calls redisService.set with key, value, expireSeconds, and returns the result as MCP content.
    private async handleStringSet(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.set(args.key, args.value, args.expireSeconds);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Input schema definition for the string_set tool, including properties for key, value, and optional expireSeconds.
    {
      name: 'string_set',
      description: '设置字符串键值',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string', description: '键名' },
          value: { type: 'string', description: '值' },
          expireSeconds: { type: 'number', description: '过期时间(秒)(可选)' }
        },
        required: ['key', 'value']
      }
    },
  • Registration/dispatch in the CallToolRequestSchema handler switch statement that routes string_set calls to the handleStringSet method.
    case 'string_set':
      return await this.handleStringSet(args);
  • Tool registration in the ListToolsRequestSchema response, declaring the string_set tool with its name, description, and schema.
    {
      name: 'string_set',
      description: '设置字符串键值',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string', description: '键名' },
          value: { type: 'string', description: '值' },
          expireSeconds: { type: 'number', description: '过期时间(秒)(可选)' }
        },
        required: ['key', 'value']
      }
    },

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