feat(config): add project-specific environment variables with backwar… - #1
Conversation
…d compatibility Rename generic MCP_* environment variables to MCP_PR_* prefix to prevent namespace collisions when multiple MCP servers are installed. This allows developers to run mcp-pr alongside other MCP servers with independent configurations. Changes: - MCP_LOG_LEVEL → MCP_PR_LOG_LEVEL - MCP_DEFAULT_PROVIDER → MCP_PR_DEFAULT_PROVIDER - MCP_REVIEW_TIMEOUT → MCP_PR_REVIEW_TIMEOUT - MCP_MAX_DIFF_SIZE → MCP_PR_MAX_DIFF_SIZE Backward Compatibility: - Old variable names still work during transition period - Deprecation warnings logged when old names are used - New names take precedence when both are set - Will be removed in v1.0.0 Preserved (unchanged): - API keys: ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY - Provider timeouts: ANTHROPIC_TIMEOUT, OPENAI_TIMEOUT, GOOGLE_TIMEOUT Implementation: - Added GetEnvWithFallback() helper with deprecation warnings - Updated config.Load() to use new variable names with fallback - Added comprehensive unit and integration tests (24 test cases) - Updated documentation with migration guide - Performance: <0.004ms load time (2500x better than 10ms target) Testing: - Unit tests: 100% pass rate for config package - Integration tests: Backward compatibility verified - Benchmark tests: Performance validated - TDD approach: Tests written first, verified to fail, then pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR introduces project-specific environment variable naming to prevent namespace collisions when running multiple MCP servers. The implementation renames generic MCP_* variables to MCP_PR_* while maintaining backward compatibility with deprecated variable names that log warnings.
Key changes:
- Added
GetEnvWithFallbackhelper function with fallback chain and deprecation warnings - Renamed 4 environment variables: LOG_LEVEL, DEFAULT_PROVIDER, REVIEW_TIMEOUT, MAX_DIFF_SIZE
- Preserved standard API key and provider timeout variable names
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/config/config.go | Implemented GetEnvWithFallback helper and updated Load() to use new variable names with backward compatibility |
| tests/unit/config/config_test.go | Added comprehensive unit tests for fallback logic, new variable names, and backward compatibility |
| tests/unit/config/config_benchmark_test.go | Added benchmarks to verify configuration load performance |
| tests/integration/config_compat_test.go | Added integration tests for backward compatibility scenarios |
| README.md | Updated configuration section with new variable names and migration guide |
| CONTRIBUTING.md | Updated development setup with new variable names |
| CHANGELOG.md | Documented variable name changes and deprecation timeline |
| specs/002-update-the-env/* | Added comprehensive specification, design documents, and task tracking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| name string | ||
| envVars map[string]string | ||
| expectError bool | ||
| checkAntropic bool |
There was a problem hiding this comment.
Corrected spelling of 'checkAntropic' to 'checkAnthropic'.
| "ANTHROPIC_API_KEY": "sk-ant-test-key", | ||
| }, | ||
| expectError: false, | ||
| checkAntropic: true, |
There was a problem hiding this comment.
Corrected spelling of 'checkAntropic' to 'checkAnthropic'.
| "GOOGLE_API_KEY": "google-test", | ||
| }, | ||
| expectError: false, | ||
| checkAntropic: true, |
There was a problem hiding this comment.
Corrected spelling of 'checkAntropic' to 'checkAnthropic'.
| if err != nil { | ||
| t.Fatalf("config.Load() failed: %v", err) | ||
| } | ||
| if tt.checkAntropic && cfg.AnthropicAPIKey == "" { |
There was a problem hiding this comment.
Corrected spelling of 'checkAntropic' to 'checkAnthropic'.
…d compatibility
Rename generic MCP_* environment variables to MCP_PR_* prefix to prevent namespace collisions when multiple MCP servers are installed. This allows developers to run mcp-pr alongside other MCP servers with independent configurations.
Changes:
Backward Compatibility:
Preserved (unchanged):
Implementation:
Testing:
🤖 Generated with Claude Code
Description
Fixes #
Type of Change
Changes Made
Testing
Test Coverage
make test)Manual Testing
# Commands run and their resultsChecklist
Code Quality
make lint)make fmt)Testing
make test)Documentation
Dependencies
Breaking Changes
Impact:
Migration:
Screenshots (if applicable)
Performance Impact
Security Considerations
Additional Context
Reviewer Notes
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.