Skip to main content
Glama

hash_get

Retrieve specific field values from a Redis hash key using the Redis MCP server, simplifying efficient data access and management for database operations.

Instructions

获取哈希字段

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldYes字段名
keyYes哈希键名

Implementation Reference

  • The primary handler function for the 'hash_get' MCP tool. It ensures a Redis connection, retrieves the hash field value using RedisService.hget(key, field), and returns the result as formatted JSON text content.
    private async handleHashGet(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.hget(args.key, args.field); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] };
  • The tool schema definition including name, description, and input schema (requires 'key' and 'field' strings) as returned by ListTools.
    { name: 'hash_get', description: '获取哈希字段', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '哈希键名' }, field: { type: 'string', description: '字段名' } }, required: ['key', 'field'] } },
  • The dispatch case in the CallToolRequest handler that routes 'hash_get' calls to the handleHashGet method.
    case 'hash_get': return await this.handleHashGet(args);
  • The supporting RedisService.hget method that performs the actual Redis HGET operation via the redis client and wraps it in error handling.
    async hget(key: string, field: string): Promise<RedisOperationResult<string | null>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); const result = await this.client.hGet(key, field); return result || null; });

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