redis_hgetall
Retrieve all field-value pairs from a Redis hash using the hash key. Enables full hash data retrieval for inspection, migration, or backup.
Instructions
获取哈希所有字段。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- src/index.ts:174-174 (schema)Tool registration and input schema for redis_hgetall. Defines the tool name, description, and input schema (key: string, required).
{ name: "redis_hgetall", description: "获取哈希所有字段。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } }, - src/index.ts:193-193 (handler)Handler logic for redis_hgetall. Calls client.hGetAll(args.key) to retrieve all hash fields and returns the result as JSON.
redis_hgetall: async () => { const r = await client.hGetAll(args.key); return `HGETALL 成功。${args.key}: ${JSON.stringify(r)}`; }, - src/index.ts:165-177 (registration)Registration of all tools via ListToolsRequestSchema, including redis_hgetall in the tools array.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: "redis_set", description: "设置键值。自动读取项目 .env 配置连接 Redis。", inputSchema: { type: "object", properties: { key: { type: "string" }, value: { type: "string" } }, required: ["key", "value"] } }, { name: "redis_get", description: "获取键值。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } }, { name: "redis_del", description: "删除键。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } }, { name: "redis_exists", description: "检查键是否存在。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } }, { name: "redis_info", description: "获取连接信息。", inputSchema: { type: "object", properties: {} } }, { name: "redis_hset", description: "设置哈希字段。", inputSchema: { type: "object", properties: { key: { type: "string" }, field: { type: "string" }, value: { type: "string" } }, required: ["key", "field", "value"] } }, { name: "redis_hget", description: "获取哈希字段。", inputSchema: { type: "object", properties: { key: { type: "string" }, field: { type: "string" } }, required: ["key", "field"] } }, { name: "redis_hgetall", description: "获取哈希所有字段。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } }, { name: "redis_hdel", description: "删除哈希字段。", inputSchema: { type: "object", properties: { key: { type: "string" }, fields: { type: "array", items: { type: "string" } } }, required: ["key", "fields"] } } ] }));