| 244 | |
| 245 | |
| 246 | async 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() |