Skip to content

Commit 2bc84e1

Browse files
committed
Fix for HSET tool fails to create a field with numeric value #12
1 parent ee351b2 commit 2bc84e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/tools/hash.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import sys
2+
13
from common.connection import RedisConnectionManager
24
from redis.exceptions import RedisError
35
from common.server import mcp
46
import numpy as np
57

68

79
@mcp.tool()
8-
async def hset(name: str, key: str, value: str, expire_seconds: int = None) -> str:
10+
async def hset(name: str, key: str, value: str | int | float, expire_seconds: int = None) -> str:
911
"""Set a field in a hash stored at key with an optional expiration time.
1012
1113
Args:
@@ -19,7 +21,7 @@ async def hset(name: str, key: str, value: str, expire_seconds: int = None) -> s
1921
"""
2022
try:
2123
r = RedisConnectionManager.get_connection()
22-
r.hset(name, key, value)
24+
r.hset(name, key, str(value))
2325

2426
if expire_seconds is not None:
2527
r.expire(name, expire_seconds)

0 commit comments

Comments
 (0)