fix validation error for stdio mcp (#6341)

This commit is contained in:
Nilay 2026-06-15 23:56:41 +05:30 committed by GitHub
commit fbe4d08ad0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,13 +77,17 @@ def _validate_url(url: str) -> str:
return trimmed
parsed = urlparse(trimmed)
if parsed.scheme not in ("http", "https"):
detail = (
"MCP server address must start with http:// or https:// "
"(for example https://example.com/mcp)."
)
# Host-scoped wording: self-hosted hosts can opt in via the env var.
if _looks_like_command(trimmed):
detail += " Running a local command is not enabled on this server."
detail = (
"Local commands aren't enabled on this server. To allow them, "
"set UNSLOTH_STUDIO_ALLOW_STDIO_MCP=1 and restart Studio, or use "
"an http:// or https:// URL instead."
)
else:
detail = (
"MCP server address must start with http:// or https:// "
"(for example https://example.com/mcp)."
)
raise HTTPException(status_code = 400, detail = detail)
if not parsed.netloc:
raise HTTPException(status_code = 400, detail = "url is missing a host")