Add generic memory gateway v1

This commit is contained in:
2026-05-05 16:18:31 +08:00
parent ba84b1ddb3
commit e65731a273
54 changed files with 4082 additions and 49 deletions

29
tests/test_v1_mcp.py Normal file
View File

@ -0,0 +1,29 @@
import asyncio
from memory_gateway.repositories import InMemoryRepository
from memory_gateway.services import MemoryGatewayService
def test_v1_mcp_tools_are_exposed_and_dispatch(monkeypatch):
import memory_gateway.server as server
service = MemoryGatewayService(InMemoryRepository())
monkeypatch.setattr(server, "v1_service", service)
tools = asyncio.run(server.list_tools())
assert any(tool.name == "memory_search" for tool in tools)
assert any(tool.name == "memory_commit_session" for tool in tools)
result = asyncio.run(
server.call_v1_memory_tool(
"memory_upsert",
{
"user_id": "user_a",
"content": "MCP 写入的 v1 memory",
"visibility": "private",
},
)
)
assert result["user_id"] == "user_a"
assert result["namespace"] == "user/user_a/long_term"