Skip to main content
Glama

get_thought_stats

Analyze and generate statistics for recorded thoughts, including count and depth distribution. Filter results by specific categories to gain targeted insights into thought patterns.

Instructions

Get statistics about recorded thoughts.

This tool provides statistics about recorded thoughts, such as count and depth distribution. Results can be filtered by category.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter to get stats for a specific category

Implementation Reference

  • Primary FastMCP handler for the 'get_thought_stats' tool. Defines input schema using Pydantic Field (optional category filter), calls the core implementation, and returns JSON-formatted stats.
    @mcp.tool()
    def get_thought_stats(
        category: Optional[str] = Field(
            description="Filter to get stats for a specific category", default=None
        ),
    ) -> str:
        """
        Get statistics about recorded thoughts.
    
        This tool provides statistics about recorded thoughts, such as count and
        depth distribution. Results can be filtered by category.
        """
        # Extract actual value if it's a Field object
        if hasattr(category, "default"):
            category = category.default
    
        result = get_thought_stats_impl(category)
        return json.dumps(result, indent=2)
  • Core implementation of get_thought_stats logic: filters thoughts by category, computes total count, length of longest thought, and its 1-based index.
    def get_thought_stats(category: Optional[str] = None) -> Dict[str, Any]:
        """Get statistics about recorded thoughts."""
        thoughts = _storage.get_thoughts()
    
        if category:
            thoughts = [t for t in thoughts if t.get("category") == category]
    
        if not thoughts:
            return {
                "success": True,
                "message": "No thoughts have been recorded yet",
                "stats": {"total_thoughts": 0, "longest_thought_length": 0, "longest_thought_index": 0},
            }
    
        # Find longest thought
        longest_idx = 0
        longest_len = 0
        for i, t in enumerate(thoughts):
            thought_len = len(t["thought"])
            if thought_len > longest_len:
                longest_len = thought_len
                longest_idx = i + 1  # 1-based indexing
    
        return {
            "success": True,
            "message": "Retrieved statistics",
            "stats": {
                "total_thoughts": len(thoughts),
                "longest_thought_length": longest_len,
                "longest_thought_index": longest_idx,
            },
        }
  • ThoughtStorage class and global _storage instance used by get_thought_stats to access stored thoughts.
    class ThoughtStorage:
        def __init__(self):
            self._storage_file = None
            self._thoughts = []
            self._init_storage()
    
        def _init_storage(self):
            """Initialize temporary file for thought storage."""
            temp = tempfile.NamedTemporaryFile(prefix="mcp_thoughts_", suffix=".tmp", delete=False)
            self._storage_file = temp.name
            temp.close()
            logger.debug(f"Initialized thought storage using temporary file: {self._storage_file}")
    
        def add_thought(self, thought: Dict[str, Any]):
            """Add a thought to storage."""
            self._thoughts.append(thought)
            self._save()
    
        def get_thoughts(self) -> List[Dict[str, Any]]:
            """Get all stored thoughts."""
            return self._thoughts
    
        def clear_thoughts(self, category: Optional[str] = None):
            """Clear stored thoughts, optionally by category."""
            if category:
                self._thoughts = [t for t in self._thoughts if t.get("category") != category]
            else:
                self._thoughts = []
            self._save()
    
        def _save(self):
            """Save thoughts to storage file."""
            with open(self._storage_file, "w") as f:
                json.dump(self._thoughts, f)
    
    
    # Global storage instance
  • Import of the core get_thought_stats implementation for use in the FastMCP tool handler.
    from .think_tool import get_thought_stats as get_thought_stats_impl
  • Registration/dispatching of 'get-thought-stats' tool in the package's call_tool function.
    elif fastmcp_tool_name == "get-thought-stats":
        result = get_thought_stats()
Behavior2/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 of behavioral disclosure. It states the tool provides statistics but doesn't describe what the output looks like (e.g., format, structure), whether it's read-only (implied by 'get'), or any performance considerations like rate limits. This leaves significant gaps for a tool with no output schema.

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

Conciseness4/5

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

The description is concise and front-loaded, with the core purpose in the first sentence and additional details in the second. Both sentences earn their place by clarifying scope and functionality. However, it could be slightly more structured by explicitly separating purpose from usage notes.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what statistics are returned (beyond 'count and depth distribution'), how results are formatted, or any behavioral traits. For a tool with no structured output documentation, this leaves too much ambiguity for effective agent use.

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

Parameters3/5

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

Schema description coverage is 100%, with the single parameter 'category' well-documented in the schema. The description adds minimal value beyond the schema by mentioning 'Results can be filtered by category,' which aligns with the schema's description. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get statistics about recorded thoughts' with specific examples ('such as count and depth distribution'). It distinguishes itself from sibling tools like 'get_thoughts' (which likely retrieves the thoughts themselves) by focusing on statistical analysis. However, it doesn't explicitly contrast with all siblings, so it doesn't reach the highest score.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'Results can be filtered by category,' suggesting this tool is for statistical analysis rather than raw data retrieval. However, it doesn't provide explicit guidance on when to use this versus alternatives like 'get_thoughts' or 'detect_thinking_directive,' nor does it specify prerequisites or exclusions.

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

Related 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/smian0/mcp-agile-flow'

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