Skip to main content
Glama
stat-guy

Chain of Draft (CoD) MCP Server

by stat-guy

analyze_problem_complexity

Analyze problem complexity to determine difficulty level and required resources for effective solution planning.

Instructions

Analyze the complexity of a problem

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
problemYesThe problem to analyze
domainNoProblem domain

Implementation Reference

  • Primary handler function for the 'analyze_problem_complexity' tool in the Python FastMCP server. Decorated with @app.tool() for automatic registration and schema inference. Delegates to complexity_estimator for analysis.
    @app.tool()
    async def analyze_problem_complexity(
        problem: str,
        domain: str = "general"
    ) -> str:
        """Analyze the complexity of a problem.
        
        Args:
            problem: The problem to analyze
            domain: Problem domain
        """
        analysis = complexity_estimator.analyze_problem(problem, domain)
        
        result = f"Complexity Analysis for {domain} problem:\n\n"
        result += f"Word count: {analysis['word_count']}\n"
        result += f"Sentence count: {analysis['sentence_count']}\n"
        result += f"Words per sentence: {analysis['words_per_sentence']:.1f}\n"
        result += f"Complexity indicators found: {analysis['indicator_count']}\n"
        
        if analysis['found_indicators']:
            result += f"Indicators: {', '.join(analysis['found_indicators'])}\n"
        
        result += f"Question count: {analysis['question_count']}\n"
        result += f"\nEstimated complexity score: {analysis['estimated_complexity']}\n"
        result += f"Recommended word limit per step: {analysis['estimated_complexity']}\n"
        
        return result
  • Core helper method performing detailed problem complexity analysis, computing metrics like word count, indicators, sentences, and estimated complexity score. Called by the handler.
    def analyze_problem(self, problem, domain="general"):
        """
        Provide a detailed analysis of problem complexity factors.
        Useful for debugging and understanding complexity estimates.
        """
        base_limit = self.domain_base_limits.get(domain.lower(), 5)
        
        # Word count analysis
        word_count = len(problem.split())
        length_factor = min(word_count / 50, 2)
        
        # Indicator analysis
        indicators = self.complexity_indicators.get(domain.lower(), [])
        found_indicators = [ind for ind in indicators if ind.lower() in problem.lower()]
        indicator_count = len(found_indicators)
        indicator_factor = min(1 + (indicator_count * 0.2), 1.8)
        
        # Question mark analysis
        question_count = problem.count("?")
        question_factor = 1 + (question_count * 0.2)
        
        # Sentence complexity
        sentences = [s for s in problem.split(".") if s.strip()]
        words_per_sentence = word_count / max(len(sentences), 1)
        sentence_complexity_factor = min(words_per_sentence / 15, 1.5)
        
        return {
            "domain": domain,
            "base_limit": base_limit,
            "word_count": word_count,
            "length_factor": length_factor,
            "indicator_count": indicator_count,
            "found_indicators": found_indicators,
            "indicator_factor": indicator_factor,
            "question_count": question_count,
            "question_factor": question_factor,
            "sentence_count": len(sentences),
            "words_per_sentence": words_per_sentence,
            "sentence_complexity_factor": sentence_complexity_factor,
            "estimated_complexity": max(3, min(round(base_limit * max(length_factor, indicator_factor, question_factor, sentence_complexity_factor)), 10))
        }
  • Tool schema definition in JavaScript MCP server, specifying input parameters and descriptions for tool discovery.
    const COMPLEXITY_TOOL = {
      name: "analyze_problem_complexity",
      description: "Analyze the complexity of a problem",
      inputSchema: {
        type: "object",
        properties: {
          problem: {
            type: "string",
            description: "The problem to analyze"
          },
          domain: {
            type: "string",
            description: "Problem domain"
          }
        },
        required: ["problem"]
      }
    };
  • Handler implementation in JavaScript MCP server for dispatching and executing the tool using inline complexityEstimator.
    // Complexity analysis
    if (name === "analyze_problem_complexity") {
      const analysis = complexityEstimator.analyzeProblem(args.problem, args.domain || "general");
      
      let result = `Complexity Analysis for ${args.domain || "general"} problem:\n\n`;
      result += `Word count: ${analysis.word_count}\n`;
      result += `Sentence count: ${analysis.sentence_count}\n`;
      result += `Words per sentence: ${analysis.words_per_sentence.toFixed(1)}\n`;
      result += `Complexity indicators found: ${analysis.indicator_count}\n`;
      
      if (analysis.found_indicators && analysis.found_indicators.length > 0) {
        result += `Indicators: ${analysis.found_indicators.join(", ")}\n`;
      }
      
      result += `Question count: ${analysis.question_count}\n`;
      result += `\nEstimated complexity score: ${analysis.estimated_complexity}\n`;
      result += `Recommended word limit per step: ${analysis.estimated_complexity}\n`;
      
      return {
        content: [{
          type: "text",
          text: result
        }]
      };
  • Inline helper object in JS with analyzeProblem method mirroring the Python ComplexityEstimator, providing core analysis logic.
    const complexityEstimator = {
      domainBaseLimits: {
        math: 6,
        logic: 5,
        common_sense: 4,
        physics: 7,
        chemistry: 6,
        biology: 5,
        code: 8,
        puzzle: 5,
        general: 5
      },
      complexityIndicators: {
        math: ['integral', 'derivative', 'equation', 'theorem', 'calculus', 'polynomial', 'algorithm'],
        logic: ['if-then', 'premise', 'fallacy', 'syllogism', 'deduction', 'induction'],
        physics: ['velocity', 'acceleration', 'quantum', 'momentum', 'thermodynamics'],
        code: ['function', 'algorithm', 'recursive', 'complexity', 'optimization', 'edge case']
      },
      analyzeProblem: function(problem, domain) {
        const wordCount = problem.split(/\s+/).filter(Boolean).length;
        const sentences = problem.split(/[.!?]+/).filter(Boolean);
        const sentenceCount = sentences.length;
        const wordsPerSentence = sentenceCount > 0 ? wordCount / sentenceCount : 0;
        
        // Count indicators
        const indicators = this.complexityIndicators[domain] || this.complexityIndicators.general || [];
        const lowerProblem = problem.toLowerCase();
        const foundIndicators = indicators.filter(i => lowerProblem.includes(i.toLowerCase()));
        
        // Count questions
        const questionCount = (problem.match(/\?/g) || []).length;
        
        // Estimate complexity
        let complexity = this.domainBaseLimits[domain] || this.domainBaseLimits.general;
        
        // Adjust for length
        if (wordCount > 100) complexity += 2;
        else if (wordCount > 50) complexity += 1;
        
        // Adjust for sentences
        if (wordsPerSentence > 20) complexity += 1;
        
        // Adjust for indicators
        complexity += Math.min(3, foundIndicators.length);
        
        // Adjust for questions
        complexity += Math.min(2, questionCount);
        
        return {
          word_count: wordCount,
          sentence_count: sentenceCount,
          words_per_sentence: wordsPerSentence,
          indicator_count: foundIndicators.length,
          found_indicators: foundIndicators,
          question_count: questionCount,
          estimated_complexity: complexity
        };
      }
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. It doesn't disclose behavioral traits such as whether this is a read-only analysis, if it requires specific inputs beyond the schema, what the output format might be, or any rate limits. The description is too minimal to offer meaningful context beyond the basic action.

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, efficient sentence with no wasted words, making it front-loaded and easy to parse. However, it's so brief that it under-specifies the tool's purpose, slightly reducing its effectiveness despite the conciseness.

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 the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'analyze' entails, what results to expect, or how it fits with sibling tools. For a tool with 2 parameters and no structured behavioral hints, more context is needed to guide an agent effectively.

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?

The input schema has 100% description coverage, with clear documentation for both parameters ('problem' and 'domain'). The description doesn't add any meaning beyond what the schema provides, such as explaining how 'domain' influences the analysis. Since schema coverage is high, the baseline score of 3 is appropriate.

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

Purpose3/5

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

The description 'Analyze the complexity of a problem' states a vague purpose with the verb 'analyze' and resource 'complexity of a problem', but it doesn't specify what complexity means (e.g., computational, conceptual, time) or how it differs from siblings like 'logic_solve' or 'math_solve'. It's not tautological but lacks specificity.

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 is provided on when to use this tool versus alternatives. The description doesn't mention context, prerequisites, or exclusions, and with siblings like 'logic_solve' or 'code_solve' that might handle related tasks, there's no differentiation to help an agent choose appropriately.

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/stat-guy/chain-of-draft'

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