Skip to main content
Glama

stats

Monitor memory health statistics including file counts per tier, average strength, and active, decaying, and archived counts.

Instructions

Show memory health statistics: file counts per tier, average strength, active/decaying/archived counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The calc_stats() function is the core handler for the 'stats' tool. It lists all memory files, groups them by tier, calculates counts, average strength, and active/decaying/archived breakdowns, returning a formatted string.
    def calc_stats():
        files = list_memory_files()
        total = len(files)
        by_tier = {}
        for f in files:
            by_tier.setdefault(f["tier"], []).append(f)
        lines = [f"Total: {total} memories"]
        for tier in TIERS:
            entries = by_tier.get(tier, [])
            if not entries:
                continue
            avg_s = sum(e["strength"] for e in entries) / len(entries)
            decaying = sum(1 for e in entries if 0.2 <= e["strength"] < 0.4)
            archived = sum(1 for e in entries if e["strength"] < 0.2)
            active = len(entries) - decaying - archived
            lines.append(f"  {tier}: {len(entries)} files | avg strength {avg_s:.2f} | {active} active, {decaying} decaying, {archived} archived")
        return "\n".join(lines)
  • Tool definition/schema for 'stats' - declares the tool name, description, and an empty input schema (no parameters required).
    {
        "name": "stats",
        "description": "Show memory health statistics: file counts per tier, average strength, active/decaying/archived counts.",
        "inputSchema": {"type": "object", "properties": {}},
    },
  • nexus_mcp.py:120-170 (registration)
    The TOOL_DEFS list registers all tools including 'stats' as part of the MCP server tool definitions. The handle_tools_list function returns these definitions.
    TOOL_DEFS = [
        {
            "name": "search",
            "description": "Search across all memory files by keyword. Returns matching file names, titles, strengths, and context snippets.",
            "inputSchema": {
                "type": "object",
                "properties": {"query": {"type": "string", "description": "Keyword or phrase to search for"}},
                "required": ["query"],
            },
        },
        {
            "name": "stats",
            "description": "Show memory health statistics: file counts per tier, average strength, active/decaying/archived counts.",
            "inputSchema": {"type": "object", "properties": {}},
        },
        {
            "name": "save",
            "description": "Save a new memory to a specified tier. Creates a markdown file with frontmatter. Use for recording new information, preferences, or experiences.",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "tier": {
                        "type": "string",
                        "enum": ["episodic", "semantic", "procedural", "reflection", "working"],
                        "description": "Memory tier: episodic (experiences), semantic (facts/preferences), procedural (workflows), reflection (meta), working (in-session)",
                    },
                    "name": {"type": "string", "description": "Filename slug (no extension, use dashes: my-memory-name)"},
                    "content": {"type": "string", "description": "Full markdown content of the memory (including title heading)"},
                    "tags": {"type": "string", "description": "Comma-separated tags (optional)"},
                },
                "required": ["tier", "name", "content"],
            },
        },
        {
            "name": "touch",
            "description": "Boost a memory's strength (simulate access, counteracts Ebbinghaus decay). Use this when a memory is referenced or found relevant.",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "name": {"type": "string", "description": "Memory filename (with or without .md extension)"},
                    "boost": {"type": "number", "description": "Strength boost amount (default 0.15, max 1.0)"},
                },
                "required": ["name"],
            },
        },
        {
            "name": "decay",
            "description": "Run a dry-run decay check. Calculates Ebbinghaus decay for all memories and reports which would be archived. Does NOT modify any files.",
            "inputSchema": {"type": "object", "properties": {}},
        },
    ]
  • nexus_mcp.py:215-216 (registration)
    The handle_tools_call function dispatches to calc_stats() when the tool name is 'stats', returning the result as MCP text content.
    elif name == "stats":
        return {"content": [{"type": "text", "text": calc_stats()}]}, None
  • The list_memory_files() helper function is called by calc_stats() to enumerate all memory files across tiers with their metadata (name, tier, strength, etc.).
    def list_memory_files():
        """Return list of {tier, name, path, title, strength, type} for all memories."""
        results = []
        for tier in TIERS:
            tier_dir = os.path.join(MEMORY_DIR, tier)
            if not os.path.isdir(tier_dir):
                continue
            for f in sorted(glob.glob(os.path.join(tier_dir, "*.md"))):
                name = os.path.splitext(os.path.basename(f))[0]
                with open(f, encoding="utf-8") as fh:
                    content = fh.read()
                title = ""
                for line in content.splitlines():
                    if line.startswith("# "):
                        title = line[2:]
                        break
                strength = parse_frontmatter(content, "strength") or "1.0"
                type_ = parse_frontmatter(content, "type") or tier
                results.append({
                    "uri": f"nexus://{tier}/{name}",
                    "name": name,
                    "title": title,
                    "tier": tier,
                    "strength": float(strength),
                    "type": type_,
                    "path": os.path.relpath(f, MEMORY_DIR),
                })
        return results
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes the tool as displaying statistics, which implies a read-only, non-destructive operation. However, it does not explicitly confirm safety, permissions, or side effects, leaving some ambiguity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that efficiently communicates the tool's function without extraneous words. Every part contributes to understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the zero parameters and no output schema, the description is sufficiently complete. It conveys the scope of the tool. However, mentioning the output format (e.g., JSON) could add minor value.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has zero parameters, so the baseline is 4. The description adds value by listing specific statistics shown, which is more informative than the empty schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb 'Show' and identifies the resource as 'memory health statistics', listing concrete outputs (file counts per tier, average strength, active/decaying/archived counts). This clearly distinguishes the tool from siblings like decay, save, search, and touch, which perform different actions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no explicit guidance on when to use this tool versus alternatives. It implies an overview function but does not state when to prefer stats over search or other sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Y-Sky-bro/nexus-memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server