{"record":{"id":"fa6c72ca0b783018","repo":"unslothai/unsloth","slug":"enter-an-http-s-url-or-a-local-command-whose","errorCode":null,"errorMessage":"Enter an http(s):// URL, or a local command whose first token is an executable (not a URL).","messagePattern":"Enter an http\\(s\\):// URL, or a local command whose first token is an executable \\(not a URL\\)\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"studio/backend/routes/mcp_servers.py","lineNumber":84,"sourceCode":"    # When stdio is enabled, a non-HTTP value is a local command (reuses this\n    # field so stdio servers ride existing CRUD/storage).\n    if stdio_mcp_enabled() and is_stdio(trimmed):\n        try:\n            parts = parse_stdio_command(trimmed)\n        except ValueError as exc:\n            raise log_and_http_error(\n                exc,\n                400,\n                \"Invalid command. Check quoting and try again.\",\n                event = \"mcp_servers.invalid_command\",\n                log = logger,\n            )\n        if not parts or not parts[0].strip():\n            raise HTTPException(status_code = 400, detail = \"command must not be empty\")\n        if \"://\" in parts[0]:\n            # A URL-scheme first token is a mistyped URL, not a command. Reject\n            # cleanly instead of exec-ing it (mirrors the frontend check).\n            raise HTTPException(\n                status_code = 400,\n                detail = \"Enter an http(s):// URL, or a local command whose \"\n                \"first token is an executable (not a URL).\",\n            )\n        return trimmed\n    parsed = urlparse(trimmed)\n    if parsed.scheme not in (\"http\", \"https\"):\n        if _looks_like_command(trimmed):\n            detail = (\n                \"Local commands aren't enabled on this server. To allow them, \"\n                \"set UNSLOTH_STUDIO_ALLOW_STDIO_MCP=1 and restart Unsloth, or use \"\n                \"an http:// or https:// URL instead.\"\n            )\n        else:\n            detail = (\n                \"MCP server address must start with http:// or https:// \"\n                \"(for example https://example.com/mcp).\"\n            )","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/mcp_servers.py#L66-L102","documentation":"400 raised when stdio MCP is enabled, the value is treated as a local command, but the first parsed token contains '://' — i.e. the user typed a URL into the command field. The backend refuses to exec a URL-looking token as a process (which would fail or do something unintended) and tells the user to use the value as a proper http(s) URL instead. Mirrors the frontend's check.","triggerScenarios":"POST/PUT an MCP server with url like 'https://example.com/mcp extra-arg' or 'http://host' while stdio mode classifies it as a command because the string contains whitespace (a URL with an unencoded space is definitively not a URL, so 'npx https://...' style mistakes land here too).","commonSituations":"Pasting a URL plus arguments into the command box, or constructing 'npx https://server.example' style commands where the executable slot holds a URL.","solutions":["If you meant a remote server: send just the http(s):// URL with no trailing tokens after it (encode spaces in the path/query).","If you meant a local command: put a real executable first (npx, uvx, node, python) and pass any URL as a later argument, not the first token."],"exampleFix":"# before\n{'url': 'https://example.com/mcp --flag'}   # -> 400, URL in executable slot\n\n# after\n{'url': 'https://example.com/mcp'}           # remote server\n# or\n{'url': 'npx -y some-mcp-wrapper https://example.com/mcp'}  # URL as an argument","handlingStrategy":"validation","validationCode":"const first = command.trim().split(/\\s+/)[0];\nif (first.includes('://')) throw new Error('First token looks like a URL — send the URL alone, or put a real executable first');","typeGuard":"function firstTokenIsExecutable(cmd) { return !cmd.trim().split(/\\s+/)[0].includes('://'); }","tryCatchPattern":null,"preventionTips":["Never place a URL in the executable slot of a stdio command.","Pass URLs as arguments after npx/uvx/node/python."],"tags":["mcp","stdio","url","validation","http-400"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}