Skip to content

Commit 1e1faef

Browse files
jtcorbettandrew-lastmile
authored andcommitted
add override for TLS validation (lastmile-ai#567)
### TL;DR Added support for disabling TLS validation during deployments via environment variable. ### Why make this change? We can't and shouldn't use TLS if we're accessing this from within the VPC (i.e. staging env). Add an undocumented override for TLS validation <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added option to disable TLS validation during deployment via environment variable configuration. - Warning message displayed when TLS validation is disabled. - Deployment endpoint logged in verbose mode when TLS validation is disabled. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent c67d971 commit 1e1faef

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/mcp_agent/cli/cloud/commands/deploy/wrangler_wrapper.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .constants import (
2626
CLOUDFLARE_ACCOUNT_ID,
2727
CLOUDFLARE_EMAIL,
28+
DEFAULT_DEPLOYMENTS_UPLOAD_API_BASE_URL,
2829
WRANGLER_SEND_METRICS,
2930
)
3031
from .settings import deployment_settings
@@ -161,6 +162,25 @@ def wrangler_deploy(
161162
npm_prefix.mkdir(parents=True, exist_ok=True)
162163
env_updates["npm_config_prefix"] = str(npm_prefix)
163164

165+
if os.environ.get("__MCP_DISABLE_TLS_VALIDATION", "").lower() in ("1", "true", "yes"):
166+
if deployment_settings.DEPLOYMENTS_UPLOAD_API_BASE_URL == DEFAULT_DEPLOYMENTS_UPLOAD_API_BASE_URL:
167+
print_error(
168+
f"Cannot disable TLS validation when using {DEFAULT_DEPLOYMENTS_UPLOAD_API_BASE_URL}. "
169+
"Set MCP_DEPLOYMENTS_UPLOAD_API_BASE_URL to a custom endpoint."
170+
)
171+
raise ValueError(
172+
f"TLS validation cannot be disabled with {DEFAULT_DEPLOYMENTS_UPLOAD_API_BASE_URL}"
173+
)
174+
175+
env_updates["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"
176+
print_warning(
177+
"TLS certificate validation disabled (__MCP_DISABLE_TLS_VALIDATION is set)."
178+
)
179+
if settings.VERBOSE:
180+
print_info(
181+
f"Deployment endpoint: {deployment_settings.DEPLOYMENTS_UPLOAD_API_BASE_URL}"
182+
)
183+
164184
env.update(env_updates)
165185

166186
validate_project(project_dir)

0 commit comments

Comments
 (0)