Skip to main content
Glama

string_mget

Retrieve multiple string values from Redis keys in a single operation to reduce network calls and improve performance when fetching multiple cached items or configuration settings.

Instructions

批量获取键值

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keysYes键名数组

Implementation Reference

  • Registration of the string_mget tool in the ListTools response, including name, description, and input schema.
    {
      name: 'string_mget',
      description: '批量获取键值',
      inputSchema: {
        type: 'object',
        properties: {
          keys: {
            type: 'array',
            items: { type: 'string' },
            description: '键名数组'
          }
        },
        required: ['keys']
      }
    },
  • The main handler function for the string_mget MCP tool. Ensures Redis connection, calls RedisService.mget, and returns formatted result.
    private async handleStringMget(args: any) {
      this.ensureRedisConnection();
      const result = await this.redisService!.mget(args.keys);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Dispatch case in the CallToolRequest handler that routes string_mget calls to the specific handler.
    case 'string_mget':
      return await this.handleStringMget(args);
  • Helper method in RedisService that performs the actual MGET operation using the Redis client library.
    async mget(keys: string[]): Promise<RedisOperationResult<(string | null)[]>> {
      return this.executeCommand(async () => {
        if (!this.client) throw new Error('Redis client not initialized');
        return await this.client.mGet(keys);
      });
    }

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