configure
Set research parameters including loop count, AI model selection, and search API configuration for in-depth topic investigation.
Instructions
Configure the research parameters (max loops, LLM model, search API)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxLoops | No | Maximum number of research loops (1-10) | |
| llmModel | No | Ollama model to use (e.g. llama3.2) | |
| searchApi | No | Search API to use for web research |
Implementation Reference
- src/index.ts:330-394 (handler)The handler function for the 'configure' tool. It processes input arguments to update the global research configuration (maxLoops, llmModel, searchApi) with validation, or returns the current configuration if no arguments provided.case "configure": { const newConfig = request.params.arguments; let configMessage = ''; if (newConfig && Object.keys(newConfig).length > 0) { try { // Validate new configuration if (newConfig.maxLoops !== undefined) { if (typeof newConfig.maxLoops !== 'number' || newConfig.maxLoops < 1 || newConfig.maxLoops > 10) { throw new Error("maxLoops must be a number between 1 and 10"); } } if (newConfig.searchApi !== undefined) { if (newConfig.searchApi !== 'perplexity' && newConfig.searchApi !== 'tavily' && newConfig.searchApi !== 'exa') { throw new Error("searchApi must be 'perplexity', 'tavily', or 'exa'"); } // Validate API key for new search API validateApiKeys(newConfig.searchApi); } // Type guard to ensure properties match ResearchConfig const validatedConfig: Partial<ResearchConfig> = {}; if (typeof newConfig.maxLoops === 'number') { validatedConfig.maxLoops = newConfig.maxLoops; } if (typeof newConfig.llmModel === 'string') { validatedConfig.llmModel = newConfig.llmModel; } if (newConfig.searchApi === 'perplexity' || newConfig.searchApi === 'tavily' || newConfig.searchApi === 'exa') { validatedConfig.searchApi = newConfig.searchApi; } config = { ...config, ...validatedConfig }; configMessage = 'Research configuration updated:'; } catch (error) { return { content: [ { type: "text", text: `Configuration error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } else { configMessage = 'Current research configuration:'; } return { content: [ { type: "text", text: `${configMessage} Max Loops: ${config.maxLoops} LLM Model: ${config.llmModel} Search API: ${config.searchApi}`, }, ], }; }
- src/index.ts:129-150 (registration)The tool registration in the ListTools handler, defining the name, description, and input schema for the 'configure' tool. This makes the tool available to MCP clients.name: "configure", description: "Configure the research parameters (max loops, LLM model, search API)", inputSchema: { type: "object", properties: { maxLoops: { type: "number", description: "Maximum number of research loops (1-10)" }, llmModel: { type: "string", description: "Ollama model to use (e.g. llama3.2)" }, searchApi: { type: "string", enum: ["perplexity", "tavily", "exa"], description: "Search API to use for web research" } }, required: [], }, },
- src/index.ts:131-149 (schema)The input schema defining the parameters for configuring research: maxLoops (number), llmModel (string), searchApi (enum). No required fields, allowing partial updates.inputSchema: { type: "object", properties: { maxLoops: { type: "number", description: "Maximum number of research loops (1-10)" }, llmModel: { type: "string", description: "Ollama model to use (e.g. llama3.2)" }, searchApi: { type: "string", enum: ["perplexity", "tavily", "exa"], description: "Search API to use for web research" } }, required: [], },
- src/index.ts:65-75 (helper)Helper function validateApiKeys used in the configure handler to ensure the required API key is set for the selected searchApi.function validateApiKeys(searchApi: string): void { if (searchApi === "tavily" && !process.env.TAVILY_API_KEY) { throw new Error("TAVILY_API_KEY is required when using Tavily search API"); } if (searchApi === "perplexity" && !process.env.PERPLEXITY_API_KEY) { throw new Error("PERPLEXITY_API_KEY is required when using Perplexity search API"); } if (searchApi === "exa" && !process.env.EXA_API_KEY) { throw new Error("EXA_API_KEY is required when using Exa search API"); } }
- src/index.ts:52-56 (schema)Type definition for the ResearchConfig interface used to type the global config state and validate tool inputs.interface ResearchConfig { maxLoops: number; llmModel: string; searchApi: "perplexity" | "tavily" | "exa"; }