Update cognee-mcp/cognee_mcp/server.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Vasilije 2025-01-11 16:57:59 +01:00 committed by GitHub
parent b132ff4990
commit 7b0bfe9504
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -196,10 +196,12 @@ async def handle_call_tool(
elif name == "visualize":
with open(os.devnull, "w") as fnull:
with redirect_stdout(fnull), redirect_stderr(fnull):
"""Create a thumbnail from an image"""
await cognee.visualize
img = get_freshest_png(".")
return types.Image(data=img.tobytes(), format="png")
try:
await cognee.visualize
img = get_freshest_png(".")
return types.Image(data=img.tobytes(), format="png")
except (FileNotFoundError, IOError, ValueError) as e:
raise ValueError(f"Failed to create visualization: {str(e)}")
else:
raise ValueError(f"Unknown tool: {name}")