fix: add preview to delete response for MCP server compatibility

This commit is contained in:
Viktor Barzin 2026-03-14 11:14:05 +00:00
parent 3207ecf3e9
commit 58ea218044
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 6 additions and 4 deletions

View file

@ -200,7 +200,7 @@ async def delete_memory(memory_id: int, user: AuthUser = Depends(get_current_use
async with pool.acquire() as conn:
row = await conn.fetchrow(
"SELECT id, vault_path FROM memories WHERE id = $1 AND user_id = $2",
"SELECT id, vault_path, substr(content, 1, 50) AS preview FROM memories WHERE id = $1 AND user_id = $2",
memory_id,
user.user_id,
)
@ -216,7 +216,7 @@ async def delete_memory(memory_id: int, user: AuthUser = Depends(get_current_use
user.user_id,
)
return {"deleted": memory_id}
return {"deleted": memory_id, "preview": row["preview"]}
@app.post("/api/memories/{memory_id}/secret", response_model=SecretResponse)

View file

@ -194,7 +194,7 @@ async def test_list_returns_only_user_memories(client):
@pytest.mark.asyncio
async def test_delete_only_user_memories(client):
ac, conn, app_mod = client
conn.fetchrow.return_value = _make_memory_row(id=10, vault_path=None)
conn.fetchrow.return_value = _make_memory_row(id=10, vault_path=None, preview="test content")
conn.execute.return_value = None
async with ac:
@ -204,7 +204,9 @@ async def test_delete_only_user_memories(client):
)
assert resp.status_code == 200
assert resp.json() == {"deleted": 10}
data = resp.json()
assert data["deleted"] == 10
assert "preview" in data
# Verify both SELECT and DELETE include user_id
fetchrow_args = conn.fetchrow.call_args