{"record":{"id":"272fa1a91b595e97","repo":"nanocoai/nanoclaw","slug":"provide-exactly-one-of-command-or-url","errorCode":null,"errorMessage":"Provide exactly one of command or url","messagePattern":"Provide exactly one of command or url","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/container-config.ts","lineNumber":147,"sourceCode":"\n  // A declared transport is honored; absence keeps the legacy CLI inference\n  // (url → http, command → stdio). \"streamable-http\" is the Agent Plugins\n  // spelling of the internal \"http\".\n  const type = input.type === 'streamable-http' ? 'http' : input.type;\n  if (type === 'sse') throw new Error('unsupported transport \"sse\"');\n  if (type !== undefined && type !== 'stdio' && type !== 'http') {\n    throw new Error('type must be \"stdio\", \"http\", or \"streamable-http\"');\n  }\n  if (type === 'stdio' && !command) throw new Error('type \"stdio\" requires command');\n  if (type === 'http' && !url) throw new Error('type \"http\" requires url');\n\n  const instructions = input.instructions;\n  if (instructions !== undefined && typeof instructions !== 'string') {\n    throw new Error('MCP instructions must be a string');\n  }\n\n  if (url !== undefined) {\n    if (command !== undefined) throw new Error('Provide exactly one of command or url');\n    if (input.args !== undefined || input.env !== undefined || input.cwd !== undefined) {\n      throw new Error('args, env, and cwd are only valid with command');\n    }\n    let parsed: URL;\n    try {\n      parsed = new URL(url);\n    } catch (err) {\n      throw new Error('url must be a valid HTTP(S) URL', { cause: err });\n    }\n    const loopback = ['localhost', '127.0.0.1', '[::1]', 'host.docker.internal'].includes(parsed.hostname);\n    if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopback)) {\n      throw new Error('url must use HTTPS (plain HTTP is allowed only for localhost and host.docker.internal)');\n    }\n    if (parsed.username || parsed.password || parsed.hash) {\n      throw new Error('url must not contain credentials or fragments; use OneCLI for authentication');\n    }\n    for (const key of parsed.searchParams.keys()) {\n      if (SECRET_QUERY_KEY_RE.test(key.replace(CAMEL_SPLIT_RE, '$1_$2'))) {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/container-config.ts#L129-L165","documentation":"Thrown when an MCP server entry provides BOTH `command` and `url`. The two fields select mutually exclusive transports (local process vs remote endpoint), and later code branches on url first, so the ambiguity is rejected up front at container-config.ts:147.","triggerScenarios":"An entry with {\"command\":\"npx\",...,\"url\":\"https://...\"} passed to parseMcpServerConfig via ncl add-mcp-server, validateAddMcpServer, or server config reads.","commonSituations":"Merging two example configs together; migrating stdio→http and forgetting to delete the old command field.","solutions":["Delete whichever of command/url you don't want","If migrating to http, also remove args/env/cwd (they're stdio-only)","Re-run ncl groups config get to confirm only one transport field remains"],"exampleFix":"// before\n{\"command\":\"npx\",\"args\":[\"srv\"],\"url\":\"https://mcp.example.com\"}\n// after\n{\"url\":\"https://mcp.example.com\"}","handlingStrategy":"validation","validationCode":"if (entry.command !== undefined && entry.url !== undefined) delete entry.url; // pick one transport explicitly","typeGuard":"const hasExactlyOneTransport = (e: any) => (e.command !== undefined) !== (e.url !== undefined);","tryCatchPattern":"catch (err) { if (err.message.includes('exactly one of command or url')) askUserToPickTransport(); else throw err; }","preventionTips":["Never merge two server examples; start from one","When migrating stdio→http, delete command/args/env/cwd together"],"tags":["mcp","config-validation","mutually-exclusive-fields"],"backgroundTag":"schema-validation-failed","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}