Files
python-sdk/pkg/hanzo-mcp/test_memory_integration.py
T
zooqueenandHanzo Dev 920f767417 style: auto-fix ruff lint and format for Python 3.12
Run ruff check --fix and ruff format across the repo to fix ~495
auto-fixable lint errors (mostly I001 import sorting) and reformat
225 files to match the py312 target.

Co-authored-by: Hanzo Dev <[email protected]>
2026-02-20 21:29:31 -08:00

97 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Test memory integration in hanzo-mcp."""
import asyncio
import sys
from pathlib import Path
# Add parent to path
sys.path.insert(0, str(Path(__file__).parent))
class Console:
"""Simple console replacement."""
def print(self, text):
print(text)
console = Console()
async def test_memory_integration():
"""Test that memory tools work with local storage."""
console.print("\n[bold cyan]Testing Hanzo MCP Memory Integration[/bold cyan]\n")
# Test importing hanzo-memory
try:
import hanzo_memory
console.print("✅ hanzo-memory package imported successfully")
except ImportError as e:
console.print(f"❌ Failed to import hanzo-memory: {e}")
return
# Test local memory client
try:
from hanzo_memory.db.local_client import LocalMemoryClient
console.print("✅ LocalMemoryClient imported successfully")
# Create client
client = LocalMemoryClient(enable_markdown=True)
await client.initialize()
console.print("✅ LocalMemoryClient initialized with markdown support")
# Check for markdown memories
projects = await client.list_projects()
markdown_project = next(
(p for p in projects if p.project_id == "markdown_import"), None
)
if markdown_project:
memory_count = len(
[
m
for m in client.memories.values()
if m.get("project_id") == "markdown_import"
]
)
console.print(f"✅ Found {memory_count} memories from markdown files")
else:
console.print("ℹ️ No markdown memories found (first run)")
await client.close()
except Exception as e:
console.print(f"❌ Error with LocalMemoryClient: {e}")
return
# Test MCP tools integration
try:
# Check if memory tools can be imported
from hanzo_tools.memory import memory_tools
console.print("✅ Memory tools module imported")
tool_names = [t.name for t in memory_tools.MEMORY_TOOLS]
console.print(f"✅ Found {len(tool_names)} memory tools: {tool_names[:3]}...")
except ImportError as e:
console.print(f"⚠️ Memory tools not available (expected): {e}")
console.print(
" This is OK - memory tools are loaded dynamically when MCP server starts"
)
console.print(
"\n[bold green]✅ Memory integration test completed successfully![/bold green]"
)
console.print(
"\nYour markdown files (LLM.md, CLAUDE.md, etc.) will be automatically loaded into memory when using hanzo-mcp tools."
)
if __name__ == "__main__":
asyncio.run(test_memory_integration())