agentbay_memory_health
Assess memory health of any project: get total entries, tier/type breakdown, stale count, low confidence entries, expiring entries, alias count, and total tokens.
Instructions
Check memory health: total entries, tier/type breakdown, stale count, low confidence entries, expiring entries, alias count, total tokens
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID |
Implementation Reference
- src/index.ts:728-751 (registration)The tool 'agentbay_memory_health' is registered on the MCP server at line 728 via server.tool(), with Zod schema defining a 'projectId' input parameter, and its handler at lines 734-750.
server.tool( 'agentbay_memory_health', 'Check memory health: total entries, tier/type breakdown, stale count, low confidence entries, expiring entries, alias count, total tokens', { projectId: z.string().describe('Project ID'), }, async ({ projectId }) => { const data = await apiGet(`/api/v1/projects/${projectId}/memory?action=health`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; const lines = [ `Memory Health for project:`, `Total entries: ${data.totalEntries} | Total tokens: ${data.totalTokens?.toLocaleString() || 0} | Aliases: ${data.aliasCount || 0}`, ``, `By tier: ${Object.entries(data.byTier || {}).map(([k, v]) => `${k}=${v}`).join(', ') || 'none'}`, `By type: ${Object.entries(data.byType || {}).map(([k, v]) => `${k}=${v}`).join(', ') || 'none'}`, ``, `Stale (30+ days unverified): ${data.staleCount || 0}`, `Low confidence (<30%): ${data.lowConfidenceCount || 0}`, `Expiring in 24h: ${data.expiringCount || 0}`, ]; return { content: [{ type: 'text' as const, text: lines.join('\n') }] }; } ); - src/index.ts:734-750 (handler)The handler function for agentbay_memory_health: calls GET /api/v1/projects/{projectId}/memory?action=health and formats the response into a text report showing total entries, tokens, aliases, breakdowns by tier/type, stale count, low confidence count, and expiring entries.
async ({ projectId }) => { const data = await apiGet(`/api/v1/projects/${projectId}/memory?action=health`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; const lines = [ `Memory Health for project:`, `Total entries: ${data.totalEntries} | Total tokens: ${data.totalTokens?.toLocaleString() || 0} | Aliases: ${data.aliasCount || 0}`, ``, `By tier: ${Object.entries(data.byTier || {}).map(([k, v]) => `${k}=${v}`).join(', ') || 'none'}`, `By type: ${Object.entries(data.byType || {}).map(([k, v]) => `${k}=${v}`).join(', ') || 'none'}`, ``, `Stale (30+ days unverified): ${data.staleCount || 0}`, `Low confidence (<30%): ${data.lowConfidenceCount || 0}`, `Expiring in 24h: ${data.expiringCount || 0}`, ]; return { content: [{ type: 'text' as const, text: lines.join('\n') }] }; } - src/index.ts:731-733 (schema)Input schema: requires a 'projectId' string via Zod. Described as 'Project ID'.
{ projectId: z.string().describe('Project ID'), },