diff --git a/gemini_server.py b/gemini_server.py index 0e0b312..008d999 100755 --- a/gemini_server.py +++ b/gemini_server.py @@ -4,8 +4,9 @@ This file exists to maintain compatibility with existing configurations. The main implementation is now in server.py """ -from server import main import asyncio +from server import main + if __name__ == "__main__": asyncio.run(main()) diff --git a/prompts/__init__.py b/prompts/__init__.py index 8861682..ae950c7 100644 --- a/prompts/__init__.py +++ b/prompts/__init__.py @@ -2,12 +2,8 @@ System prompts for Gemini tools """ -from .tool_prompts import ( - THINK_DEEPER_PROMPT, - REVIEW_CODE_PROMPT, - DEBUG_ISSUE_PROMPT, - ANALYZE_PROMPT, -) +from .tool_prompts import (ANALYZE_PROMPT, DEBUG_ISSUE_PROMPT, + REVIEW_CODE_PROMPT, THINK_DEEPER_PROMPT) __all__ = [ "THINK_DEEPER_PROMPT", diff --git a/server.py b/server.py index 08626d6..4dae804 100644 --- a/server.py +++ b/server.py @@ -2,27 +2,22 @@ Gemini MCP Server - Main server implementation """ -import os -import sys import asyncio import logging +import os +import sys from datetime import datetime -from typing import List, Dict, Any +from typing import Any, Dict, List import google.generativeai as genai from mcp.server import Server +from mcp.server.models import InitializationOptions from mcp.server.stdio import stdio_server from mcp.types import TextContent, Tool -from mcp.server.models import InitializationOptions -from config import ( - __version__, - __updated__, - __author__, - DEFAULT_MODEL, - MAX_CONTEXT_TOKENS, -) -from tools import ThinkDeeperTool, ReviewCodeTool, DebugIssueTool, AnalyzeTool +from config import (DEFAULT_MODEL, MAX_CONTEXT_TOKENS, __author__, __updated__, + __version__) +from tools import AnalyzeTool, DebugIssueTool, ReviewCodeTool, ThinkDeeperTool # Configure logging logging.basicConfig(level=logging.INFO) @@ -147,8 +142,8 @@ async def handle_call_tool( async def handle_chat(arguments: Dict[str, Any]) -> List[TextContent]: """Handle general chat requests""" - from utils import read_files from config import TEMPERATURE_BALANCED + from utils import read_files prompt = arguments.get("prompt", "") context_files = arguments.get("context_files", []) diff --git a/setup.py b/setup.py index 4a4d3dc..70c35d5 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,10 @@ Setup configuration for Gemini MCP Server """ -from setuptools import setup from pathlib import Path +from setuptools import setup + # Read README for long description readme_path = Path(__file__).parent / "README.md" long_description = "" diff --git a/tests/conftest.py b/tests/conftest.py index a82a55a..ce6b50b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,8 +2,8 @@ Pytest configuration for Gemini MCP Server tests """ -import sys import os +import sys from pathlib import Path # Ensure the parent directory is in the Python path for imports diff --git a/tests/test_config.py b/tests/test_config.py index 244cbf3..485e30d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,17 +2,9 @@ Tests for configuration """ -from config import ( - __version__, - __updated__, - __author__, - DEFAULT_MODEL, - MAX_CONTEXT_TOKENS, - TEMPERATURE_ANALYTICAL, - TEMPERATURE_BALANCED, - TEMPERATURE_CREATIVE, - TOOL_TRIGGERS, -) +from config import (DEFAULT_MODEL, MAX_CONTEXT_TOKENS, TEMPERATURE_ANALYTICAL, + TEMPERATURE_BALANCED, TEMPERATURE_CREATIVE, TOOL_TRIGGERS, + __author__, __updated__, __version__) class TestConfig: diff --git a/tests/test_server.py b/tests/test_server.py index 8916869..b268a17 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -2,11 +2,12 @@ Tests for the main server functionality """ -import pytest import json from unittest.mock import Mock, patch -from server import handle_list_tools, handle_call_tool +import pytest + +from server import handle_call_tool, handle_list_tools class TestServerTools: diff --git a/tests/test_tools.py b/tests/test_tools.py index da44c3e..0d761d1 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -2,10 +2,11 @@ Tests for individual tool implementations """ -import pytest from unittest.mock import Mock, patch -from tools import ThinkDeeperTool, ReviewCodeTool, DebugIssueTool, AnalyzeTool +import pytest + +from tools import AnalyzeTool, DebugIssueTool, ReviewCodeTool, ThinkDeeperTool class TestThinkDeeperTool: diff --git a/tests/test_utils.py b/tests/test_utils.py index 3581ea1..9bede78 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2,12 +2,8 @@ Tests for utility functions """ -from utils import ( - read_file_content, - read_files, - estimate_tokens, - check_token_limit, -) +from utils import (check_token_limit, estimate_tokens, read_file_content, + read_files) class TestFileUtils: diff --git a/tools/__init__.py b/tools/__init__.py index 994ff01..f7e808d 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -2,10 +2,10 @@ Tool implementations for Gemini MCP Server """ -from .think_deeper import ThinkDeeperTool -from .review_code import ReviewCodeTool -from .debug_issue import DebugIssueTool from .analyze import AnalyzeTool +from .debug_issue import DebugIssueTool +from .review_code import ReviewCodeTool +from .think_deeper import ThinkDeeperTool __all__ = [ "ThinkDeeperTool", diff --git a/tools/analyze.py b/tools/analyze.py index 6aa05ff..8af4526 100644 --- a/tools/analyze.py +++ b/tools/analyze.py @@ -2,12 +2,15 @@ Analyze tool - General-purpose code and file analysis """ -from typing import Dict, Any, List, Optional +from typing import Any, Dict, List, Optional + from pydantic import Field -from .base import BaseTool, ToolRequest + +from config import MAX_CONTEXT_TOKENS, TEMPERATURE_ANALYTICAL from prompts import ANALYZE_PROMPT -from utils import read_files, check_token_limit -from config import TEMPERATURE_ANALYTICAL, MAX_CONTEXT_TOKENS +from utils import check_token_limit, read_files + +from .base import BaseTool, ToolRequest class AnalyzeRequest(ToolRequest): diff --git a/tools/base.py b/tools/base.py index e5a068a..54e1c70 100644 --- a/tools/base.py +++ b/tools/base.py @@ -3,10 +3,11 @@ Base class for all Gemini MCP tools """ from abc import ABC, abstractmethod -from typing import Dict, Any, List, Optional -from pydantic import BaseModel, Field +from typing import Any, Dict, List, Optional + import google.generativeai as genai from mcp.types import TextContent +from pydantic import BaseModel, Field class ToolRequest(BaseModel): diff --git a/tools/debug_issue.py b/tools/debug_issue.py index 717d54c..4cef14d 100644 --- a/tools/debug_issue.py +++ b/tools/debug_issue.py @@ -2,12 +2,15 @@ Debug Issue tool - Root cause analysis and debugging assistance """ -from typing import Dict, Any, List, Optional +from typing import Any, Dict, List, Optional + from pydantic import Field -from .base import BaseTool, ToolRequest + +from config import MAX_CONTEXT_TOKENS, TEMPERATURE_ANALYTICAL from prompts import DEBUG_ISSUE_PROMPT -from utils import read_files, check_token_limit -from config import TEMPERATURE_ANALYTICAL, MAX_CONTEXT_TOKENS +from utils import check_token_limit, read_files + +from .base import BaseTool, ToolRequest class DebugIssueRequest(ToolRequest): diff --git a/tools/review_code.py b/tools/review_code.py index 8d25b50..0fca490 100644 --- a/tools/review_code.py +++ b/tools/review_code.py @@ -2,12 +2,15 @@ Code Review tool - Comprehensive code analysis and review """ -from typing import Dict, Any, List, Optional +from typing import Any, Dict, List, Optional + from pydantic import Field -from .base import BaseTool, ToolRequest + +from config import MAX_CONTEXT_TOKENS, TEMPERATURE_ANALYTICAL from prompts import REVIEW_CODE_PROMPT -from utils import read_files, check_token_limit -from config import TEMPERATURE_ANALYTICAL, MAX_CONTEXT_TOKENS +from utils import check_token_limit, read_files + +from .base import BaseTool, ToolRequest class ReviewCodeRequest(ToolRequest): diff --git a/tools/think_deeper.py b/tools/think_deeper.py index 64ca07d..793be57 100644 --- a/tools/think_deeper.py +++ b/tools/think_deeper.py @@ -2,12 +2,15 @@ Think Deeper tool - Extended reasoning and problem-solving """ -from typing import Dict, Any, List, Optional +from typing import Any, Dict, List, Optional + from pydantic import Field -from .base import BaseTool, ToolRequest + +from config import MAX_CONTEXT_TOKENS, TEMPERATURE_CREATIVE from prompts import THINK_DEEPER_PROMPT -from utils import read_files, check_token_limit -from config import TEMPERATURE_CREATIVE, MAX_CONTEXT_TOKENS +from utils import check_token_limit, read_files + +from .base import BaseTool, ToolRequest class ThinkDeeperRequest(ToolRequest): diff --git a/utils/__init__.py b/utils/__init__.py index 5aef536..c7dc6af 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -2,8 +2,8 @@ Utility functions for Gemini MCP Server """ -from .file_utils import read_files, read_file_content -from .token_utils import estimate_tokens, check_token_limit +from .file_utils import read_file_content, read_files +from .token_utils import check_token_limit, estimate_tokens __all__ = [ "read_files", diff --git a/utils/file_utils.py b/utils/file_utils.py index f6b9c90..9b79007 100644 --- a/utils/file_utils.py +++ b/utils/file_utils.py @@ -3,7 +3,7 @@ File reading utilities """ from pathlib import Path -from typing import List, Tuple, Optional +from typing import List, Optional, Tuple def read_file_content(file_path: str) -> str: diff --git a/utils/token_utils.py b/utils/token_utils.py index a6d3608..7cb2b7a 100644 --- a/utils/token_utils.py +++ b/utils/token_utils.py @@ -3,6 +3,7 @@ Token counting utilities """ from typing import Tuple + from config import MAX_CONTEXT_TOKENS