30 lines
900 B
Python
30 lines
900 B
Python
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"
|