MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / find_similar_memories

Function find_similar_memories

examples/mcpserver/memory.py:181–204  ·  view source on GitHub ↗
(embedding: list[float], deps: Deps)

Source from the content-addressed store, hash-verified

179
180
181async def find_similar_memories(embedding: list[float], deps: Deps) -> list[MemoryNode]:
182 async with deps.pool.acquire() as conn:
183 rows = await conn.fetch(
184 """
185 SELECT id, content, summary, importance, access_count, timestamp, embedding
186 FROM memories
187 ORDER BY embedding <-> $1
188 LIMIT 5
189 """,
190 embedding,
191 )
192 memories = [
193 MemoryNode(
194 id=row["id"],
195 content=row["content"],
196 summary=row["summary"],
197 importance=row["importance"],
198 access_count=row["access_count"],
199 timestamp=row["timestamp"],
200 embedding=row["embedding"],
201 )
202 for row in rows
203 ]
204 return memories
205
206
207async def update_importance(user_embedding: list[float], deps: Deps):

Callers 1

add_memoryFunction · 0.85

Calls 1

MemoryNodeClass · 0.85

Tested by

no test coverage detected