-
Notifications
You must be signed in to change notification settings - Fork 2
feat: implement dotenv-based secret management system #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add python-dotenv dependency to pyproject.toml - Create _secrets.py module with comprehensive secret management tools - Implement naming convention mapping (CREDENTIALS_PASSWORD -> credentials.password) - Add tools: set_dotenv_path, list_secrets, add_secret_stub, get_secrets_file_path_for_user - Support both environment variable and tool-based file path configuration - Integrate config hydration into existing connector builder tools - Add comprehensive test suite with 18 test cases - Update _util.py with reference to new hydration functionality - Fix import issues in _connector_builder.py for better type compatibility The system allows users to manage secrets in .env files without exposing actual values to the LLM, while providing seamless config hydration for connector operations. Co-Authored-By: AJ Steers <[email protected]>
Original prompt from AJ Steers
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing This Branch via MCPTo test the changes in this specific branch with an MCP client like Claude Desktop, use the following configuration: {
"mcpServers": {
"connector-builder-mcp-dev": {
"command": "uvx",
"args": ["--from", "git+https://github.com/airbytehq/connector-builder-mcp.git@devin/1754097884-dotenv-implementation", "connector-builder-mcp"]
}
}
} Testing This Branch via CLIYou can test this version of the MCP Server using the following CLI snippet: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/connector-builder-mcp.git@devin/1754097884-dotenv-implementation#egg=airbyte-connector-builder-mcp' --help PR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
There was a problem hiding this comment.
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 implements a comprehensive dotenv-based secret management system that allows users to manage secrets in .env files without exposing actual secret values to the LLM. The system provides MCP tools for managing secrets and automatically hydrates connector configurations with secrets during execution.
- Adds file-based secret management using .env files with configurable paths
- Implements naming convention mapping from environment variables to config paths (e.g.,
CREDENTIALS_PASSWORD
→credentials.password
) - Provides four MCP tools for secret management:
set_dotenv_path
,list_secrets
,add_secret_stub
, andget_secrets_file_path_for_user
- Integrates automatic config hydration into all three connector builder operations
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
File | Description |
---|---|
tests/test_secrets.py |
Comprehensive test suite with 18 test cases covering all secrets functionality |
pyproject.toml |
Adds python-dotenv>=1.0.0 dependency |
connector_builder_mcp/_util.py |
Adds documentation note referencing the new secrets hydration functionality |
connector_builder_mcp/_secrets.py |
Core secrets management module with dotenv file handling, config hydration, and MCP tools |
connector_builder_mcp/_connector_builder.py |
Integrates config hydration into connector operations and registers secrets tools |
Co-Authored-By: AJ Steers <[email protected]>
- list_secrets → list_dotenv_secrets - add_secret_stub → populate_dotenv_missing_secrets_stubs - get_secrets_file_path_for_user → get_dotenv_path Updated all imports, function calls, and test cases to use new names. Co-Authored-By: AJ Steers <[email protected]>
Co-Authored-By: AJ Steers <[email protected]>
- Support manifest-based detection of secrets from airbyte_secret fields - Support explicit config paths like ['credentials.password', 'oauth.client_secret'] - Support legacy single secret key mode for backward compatibility - Create stubs for union of manifest-detected and explicitly provided secrets - Add comprehensive tests covering all modes and edge cases Co-Authored-By: AJ Steers <[email protected]>
Co-Authored-By: AJ Steers <[email protected]>
…ames_from_manifest - Address GitHub comment requesting more descriptive function name - Function name now clearly indicates it extracts secret names, not actual secrets - Maintains all existing functionality and test coverage Co-Authored-By: AJ Steers <[email protected]>
- Remove global state variables (_current_dotenv_path, SECRETS_FILE_ENV_VAR) - Update all function signatures to require explicit dotenv_path parameter - Add allow_create parameter to populate_dotenv_missing_secrets_stubs - Make dotenv file handling completely optional for connectors without secrets - Update all hydrate_config calls to pass explicit dotenv_path=None - Update all tests to pass explicit dotenv file paths - Maintain backward compatibility while removing environment variable dependencies - Support both secrets and semi-sensitive data (PII) through flexible mechanism Co-Authored-By: AJ Steers <[email protected]>
- Fix formatting issues in connector_builder_mcp/_secrets.py and tests/test_secrets.py - Resolve Ruff Format Check and Ruff Lint Check CI failures - All local checks now pass: format, lint, typecheck, and tests Co-Authored-By: AJ Steers <[email protected]>
…e secret hydration from manifest validation - Add optional dotenv_path parameter to execute_stream_test_read function signature - Remove secret hydration from validate_manifest and get_resolved_manifest functions - Update function docstrings to reflect new parameter - Addresses GitHub comments #18 and #19 on PR #11 Co-Authored-By: AJ Steers <[email protected]>
…dotenv keys - Remove set_dotenv_path function as it's no longer needed in stateless design - Remove function from MCP tool registration - Remove associated test class and import - Switch from uppercase underscore format (CREDENTIALS_PASSWORD) to dot notation (credentials.password) for dotenv keys - Update hydrate_config to use dot notation directly for mapping dotenv keys to config paths - Update all tests to reflect new dot notation naming convention - Addresses GitHub comment from aaronsteers on PR #11 and implements requested naming simplification Co-Authored-By: AJ Steers <[email protected]>
Test Implementation Audit -
|
- Convert all test classes to standalone test functions for better readability - Remove 3 trivial tests that don't add meaningful value: * test_hydrate_config_empty_config (trivial case) * test_hydrate_config_none_config (trivial case) * Kept test_get_dotenv_path but noted it tests trivial wrapper - Consolidate test_hydrate_config_simple_keys into test_hydrate_config_with_secrets - Addresses GitHub comment audit feedback from aaronsteers - Reduced test count from 18 to 15 while maintaining full coverage Co-Authored-By: AJ Steers <[email protected]>
Test Implementation Improvements Complete ✅I've successfully implemented the audit recommendations: Changes Made
Results
Test Structure Now
The tests are now more readable, focused, and eliminate the wasteful redundancies identified in the audit. No suppressed signals were found - all tests properly validate expected behavior and error conditions. |
- Remove get_dotenv_path function call from register_secrets_tools - Remove get_dotenv_path import from tests - Remove test_get_dotenv_path test function - Addresses GitHub comment from aaronsteers requesting deletion of this function Co-Authored-By: AJ Steers <[email protected]>
- Update execute_stream_test_read function signature to use Path | None - Add Path import from pathlib - Convert Path to string when calling hydrate_config function - Addresses GitHub comment feedback from aaronsteers Co-Authored-By: AJ Steers <[email protected]>
…ub.com/airbytehq/builder-mcp into devin/1754097884-dotenv-implementation
- Change config_paths from list format to CSV string format in tests - Fixes AttributeError: 'list' object has no attribute 'split' - Updates test_populate_dotenv_missing_secrets_stubs_config_paths and test_populate_dotenv_missing_secrets_stubs_combined_mode - Addresses pytest failures reported by aaronsteers Co-Authored-By: AJ Steers <[email protected]>
Co-Authored-By: AJ Steers <[email protected]>
feat: implement dotenv-based secret management system
Summary
This PR implements a comprehensive dotenv-based secret management system for connector-builder-mcp that allows users to manage secrets in .env files without exposing actual secret values to the LLM. The system provides MCP tools for managing secrets and automatically hydrates connector configurations with secrets during execution.
Key Features:
CREDENTIALS_PASSWORD
→credentials.password
)set_dotenv_path
,list_secrets
,add_secret_stub
,get_secrets_file_path_for_user
Implementation Details:
python-dotenv>=1.0.0
dependency_secrets.py
module with global state management for dotenv file pathvalidate_manifest
,execute_stream_test_read
, andget_resolved_manifest
Review & Testing Checklist for Human
API_KEY
,CREDENTIALS_PASSWORD
,OAUTH_CLIENT_SECRET
) map correctly to config pathsRecommended Test Plan:
poe server
and connect with MCP clientset_dotenv_path
to configure a test .env fileadd_secret_stub
to add placeholder secretslist_secrets
shows secret keys without exposing valuesDiagram
Notes
_env_var_to_path
function contains complex logic for mapping environment variable names to config paths - this is a critical piece that should be thoroughly tested_current_dotenv_path
could potentially have concurrency issues in multi-threaded scenariosLink to Devin run: https://app.devin.ai/sessions/eab82b57cce84fb8aeb33b11e2aabea0
Requested by: AJ Steers (@aaronsteers)