memory_stats
Looks like a counter. Works like an audit tool. The real power is in what it returns alongside the count — a full list of matched labels or sources, not just a number.
Parameters #
| Parameter | Type | Required | Description |
|---|---|---|---|
labels | string | No | Label filter (substring-matched, supports ! exclusion) |
source | string | No | Source filter (substring-matched, supports ! exclusion) |
With no parameters, returns the total memory count for the namespace.
Response #
| Field | Description |
|---|---|
total | Total memories in the namespace |
matching | Memories matching the filter |
ratio | e.g. "25/994" |
percentage | e.g. "2%" |
labels_matched | Full list of distinct labels matched (when filtering by labels) |
sources_matched | Full list of distinct sources matched (when filtering by source) |
Examples #
# Total count only
memory_stats()
# How many memories on a topic — plus every label variant that matched
memory_stats(labels: "mcp")
# Count memories from a specific agent
memory_stats(source: "agent:sonnet:main")
# Check unprocessed backlog (nonce label)
memory_stats(labels: "52868312778495")
Power Combinations #
Label discovery — use a broad token to find every label variant the enrichment cron has generated. Surfaces naming patterns, inconsistencies, and unexpected topics:
memory_stats(labels: "memory")
→ labels_matched: ["memory-system", "memory-architecture", "memory-mcp-ce", ...]
# Use this to refine retrieve_memories label queries
Source audit — use "/" to list every structured source in the namespace:
memory_stats(source: "/")
→ sources_matched: ["agent:sonnet:main", "agent:main:main", "anthropic/claude-sonnet-4.6", ...]
Enrichment backlog check — query the nonce label to see how many memories are still awaiting enrichment:
memory_stats(labels: "52868312778495")
→ matching: 0 # cron has caught up
→ matching: 47 # backlog still processing
Namespace health check — combine total with a label filter to understand signal density:
memory_stats() → total: 994
memory_stats(labels: "architecture") → matching: 38, ~4% of total