Skip to main content
Glama
malaksedarous

Context Optimizer MCP Server

researchTopic

Use Exa.ai to research software development topics. Provide a detailed research question or problem to get current information and practical implementation guidance.

Instructions

Conduct quick, focused web research on software development topics using Exa.ai's powerful research capabilities for current information and practical implementation guidance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYesThe research topic or problem you want to investigate. Be as detailed as possible about what you want to learn, any specific aspects to focus on, timeframes, geographical scope, or particular angles of interest.

Implementation Reference

  • The execute() method of ResearchTopicTool - validates input, checks API key config, calls conductQuickResearch(), and returns the result.
    async execute(args: any): Promise<MCPToolResponse> {
      try {
        // Validate input
        const validationError = this.validateRequiredFields(args, ['topic']);
        if (validationError) {
          return this.createErrorResponse(validationError);
        }
    
        const input = args as ResearchTopicInput;
        
        // Validate topic is not empty
        if (!input.topic.trim()) {
          return this.createErrorResponse('Topic cannot be empty');
        }
    
        // Get configuration
        const config = ConfigurationManager.getConfig();
        if (!config.research.exaKey) {
          return this.createErrorResponse(
            'Exa.ai API key is not configured. Please set the exaKey in your configuration or EXA_KEY environment variable.'
          );
        }
    
        this.logOperation(`Starting quick research for topic: ${input.topic}`);
    
        // Conduct research
        const result = await this.conductQuickResearch(input.topic, config.research.exaKey);
        
        this.logOperation('Quick research completed successfully');
    
        return this.createSuccessResponse(result.result);
    
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        this.logOperation(`Research failed: ${errorMessage}`);
        return this.createErrorResponse(`Research failed: ${errorMessage}`);
      }
    }
  • The private conductQuickResearch() method - creates an Exa research task with the topic, polls for completion, and formats the response.
    private async conductQuickResearch(topic: string, exaKey: string): Promise<ExaResponse> {
      const client = new Exa(exaKey);
    
      try {
        const schema = {
          type: 'object' as const,
          properties: {
            result: { type: 'string' as const }
          },
          required: ['result'],
          description: 'Schema with just the result in markdown.'
        };
    
        if (!client?.research || typeof (client as any).research.create !== 'function') {
          throw new Error('Exa.js research client missing create() method');
        }
        const research: any = (client as any).research;
    
        this.logOperation('Creating Exa research task');
    const task = await research.create({
          instructions: topic,
          model: RESEARCH_CONFIG.QUICK_RESEARCH.MODEL,
          output: { schema },
        });
    
        this.logOperation(`Task created with ID: ${task.id}. Polling for results...`);
        const result = await this.pollTaskWithFallback(
          client, 
          task.id, 
          RESEARCH_CONFIG.QUICK_RESEARCH.MAX_ATTEMPTS,
          RESEARCH_CONFIG.QUICK_RESEARCH.POLL_INTERVAL_MS,
          RESEARCH_CONFIG.QUICK_RESEARCH.TIMEOUT_MS
        );
        
        return this.formatResponse(result);
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Failed to conduct research with Exa.ai.';
        throw new Error(`Exa.ai research failed: ${errorMessage}`);
      }
    }
  • src/server.ts:60-66 (registration)
    Registration of ResearchTopicTool in setupTools() - instantiates and stores in the tools map.
    private setupTools(): void {
      const toolInstances = [
        new AskAboutFileTool(),
        new RunAndExtractTool(),
        new AskFollowUpTool(),
        new ResearchTopicTool(),
        new DeepResearchTool()
  • ResearchTopicInput interface and inputSchema definition - defines the 'topic' string parameter (required).
    interface ResearchTopicInput {
      topic: string;
    }
    
    export class ResearchTopicTool extends BaseResearchTool {
      readonly name = 'researchTopic';
      readonly description = 'Conduct quick, focused web research on software development topics using Exa.ai\'s powerful research capabilities for current information and practical implementation guidance.';
    
      readonly inputSchema = {
        type: 'object' as const,
        properties: {
          topic: {
            type: 'string' as const,
            description: 'The research topic or problem you want to investigate. Be as detailed as possible about what you want to learn, any specific aspects to focus on, timeframes, geographical scope, or particular angles of interest.'
          }
        },
        required: ['topic']
      };
  • BaseResearchTool abstract class - provides pollTask(), formatResponse(), and pollTaskWithFallback() helper methods used by ResearchTopicTool.
    export abstract class BaseResearchTool extends BaseMCPTool {
      /**
       * Poll an Exa research task until completion or timeout
       */
      protected async pollTask(client: Exa, taskId: string, maxAttempts: number, pollIntervalMs: number, timeoutMs: number): Promise<ExaTask> {
        let attempts = 0;
        const research: any = (client as any).research;
        if (!research || typeof research.get !== 'function') {
          throw new Error('Exa research client does not expose get() to fetch task status.');
        }
    
        while (attempts < maxAttempts) {
          const task = await research.get(taskId);
          
          if (task.status === 'completed') {
            this.logOperation('Research task completed');
            return task;
          }
          
          if (task.status === 'failed') {
            throw new Error('Research task failed');
          }
          
          if (task.status === 'running' || task.status === 'pending') {
            this.logOperation(`Task status: ${task.status}... (${attempts * pollIntervalMs / 1000}s elapsed)`);
            await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
            attempts++;
          } else {
            // Unexpected status
            throw new Error(`Unexpected task status: ${task.status}`);
          }
        }
        
        // Timeout after configured duration
        throw new Error(`Research task timed out after ${timeoutMs / 1000} seconds`);
      }
    
      /**
       * Format the Exa task result into a standardized response
       */
      protected formatResponse(result: ExaTask): ExaResponse {
        if (!result?.data?.result) {
          throw new Error('Malformed response from Exa.ai - missing result data');
        }
        return {
          result: result.data.result,
          raw: result,
        };
      }
    
      /**
       * Check if the Exa client has a built-in pollTask method and use it, 
       * otherwise fall back to our implementation
       */
      protected async pollTaskWithFallback(
        client: Exa, 
        taskId: string, 
        maxAttempts: number, 
        pollIntervalMs: number, 
        timeoutMs: number
      ): Promise<ExaTask> {
      // Prefer SDK-provided poller; else fall back to local polling using get()
        const research: any = (client as any).research;
        if (research) {
          if (typeof research.pollUntilFinished === 'function') {
            return await research.pollUntilFinished(taskId);
          }
        }
        return await this.pollTask(client, taskId, maxAttempts, pollIntervalMs, timeoutMs);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only mentions using Exa.ai's capabilities and returning 'current information and practical implementation guidance'. It does not disclose behavioral traits like rate limits, result format, or any constraints.

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 a single sentence of 20 words, concise and front-loaded with the core purpose. It avoids fluff but could include usage guidance without much increase in length.

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

Completeness3/5

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

For a simple tool with one parameter and no output schema, the description is minimally adequate. However, it lacks differentiation from sibling tools and does not address behavioral aspects, leaving gaps for an AI agent to infer.

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%, so the parameter is already well-documented in the schema. The tool description adds no additional meaning or context beyond what the schema provides.

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

Purpose5/5

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

The description clearly states the verb ('conduct'), resource ('web research using Exa.ai'), and scope ('software development topics'). It effectively distinguishes from sibling tools like deepResearch by specifying 'quick, focused' research.

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 explicit guidance on when to use this tool versus alternatives like deepResearch or askFollowUp. The description does not specify when not to use it or provide context for choosing among siblings.

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/malaksedarous/context-optimizer-mcp-server'

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