Skip to main content
Glama
tools.ts1.78 kB
import { FastMCP } from "fastmcp"; import { ExtendedThinkSchema } from "../agents/BasicAgent.js"; /** * Register thinking tools with the server * * @param server FastMCP server instance */ export function registerThinkTools(server: FastMCP): void { server.addTool({ name: "think", description: "Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed. Consider including: problem definition, relevant context, analysis steps, self-reflection on your reasoning, and conclusions. Adapt this structure as needed for your specific thought process.", parameters: ExtendedThinkSchema, execute: async (params: any) => { const { structuredReasoning, selfReflect = false } = params; // Step counter logic // Initialize or estimate plannedSteps if not provided if (!params.plannedSteps) { // Roughly estimate based on content length const contentLength = structuredReasoning.length; params.plannedSteps = Math.max(1, Math.min(5, Math.ceil(contentLength / 300))); } // Initialize currentStep if not provided if (!params.currentStep) { params.currentStep = 1; } else { // Increment the current step params.currentStep += 1; } // Ensure current step doesn't exceed planned steps params.currentStep = Math.min(params.currentStep, params.plannedSteps); // Format output with step counter return `# Structured Reasoning (Step ${params.currentStep} of ${params.plannedSteps})\n\n${structuredReasoning}\n\n(Step ${params.currentStep} of ${params.plannedSteps})`; } }); }

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/flight505/mcp-think-tank'

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