think
Record a thought by providing the content as a string. This tool captures and stores your ideas.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thought | Yes | The thought content to record |
Implementation Reference
- src/mcp/think.ts:70-81 (handler)The actual handler for the 'think' tool - records a thought into internal state and returns a success message.
async ({ thought }) => { thoughts.push({ timestamp: new Date().toISOString(), content: thought }); return { content: [{ type: "text", text: "Thought recorded successfully" }] }; } - src/mcp/think.ts:67-69 (schema)The 'think' tool's schema registration with Zod validation - requires a non-empty 'thought' string parameter.
server.tool( "think", { thought: z.string().min(1, "Thought cannot be empty").describe("The thought content to record") }, - src/mcp/think.ts:62-148 (registration)The registerThinkTool function that registers the 'think' tool (plus get_thoughts, clear_thoughts, get_thought_stats) on the MCP server.
export function registerThinkTool(server: McpServer) { // Use closure state, but keep the class exported for the old test let thoughts: Thought[] = []; // Register think command server.tool( "think", { thought: z.string().min(1, "Thought cannot be empty").describe("The thought content to record") }, async ({ thought }) => { thoughts.push({ timestamp: new Date().toISOString(), content: thought }); return { content: [{ type: "text", text: "Thought recorded successfully" }] }; } ); // Register get_thoughts command server.tool( "get_thoughts", "Retrieve all recorded thoughts", async () => { const currentThoughts = [...thoughts]; return { content: [{ type: "text", text: JSON.stringify(currentThoughts, null, 2) }] }; } ); // Register clear_thoughts command server.tool( "clear_thoughts", "Clear all recorded thoughts", async () => { const count = thoughts.length; thoughts = []; // Reset the array return { content: [{ type: "text", text: `Cleared ${count} recorded thoughts.` }] }; } ); // 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) }] }; } ); - src/index.ts:10-25 (registration)Import and invocation of registerThinkTool in the main entry point, wiring the tool into the server.
import { registerThinkTool } from "./mcp/think.js"; // Create an MCP server const server = new McpServer({ name: "Local Utilities MCP Server", version: "1.0.0" }); // Register all utilities registerHostnameTool(server); registerPublicIpTool(server); registerDirectoryTool(server); registerNodeVersionTool(server); registerPortCheckerTool(server); registerTimeTool(server); registerThinkTool(server); - src/mcp/think.ts:20-60 (helper)ThinkToolInternalLogic class with helper methods (addThought, getAllThoughts, clearThoughts, getThoughtStats) for managing thoughts internally.
export class ThinkToolInternalLogic { thoughts: Thought[] = []; // Make public for test access if needed, or add methods addThought(content: string): void { this.thoughts.push({ timestamp: new Date().toISOString(), content }); } getAllThoughts(): Thought[] { return [...this.thoughts]; } clearThoughts(): void { this.thoughts = []; } 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 }; } }