Standard Integration Pattern:
# Add shared module path
sys.path.insert(0, '/opt/mcp-servers/shared')
# Credentials Helper for secure password retrieval (Nexus 3.0.6)
try:
from credentials_helper import get_environment_config
CREDENTIALS_HELPER_AVAILABLE = True
except ImportError:
CREDENTIALS_HELPER_AVAILABLE = False
# Get password with fallback
if CREDENTIALS_HELPER_AVAILABLE:
_config = get_environment_config('environment_name')
PASSWORD = _config.get('vault_password', 'fallback')
else:
PASSWORD = 'fallback' # Fallback - see locker l_XXXX
For Multiple Environments (like search server):
def _get_password(env_name: str, fallback: str) -> str:
if CREDENTIALS_HELPER_AVAILABLE:
try:
config = get_environment_config(env_name)
return config.get('vault_password', fallback)
except:
pass
return fallback
# Usage
password = _get_password('context', 'D8qlcX') # l_abab
Important: Always include the locker ID in comments for the fallback password so developers know where to look.