The leanmcp env command provides a complete set of tools for managing environment variables on your running Lambda deployments. Changes are applied immediately (causing a cold start on next invocation).
System variables like PORT, AWS_LWA_* cannot be modified or deleted as they are required for Lambda Web Adapter.
# Basic list (values masked)leanmcp env list# Show actual valuesleanmcp env list --reveal# List for specific projectleanmcp env list --project-id proj_abc123
# Set a single variableleanmcp env set API_KEY=sk-1234567890abcdef# Set for specific projectleanmcp env set DATABASE_URL=postgres://localhost:5432/db --project-id proj_abc123# Set multiple variables at onceleanmcp env set API_KEY=sk-abc123 DEBUG_MODE=true MAX_RETRIES=3
Example Output:
Copy
Setting environment variable(s) for my-mcp-server...Successfully updated: ✓ API_KEY ✓ DEBUG_MODE ✓ MAX_RETRIESVariables updated successfully!Note: Changes will take effect after a cold start.
Variable keys are automatically converted to uppercase and sanitized to match Lambda environment variable naming rules.
# Get masked valueleanmcp env get API_KEY# Get actual valueleanmcp env get API_KEY --reveal# Get from specific projectleanmcp env get DATABASE_URL --project-id proj_abc123
# Remove with confirmationleanmcp env remove API_KEY# Skip confirmationleanmcp env remove DEBUG_MODE --yes# Remove from specific projectleanmcp env remove OLD_CONFIG --project-id proj_abc123
Example Output:
Copy
? Are you sure you want to delete API_KEY? (y/N) yRemoving environment variable: API_KEYVariable removed successfully!Note: Changes will take effect after a cold start.
This action cannot be undone. The variable will be permanently deleted from your Lambda function.
# Pull to .env (default)leanmcp env pull# Pull to custom fileleanmcp env pull --output .env.production# Overwrite without confirmationleanmcp env pull --overwrite# Pull from specific projectleanmcp env pull --project-id proj_abc123
Example Output:
Copy
Pulling environment variables from my-mcp-server...Downloaded 4 variables to .env✓ API_KEY✓ DATABASE_URL✓ DEBUG_MODE✓ MAX_RETRIESNote: System variables (PORT, AWS_LWA_*) are excluded.
Generated .env file:
Copy
# Environment variables from my-mcp-server# Downloaded: 2026-01-21T22:12:00ZAPI_KEY=sk-1234567890abcdefDATABASE_URL=postgres://user:pass@host:5432/dbDEBUG_MODE=trueMAX_RETRIES=3
# Push from .env (merge mode)leanmcp env push# Push from custom fileleanmcp env push --file .env.production# Replace all variablesleanmcp env push --replace# Push to specific projectleanmcp env push --project-id proj_abc123
Example Output (Merge Mode):
Copy
Pushing environment variables from .env...Parsing file...Found 5 variables? This will update 3 and add 2 variables. Continue? (Y/n) yUpdating variables on my-mcp-server...Successfully updated: ✓ API_KEY (updated) ✓ DATABASE_URL (updated) ✓ DEBUG_MODE (updated) ✓ NEW_VAR_1 (added) ✓ NEW_VAR_2 (added)Variables pushed successfully!Note: Changes will take effect after a cold start.
Example Output (Replace Mode):
Copy
Pushing environment variables from .env...⚠️ WARNING: Replace mode will delete all existing variables!Current variables (4): - API_KEY - DATABASE_URL - DEBUG_MODE - OLD_CONFIGNew variables (3): + API_KEY + DATABASE_URL + NEW_CONFIG? This will DELETE 2 variables and set 3 variables. Continue? (y/N) yReplacing all variables on my-mcp-server...Variables replaced successfully!Note: Changes will take effect after a cold start.
In --replace mode, all existing user variables will be deleted and replaced with the contents of your file. System variables are always preserved.
The following variables are protected and cannot be modified:AWS Reserved:
AWS_* (all AWS-prefixed variables)
Lambda Web Adapter System:
PORT
AWS_LWA_PORT
AWS_LWA_INVOKE_MODE
AWS_LWA_READINESS_CHECK_MIN_UNHEALTHY_STATUS
These variables are automatically managed by AWS Lambda and the Lambda Web Adapter. Attempting to modify them will result in them being skipped with a warning.