Skip to main content
Glama
arjshiv

Local Utilities MCP Server

by arjshiv

get_thought_stats

Retrieves summary statistics about recorded thoughts, including counts and aggregated data.

Instructions

Get statistics about recorded thoughts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual handler function for the get_thought_stats tool. It computes statistics (totalThoughts, averageLength, oldestThought, newestThought) from the in-memory thoughts array and returns them as JSON.
    // Register get_thought_stats command
    server.tool(
      "get_thought_stats",
      "Get statistics about recorded thoughts",
      async () => {
        const totalThoughts = thoughts.length;
        let statsData; // Renamed to avoid conflict with exported interface
    
        if (totalThoughts === 0) {
          statsData = {
            totalThoughts: 0,
            averageLength: 0,
            oldestThought: null,
            newestThought: null
          };
        } else {
          const averageLength = thoughts.reduce((acc, thought) =>
            acc + thought.content.length, 0) / totalThoughts;
          statsData = {
            totalThoughts,
            averageLength: parseFloat(averageLength.toFixed(2)),
            oldestThought: thoughts[0].timestamp,
            newestThought: thoughts[thoughts.length - 1].timestamp
          };
        }
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(statsData, null, 2)
          }]
        };
      }
    );
  • Registration of the get_thought_stats tool via server.tool() call inside registerThinkTool(). The tool is registered with description 'Get statistics about recorded thoughts' and no required input schema.
    // Register get_thought_stats command
    server.tool(
      "get_thought_stats",
      "Get statistics about recorded thoughts",
      async () => {
        const totalThoughts = thoughts.length;
        let statsData; // Renamed to avoid conflict with exported interface
    
        if (totalThoughts === 0) {
          statsData = {
            totalThoughts: 0,
            averageLength: 0,
            oldestThought: null,
            newestThought: null
          };
        } else {
          const averageLength = thoughts.reduce((acc, thought) =>
            acc + thought.content.length, 0) / totalThoughts;
          statsData = {
            totalThoughts,
            averageLength: parseFloat(averageLength.toFixed(2)),
            oldestThought: thoughts[0].timestamp,
            newestThought: thoughts[thoughts.length - 1].timestamp
          };
        }
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(statsData, null, 2)
          }]
        };
      }
    );
  • ThoughtStats interface defining the shape of the return value: totalThoughts (number), averageLength (number), oldestThought (string|null), newestThought (string|null).
    export interface ThoughtStats {
      [key: string]: number | string | null;
      totalThoughts: number;
      averageLength: number;
      oldestThought: string | null;
      newestThought: string | null;
    }
  • getThoughtStats() method on ThinkToolInternalLogic class - a helper that computes the same stats, used by the exported class but separate from the closure-based handler in registerThinkTool().
    getThoughtStats(): ThoughtStats {
      const totalThoughts = this.thoughts.length;
      
      if (totalThoughts === 0) {
        return {
          totalThoughts: 0,
          averageLength: 0,
          oldestThought: null,
          newestThought: null
        };
      }
    
      const averageLength = this.thoughts.reduce((acc, thought) => 
        acc + thought.content.length, 0) / totalThoughts;
    
      return {
        totalThoughts,
        averageLength: parseFloat(averageLength.toFixed(2)), // Keep formatted
        oldestThought: this.thoughts[0].timestamp,
        newestThought: this.thoughts[this.thoughts.length - 1].timestamp
      };
    }
  • src/index.ts:10-10 (registration)
    Import of registerThinkTool from './mcp/think.js' in the main entry point.
    import { registerThinkTool } from "./mcp/think.js";
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. 'Get statistics' implies a read operation with no side effects, but it does not disclose behavior for edge cases (e.g., empty thought list), performance implications, or whether it modifies any state. Minimal behavioral info.

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

Conciseness3/5

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

The description is a single sentence, which is concise but lacks detail. It could be more informative without being verbose, e.g., specifying 'count, average, etc.'. Still, it is front-loaded and avoids redundancy.

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 that there is no output schema and no annotations, the description is incomplete. It does not clarify what statistics are returned (e.g., count of thoughts, time range, average length). For a tool with no parameters, the description should provide a clearer picture of the output.

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?

With zero parameters, the input schema is fully covered. The description adds no parameter-specific meaning, but according to rules, baseline for 0 params is 4. No information is missing about parameters.

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?

Description clearly states 'Get statistics about recorded thoughts', which is a verb+resource pattern. It distinguishes from siblings like 'get_thoughts' (which likely returns the full list) and 'think' (which creates a thought). However, it remains vague about what specific statistics are returned (e.g., count, frequency).

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?

No guidance on when to use this tool versus alternatives. It does not mention that it provides summary data compared to 'get_thoughts' listing all thoughts, nor does it suggest prerequisites like 'think' first. The description is purely declarative.

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/arjshiv/localutils-mcp-server'

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