Files
my-pal-mcp-server/tools/think_deeper.py
Fahad 1aa19548d1 feat: complete redesign to v2.4.0 - Claude's ultimate development partner
Major redesign of Gemini MCP Server with modular architecture:

- Removed all emoji characters from tool outputs for clean terminal display
- Kept review category emojis (🔴🟠🟡🟢) per user preference
- Added 4 specialized tools:
  - think_deeper: Extended reasoning and problem-solving (temp 0.7)
  - review_code: Professional code review with severity levels (temp 0.2)
  - debug_issue: Root cause analysis and debugging (temp 0.2)
  - analyze: General-purpose file analysis (temp 0.2)
- Modular architecture with base tool class and Pydantic models
- Verbose tool descriptions with natural language triggers
- Updated README with comprehensive examples and real-world use cases
- All 25 tests passing, type checking clean, critical linting clean

BREAKING CHANGE: Removed analyze_code tool in favor of specialized tools

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-08 22:30:45 +04:00

146 lines
5.3 KiB
Python

"""
Think Deeper tool - Extended reasoning and problem-solving
"""
from typing import Dict, Any, List, Optional
from pydantic import Field
from .base import BaseTool, ToolRequest
from prompts import THINK_DEEPER_PROMPT
from utils import read_files, check_token_limit
from config import TEMPERATURE_CREATIVE, MAX_CONTEXT_TOKENS
class ThinkDeeperRequest(ToolRequest):
"""Request model for think_deeper tool"""
current_analysis: str = Field(
..., description="Claude's current thinking/analysis to extend"
)
problem_context: Optional[str] = Field(
None, description="Additional context about the problem or goal"
)
focus_areas: Optional[List[str]] = Field(
None,
description="Specific aspects to focus on (architecture, performance, security, etc.)",
)
reference_files: Optional[List[str]] = Field(
None, description="Optional file paths for additional context"
)
class ThinkDeeperTool(BaseTool):
"""Extended thinking and reasoning tool"""
def get_name(self) -> str:
return "think_deeper"
def get_description(self) -> str:
return (
"EXTENDED THINKING & REASONING - Your deep thinking partner for complex problems. "
"Use this when you need to extend your analysis, explore alternatives, or validate approaches. "
"Perfect for: architecture decisions, complex bugs, performance challenges, security analysis. "
"Triggers: 'think deeper', 'ultrathink', 'extend my analysis', 'explore alternatives'. "
"I'll challenge assumptions, find edge cases, and provide alternative solutions."
)
def get_input_schema(self) -> Dict[str, Any]:
return {
"type": "object",
"properties": {
"current_analysis": {
"type": "string",
"description": "Your current thinking/analysis to extend and validate",
},
"problem_context": {
"type": "string",
"description": "Additional context about the problem or goal",
},
"focus_areas": {
"type": "array",
"items": {"type": "string"},
"description": "Specific aspects to focus on (architecture, performance, security, etc.)",
},
"reference_files": {
"type": "array",
"items": {"type": "string"},
"description": "Optional file paths for additional context",
},
"temperature": {
"type": "number",
"description": "Temperature for creative thinking (0-1, default 0.7)",
"minimum": 0,
"maximum": 1,
},
"max_tokens": {
"type": "integer",
"description": "Maximum tokens in response",
"default": 8192,
},
},
"required": ["current_analysis"],
}
def get_system_prompt(self) -> str:
return THINK_DEEPER_PROMPT
def get_default_temperature(self) -> float:
return TEMPERATURE_CREATIVE
def get_request_model(self):
return ThinkDeeperRequest
async def prepare_prompt(self, request: ThinkDeeperRequest) -> str:
"""Prepare the full prompt for extended thinking"""
# Build context parts
context_parts = [
f"=== CLAUDE'S CURRENT ANALYSIS ===\n{request.current_analysis}\n=== END ANALYSIS ==="
]
if request.problem_context:
context_parts.append(
f"\n=== PROBLEM CONTEXT ===\n{request.problem_context}\n=== END CONTEXT ==="
)
# Add reference files if provided
if request.reference_files:
file_content, _ = read_files(request.reference_files)
context_parts.append(
f"\n=== REFERENCE FILES ===\n{file_content}\n=== END FILES ==="
)
full_context = "\n".join(context_parts)
# Check token limits
within_limit, estimated_tokens = check_token_limit(full_context)
if not within_limit:
raise ValueError(
f"Context too large (~{estimated_tokens:,} tokens). "
f"Maximum is {MAX_CONTEXT_TOKENS:,} tokens."
)
# Add focus areas instruction if specified
focus_instruction = ""
if request.focus_areas:
areas = ", ".join(request.focus_areas)
focus_instruction = f"\n\nFOCUS AREAS: Please pay special attention to {areas} aspects."
# Combine system prompt with context
full_prompt = f"""{self.get_system_prompt()}{focus_instruction}
{full_context}
Please provide deep analysis that extends Claude's thinking with:
1. Alternative approaches and solutions
2. Edge cases and potential failure modes
3. Critical evaluation of assumptions
4. Concrete implementation suggestions
5. Risk assessment and mitigation strategies"""
return full_prompt
def format_response(
self, response: str, request: ThinkDeeperRequest
) -> str:
"""Format the response with clear attribution"""
return f"Extended Analysis by Gemini:\n\n{response}"