Skip to content

feat(config): add project-specific environment variables with backwar… - #1

Merged
dshills merged 1 commit into
mainfrom
002-update-the-env
Oct 29, 2025
Merged

feat(config): add project-specific environment variables with backwar…#1
dshills merged 1 commit into
mainfrom
002-update-the-env

Conversation

@dshills

@dshills dshills commented Oct 29, 2025

Copy link
Copy Markdown
Owner

…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

Description

Fixes #

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test improvement

Changes Made

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests pass locally (make test)

Manual Testing

# Commands run and their results

Checklist

Code Quality

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Linter passes (make lint)
  • Code is formatted (make fmt)

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally (make test)
  • Test coverage has not decreased

Documentation

  • I have updated the documentation accordingly
  • I have updated CHANGELOG.md (for significant changes)
  • I have added/updated code comments where necessary

Dependencies

  • I have not added new dependencies (or justified them below)
  • All dependencies are properly licensed (MIT/Apache 2.0 compatible)

Breaking Changes

Impact:

Migration:

// Before
oldAPI()

// After
newAPI()

Screenshots (if applicable)

Performance Impact

  • No performance impact
  • Performance improved
  • Performance may be affected (explain below)

Security Considerations

  • No security impact
  • Security improved
  • Reviewed for vulnerabilities (SQL injection, XSS, etc.)

Additional Context

Reviewer Notes


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.

…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>
Copilot AI review requested due to automatic review settings October 29, 2025 14:52
@dshills
dshills merged commit 95c1c72 into main Oct 29, 2025
9 checks passed
@dshills
dshills deleted the 002-update-the-env branch October 29, 2025 14:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetEnvWithFallback helper 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

Copilot AI Oct 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'checkAntropic' to 'checkAnthropic'.

Copilot uses AI. Check for mistakes.
"ANTHROPIC_API_KEY": "sk-ant-test-key",
},
expectError: false,
checkAntropic: true,

Copilot AI Oct 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'checkAntropic' to 'checkAnthropic'.

Copilot uses AI. Check for mistakes.
"GOOGLE_API_KEY": "google-test",
},
expectError: false,
checkAntropic: true,

Copilot AI Oct 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'checkAntropic' to 'checkAnthropic'.

Copilot uses AI. Check for mistakes.
if err != nil {
t.Fatalf("config.Load() failed: %v", err)
}
if tt.checkAntropic && cfg.AnthropicAPIKey == "" {

Copilot AI Oct 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'checkAntropic' to 'checkAnthropic'.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants