Second Opinion
About
Review commits and codebases using external LLMs like OpenAI, Google Gemini, and Mistral.
Details
- Author
- dshills
- Categories
- Developer Tools, AI
Jump to
Setup
Install Second Opinion in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/dshills/second-opinion
Follow the installation instructions in the repository README, then restart your MCP client.
An MCP (Model Context Protocol) server that assists Claude Code in reviewing commits and code bases. This tool leverages external LLMs (OpenAI, Google Gemini, Ollama, Mistral) to provide intelligent code review capabilities, git diff analysis, commit quality assessment, and uncommitted work analysis.
- Git Diff Analysis: Analyze git diff output to understand code changes using LLMs
- Code Review: Review code for quality, security, and best practices with AI assistance
- Commit Analysis: Analyze git commits for quality and adherence to best practices
- Uncommitted Work Analysis: Analyze all uncommitted changes or just staged changes
- Repository Information: Get information about git repositories
- Multiple LLM Support: Works with OpenAI, Google Gemini, Ollama (local), and Mistral AI
- π Smart Optimization: Dynamic token allocation and task-specific temperature tuning
- β‘ Performance Tuning: Provider-specific optimizations and memory-aware chunking
- Security: Input validation, secure path handling, and API key protection
- Memory Safety: Configurable memory limits and streaming support for large diffs
- Go 1.20 or higher
- Git
- Claude Code Desktop app
git clone https://github.com/dshills/second-opinion.git cd second-opinion
Second Opinion supports two configuration methods, with the following priority order:
- JSON Configuration File(preferred):~/.second-opinion.jsonin your home directory
- Environment Variables: Using.envfile or system environment variables
Create a.second-opinion.jsonfile in your home directory:
{ "default_provider": "openai", "temperature": 0.3, "max_tokens": 4096, "server_name": "Second Opinion π", "server_version": "1.0.0", "openai": { "api_key": "sk-your-openai-api-key", "model": "gpt-5-mini" }, "google": { "api_key": "your-google-api-key", "model": "gemini-2.0-flash-exp" }, "ollama": { "endpoint": "http://localhost:11434", "model": "devstral:latest" }, "mistral": { "api_key": "your-mistral-api-key", "model": "mistral-small-latest" }, "memory": { "max_diff_size_mb": 10, "max_file_count": 1000, "max_line_length": 1000, "enable_streaming": true, "chunk_size_mb": 1 } }
- Dynamic Token Allocation: Automatically adjusts tokens (4096-32768) based on diff size
- Task-Specific Temperature: Optimizes temperature (0.1-0.3) based on analysis type
- Provider Optimization: Custom parameters for each LLM provider
- Memory Management: Automatic chunking for large diffs and high file counts
If no JSON configuration is found, the server falls back to environment variables:
- Edit.envand configure your LLM providers:
# Set your default provider DEFAULT_PROVIDER=openai # or google, ollama, mistral # Configure each provider with its own API key and preferred model OPENAI_API_KEY=sk-your-openai-api-key OPENAI_MODEL=gpt-5-mini # or gpt-5, gpt-5-nano, gpt-5-chat-latest, gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo GOOGLE_API_KEY=your-google-api-key GOOGLE_MODEL=gemini-2.0-flash-exp # or gemini-1.5-flash, gemini-1.5-pro OLLAMA_ENDPOINT=http://localhost:11434 OLLAMA_MODEL=devstral:latest # or llama3.2, codellama, mistral, etc. MISTRAL_API_KEY=your-mistral-api-key MISTRAL_MODEL=mistral-small-latest # or mistral-large-latest, codestral-latest # Global settings apply to all providers LLM_TEMPERATURE=0.3 # Controls randomness (0.0-2.0, default: 0.3) LLM_MAX_TOKENS=4096 # Maximum response length (default: 4096)
The configuration file location depends on your operating system:
- macOS:~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:%APPDATA%\Claude\claude_desktop_config.json
- Linux:~/.config/Claude/claude_desktop_config.json
Open the configuration file and add the Second Opinion server:
Option 1: Using JSON Configuration (Recommended)
{ "mcpServers": { "second-opinion": { "command": "/path/to/second-opinion/bin/second-opinion" } } }
Replace/path/to/second-opinionwith the actual path where you cloned the repository.
{ "mcpServers": { "second-opinion": { "command": "/path/to/second-opinion/bin/second-opinion", "env": { "DEFAULT_PROVIDER": "openai", "OPENAI_API_KEY": "your-openai-api-key", "OPENAI_MODEL": "gpt-5-mini", "LLM_TEMPERATURE": "0.3", "LLM_MAX_TOKENS": "4096" } } } }
After saving the configuration, restart Claude Code for the changes to take effect.
In Claude Code, you should see "second-opinion" in the MCP servers list. You can test it by asking:
"What git repository information can you get from the current directory?"
Analyzes git diff output to understand code changes using the configured LLM with automatic optimization.
- diff_content(required): Git diff output to analyze
- summarize(optional): Whether to provide a summary of changes
- provider(optional): LLM provider to use (overrides default)
- model(optional): Model to use (overrides provider default)
- Dynamic Token Allocation: 4096-32768 tokens based on diff size
- Temperature Tuning: 0.25 optimized for diff analysis
- Chunking: Automatic chunking for large diffs (>10MB or >1000 files)
- Provider-Specific: Custom parameters per LLM provider
"Analyze this git diff and tell me what changed: [paste diff here]"
Reviews code for quality, security, and best practices using the configured LLM with task-specific optimization.
- code(required): Code to review
- language(optional): Programming language of the code
- focus(optional): Specific focus area -security,performance,style, orall
- provider(optional): LLM provider to use (overrides default)
- model(optional): Model to use (overrides provider default)
- Task-Specific Temperature: 0.1 for security focus (high precision), 0.2 for general code review
- Dynamic Token Allocation: Scales with code size for comprehensive analysis
- Focus-Aware Analysis: Specialized prompts and parameters per focus area
"Review this Python code for security issues: [paste code here]"
Analyzes a git commit for quality and adherence to best practices using the configured LLM with commit-specific optimization.
- commit_sha(optional): Git commit SHA to analyze (default: HEAD)
- repo_path(optional): Path to the git repository (default: current directory)
- provider(optional): LLM provider to use (overrides default)
- model(optional): Model to use (overrides provider default)
- Commit Analysis Temperature: 0.2 for consistent, deterministic commit analysis
- Memory-Safe Diff Processing: Handles large commits with automatic truncation
- Combined Analysis: Includes commit message quality, diff analysis, and best practices
"Analyze the latest commit in this repository" "Analyze commit abc123 and tell me if it follows best practices"
Analyzes uncommitted changes in a git repository to help prepare for commits with intelligent optimization.
- repo_path(optional): Path to the git repository (default: current directory)
- staged_only(optional): Analyze only staged changes (default: false, analyzes all uncommitted changes)
- provider(optional): LLM provider to use (overrides default)
- model(optional): Model to use (overrides provider default)
- Code Review Temperature: 0.2 for balanced analysis of uncommitted changes
- Large Changeset Handling: Automatic chunking for extensive modifications
- Context-Aware Analysis: Tailored analysis for staged vs. all uncommitted work
- Summary of all changes (files modified, added, deleted)
- Type and nature of changes (feature, bugfix, refactor, etc.)
- Completeness and readiness for commit
- Potential issues or concerns
- Suggested commit message(s) if changes are ready
- Recommendations for organizing commits if changes should be split
"Analyze my uncommitted changes and suggest a commit message" "Review only my staged changes before I commit" "Should I split my current changes into multiple commits?"
Gets information about a git repository (no LLM analysis).
- repo_path(optional): Path to the git repository (default: current directory)
"Show me information about this git repository"
- Input Validation: All repository paths and commit SHAs are validated to prevent command injection
- Path Restrictions: Repository paths must be within the current working directory
- API Key Protection: API keys are never exposed in error messages or logs
- HTTP Timeouts: All LLM API calls have 30-second timeouts to prevent hanging
- Concurrent Access: Thread-safe provider management for concurrent requests
Second Opinion includes a comprehensive optimization system that automatically tunes performance based on content and context:
- 4096 tokens: Very small diffs (<5KB)
- 6144 tokens: Small diffs (5-20KB)
- 8192 tokens: Medium diffs (20-50KB)
- 12288 tokens: Large diffs (50-150KB)
- 16384 tokens: Very large diffs (150-500KB)
- 32768 tokens: Huge diffs (>500KB)
- 0.1: Security reviews (maximum precision)
- 0.2: Code reviews and commit analysis (mostly deterministic)
- 0.25: Diff analysis (slightly flexible)
- 0.3: Architecture reviews (allows creativity)
- OpenAI: Full token allocation with top_p=0.9
- Google: Capped at 8192 tokens with focused sampling (top_k=20, top_p=0.8)
- Mistral: Conservative allocation with top_p=0.8
- Ollama: Local model optimization with repeat_penalty=1.05
- Automatic Chunking: Large diffs (>10MB or >1000 files) are intelligently split
- Smart Chunk Sizing: Adapts chunk size based on file count
- Memory-Aware Streaming: Enables streaming for large operations
second-opinion/ βββ main.go # MCP server setup and tool registration βββ handlers.go # Tool handler implementations βββ validation.go # Input validation functions βββ config/ # Configuration loading and optimization β βββ config.go # Main configuration with optimization methods β βββ optimization_test.go # Comprehensive optimization tests βββ llm/ # LLM provider implementations β βββ provider.go # Provider interface, prompts, and optimization wrapper β βββ openai.go # OpenAI implementation β βββ google.go # Google Gemini implementation β βββ ollama.go # Ollama implementation with advanced options β βββ mistral.go # Mistral implementation with additional parameters βββ CLAUDE.md # Claude Code specific instructions βββ TODO.md # Development roadmap
# Run all tests go test ./... -v # Run optimization tests specifically go test ./config -v # Run specific test suites go test ./llm -v -run TestProviderConnections # Run with race detection go test -race ./... # Run with coverage go test -cover ./...
# Install golangci-lint if not already installed go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest # Run linter golangci-lint run # Auto-fix issues where possible golangci-lint run --fix
# Build for current platform go build -o bin/second-opinion # Build with race detector (for development) go build -race -o bin/second-opinion # Build for different platforms GOOS=darwin GOARCH=amd64 go build -o bin/second-opinion-darwin-amd64 GOOS=linux GOARCH=amd64 go build -o bin/second-opinion-linux-amd64 GOOS=windows GOARCH=amd64 go build -o bin/second-opinion-windows-amd64.exe
-
"Provider not configured" error
- Ensure you have set up either~/.second-opinion.jsonor environment variables
- Check that API keys are valid and have appropriate permissions
- Ensure you're running the tool in a directory with a.gitfolder
- The tool validates that paths are git repositories for security
- Check your internet connection
- For Ollama, ensure the local server is running:ollama serve
- Consider using a faster model if timeouts persist
- The tool only allows access to the current working directory and subdirectories
- Ensure the binary has execute permissions:chmod +x bin/second-opinion
To see detailed logs, you can run the server directly:
- Fork the repository
- Create a feature branch
- Ensure all tests pass and linting is clean
- Submit a pull request
SeeTODO.mdfor planned features and known issues.
For large repositories, seedocs/MEMORY_USAGE.mdfor configuration options to handle large diffs efficiently.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
AI-powered code quality analysis to detect best practice violations, security issues, and architectural problems in real-time.
Your AI Code Review Council - Get diverse perspectives from multiple AI models in parallel.
Performs complementary code analysis by combining Claude Code and Google's Gemini AI.
An MCP server for the DeepSeek API, providing code review, file management, and account management.
Strict AI code reviewer powered by Groq. Finds bugs, SQL injections, hardcoded secrets and vulnerabilities. Scores code 0β100 with concrete fixes.
Provides AI-powered mentorship to LLM agents for tasks like code review, design critique, and brainstorming, using the Deepseek API.
Provides call graph analysis for LLMs using the nuanced library.
An AI-powered server providing access to multiple models for code analysis, problem-solving, and collaborative development with guided workflows.
Orchestrates multiple AI models like Claude and Gemini for enhanced code analysis, problem-solving, and collaborative development.
Code search and querying using the Greptile API.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




