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

Function display_memory_tree

examples/mcpserver/memory.py:246–262  ·  view source on GitHub ↗
(deps: Deps)

Source from the content-addressed store, hash-verified

244
245
246async def display_memory_tree(deps: Deps) -> str:
247 async with deps.pool.acquire() as conn:
248 rows = await conn.fetch(
249 """
250 SELECT content, summary, importance, access_count
251 FROM memories
252 ORDER BY importance DESC
253 LIMIT $1
254 """,
255 MAX_DEPTH,
256 )
257 result = ""
258 for row in rows:
259 effective_importance = row["importance"] * (1 + math.log(row["access_count"] + 1))
260 summary = row["summary"] or row["content"]
261 result += f"- {summary} (Importance: {effective_importance:.2f})\n"
262 return result
263
264
265@mcp.tool()

Callers 1

read_profileFunction · 0.85

Calls 1

logMethod · 0.45

Tested by

no test coverage detected