analyze_problem_complexity
Evaluate problem complexity by analyzing its structure and domain, facilitating efficient reasoning with minimal token usage through the Chain of Draft approach.
Instructions
Analyze the complexity of a problem
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | Problem domain | |
| problem | Yes | The problem to analyze |
Implementation Reference
- server.py:189-215 (handler)Python FastMCP tool handler for analyze_problem_complexity: decorated function that calls complexity_estimator.analyze_problem and formats the analysis result.@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
- index.js:739-762 (handler)JavaScript MCP server tool handler for analyze_problem_complexity: if-branch in CallToolRequestSchema handler that calls complexityEstimator.analyzeProblem and formats the result.// 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 }] };
- index.js:551-568 (schema)Tool schema definition in JS MCP server, including name, description, and inputSchema for analyze_problem_complexity.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"] } };
- complexity.py:108-148 (helper)Core helper method in ComplexityEstimator class that performs detailed problem complexity analysis, returning metrics used by the tool handlers.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)) }