{"record":{"id":"38b587dd63c2be2b","repo":"anthropics/skills","slug":"url-is-required-for-sse-transport","errorCode":null,"errorMessage":"URL is required for sse transport","messagePattern":"URL is required for sse transport","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/mcp-builder/scripts/connections.py","lineNumber":142,"sourceCode":"        command: Command to run (stdio only)\n        args: Command arguments (stdio only)\n        env: Environment variables (stdio only)\n        url: Server URL (sse and http only)\n        headers: HTTP headers (sse and http only)\n\n    Returns:\n        MCPConnection instance\n    \"\"\"\n    transport = transport.lower()\n\n    if transport == \"stdio\":\n        if not command:\n            raise ValueError(\"Command is required for stdio transport\")\n        return MCPConnectionStdio(command=command, args=args, env=env)\n\n    elif transport == \"sse\":\n        if not url:\n            raise ValueError(\"URL is required for sse transport\")\n        return MCPConnectionSSE(url=url, headers=headers)\n\n    elif transport in [\"http\", \"streamable_http\", \"streamable-http\"]:\n        if not url:\n            raise ValueError(\"URL is required for http transport\")\n        return MCPConnectionHTTP(url=url, headers=headers)\n\n    else:\n        raise ValueError(f\"Unsupported transport type: {transport}. Use 'stdio', 'sse', or 'http'\")\n","sourceCodeStart":124,"sourceCodeEnd":152,"githubUrl":"https://github.com/anthropics/skills/blob/f6656c1256d5a8adfa37db9110046ef20bac644c/skills/mcp-builder/scripts/connections.py#L124-L152","documentation":"create_connection() requires a url for transport='sse': SSE MCP servers are reached over HTTP at a known endpoint, so an MCPConnectionSSE cannot be constructed without one. The check fails fast when url is None/empty instead of producing a client that can never connect.","triggerScenarios":"Calling create_connection(transport='sse') without url — typically a config entry where the server was declared with a command (stdio-style) but transport set to 'sse', or the url key is missing/misspelled.","commonSituations":"Copy-pasted MCP server configs mixing fields from stdio and sse examples; forgetting the http(s):// scheme so a hostname string is treated as absent by later validation; renamed keys in config ('endpoint' vs 'url').","solutions":["Pass the server endpoint: create_connection(name='x', transport='sse', url='http://localhost:8000/sse').","If the config has a command instead of a url, that server is stdio — set transport='stdio'.","Verify the key name is exactly 'url' and the value is a full URL with scheme.","Add headers if the SSE endpoint needs auth: headers={'Authorization': 'Bearer ...'}."],"exampleFix":"# before\ncreate_connection(name=\"remote\", transport=\"sse\")\n\n# after\ncreate_connection(name=\"remote\", transport=\"sse\", url=\"https://mcp.example.com/sse\")","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef valid_sse_entry(entry: dict) -> bool:\n    url = entry.get(\"url\") or \"\"\n    return bool(url) and urlparse(url).scheme in (\"http\", \"https\")","typeGuard":null,"tryCatchPattern":"try:\n    conn = create_connection(name=n, transport=\"sse\", url=u)\nexcept ValueError as e:\n    if \"URL is required\" in str(e):\n        raise ConfigError(f\"server {n!r}: sse entry missing 'url'\") from e\n    raise","preventionTips":["Require url for any transport other than stdio at config-load time.","Validate URL has an http/https scheme before connecting.","Keep stdio and sse/http config templates separate to avoid field mixing."],"tags":["mcp","validation","config","sse"],"backgroundTag":null,"analyzedSha":"f6656c1256d5a8adfa37db9110046ef20bac644c","analyzedAt":"2026-08-14T16:09:17.493Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}