{"record":{"id":"68cb1e991aa3d450","repo":"anthropics/skills","slug":"command-is-required-for-stdio-transport","errorCode":null,"errorMessage":"Command is required for stdio transport","messagePattern":"Command is required for stdio transport","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/mcp-builder/scripts/connections.py","lineNumber":137,"sourceCode":") -> MCPConnection:\n    \"\"\"Factory function to create the appropriate MCP connection.\n\n    Args:\n        transport: Connection type (\"stdio\", \"sse\", or \"http\")\n        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":119,"sourceCodeEnd":152,"githubUrl":"https://github.com/anthropics/skills/blob/f6656c1256d5a8adfa37db9110046ef20bac644c/skills/mcp-builder/scripts/connections.py#L119-L152","documentation":"create_connection() in mcp-builder's connections.py validates transport parameters: for transport='stdio' the command (the executable to launch) is mandatory, since an MCP stdio client must spawn a server process. Empty/None command means the caller cannot possibly form a valid MCPConnectionStdio, so it fails fast rather than constructing a broken connection.","triggerScenarios":"Calling create_connection(name=..., transport='stdio', command=None or '') — e.g. reading config where the 'command' key was misspelled or omitted, or wiring a URL-based server config to stdio transport.","commonSituations":"Misconfigured JSON/YAML MCP server entries (command field missing); mixing up transports (an sse/http server entry passed with transport='stdio'); empty-string command from templating bugs in generated config files.","solutions":["Supply the server command: create_connection(name='x', transport='stdio', command='npx', args=['-y', 'server-puppeteer']).","Check the config source for typos — the key must be exactly 'command' (not 'cmd', 'exec', 'path').","If the server is remote, switch transport to 'sse' or 'http' with a url instead.","Validate config entries before passing them: assert entry.get('command') for stdio entries."],"exampleFix":"# before\ncreate_connection(name=\"fs\", transport=\"stdio\", command=\"\", args=[\"--root\", \"/tmp\"])\n\n# after\ncreate_connection(name=\"fs\", transport=\"stdio\", command=\"npx\", args=[\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/tmp\"])","handlingStrategy":"validation","validationCode":"def valid_stdio_entry(entry: dict) -> bool:\n    return bool(entry.get(\"transport\", \"stdio\").lower() == \"stdio\" and (entry.get(\"command\") or \"\").strip())","typeGuard":null,"tryCatchPattern":"try:\n    conn = create_connection(name=n, transport=\"stdio\", command=cmd, args=a)\nexcept ValueError as e:\n    if \"Command is required\" in str(e):\n        raise ConfigError(f\"server {n!r}: stdio entry missing 'command'\") from e\n    raise","preventionTips":["Schema-validate config entries before building connections (command required for stdio).","Use exact key names: command/args/env for stdio; url/headers for sse/http.","Fail config loading loudly at startup rather than per-connection at runtime."],"tags":["mcp","validation","config","stdio"],"backgroundTag":null,"analyzedSha":"f6656c1256d5a8adfa37db9110046ef20bac644c","analyzedAt":"2026-08-14T16:09:17.493Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}