{"record":{"id":"9c2cf537e188e238","repo":"nanocoai/nanoclaw","slug":"url-must-not-contain-credentials-or-fragments-use","errorCode":null,"errorMessage":"url must not contain credentials or fragments; use OneCLI for authentication","messagePattern":"url must not contain credentials or fragments; use OneCLI for authentication","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/container-config.ts","lineNumber":162,"sourceCode":"  }\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'))) {\n        throw new Error(`url query parameter \"${key}\" looks like a credential; use OneCLI for authentication`);\n      }\n    }\n    const headers = parseStringRecord(input.headers, 'headers');\n    return {\n      type: 'http',\n      url,\n      ...(headers === undefined ? {} : { headers }),\n      ...(instructions === undefined ? {} : { instructions }),\n    };\n  }\n  if (command === undefined) throw new Error('Provide exactly one of command or url');\n\n  if (input.headers !== undefined) throw new Error('headers is only valid with url');\n  const args = input.args ?? [];","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/container-config.ts#L144-L180","documentation":"The MCP url contains embedded userinfo (username/password) or a #fragment, which parseMcpServerConfig rejects. NanoClaw routes all credentials through the OneCLI vault, never through the URL, so this shape is treated as a secret-leak risk.","triggerScenarios":"urls like https://user:pass@mcp.example.com/mcp or https://mcp.example.com/mcp#section in an http MCP entry.","commonSituations":"Copy-pasting a vendor quickstart URL that embeds an API key; using a fragment as a session marker; basic-auth style internal endpoints.","solutions":["Remove credentials from the URL and inject auth via OneCLI (headers are injected at request time)","If the server needs a header, use the headers field (but keep secrets out — prefer OneCLI)","Delete any #fragment from the url"],"exampleFix":"// before\n{\"url\":\"https://alice:secret@mcp.example.com/mcp\"}\n// after\n{\"url\":\"https://mcp.example.com/mcp\"}  // auth via OneCLI","handlingStrategy":"validation","validationCode":"const u = new URL(entry.url); if (u.username || u.password || u.hash) throw new UserError('no credentials or fragments in url — use OneCLI');","typeGuard":"const urlHasNoCreds = (s: string) => { const u = new URL(s); return !u.username && !u.password && !u.hash; };","tryCatchPattern":"catch (err) { if (err.message.includes('credentials or fragments')) moveToVault(); else throw err; }","preventionTips":["Never paste vendor quickstart URLs with embedded keys","Store all MCP auth in OneCLI"],"tags":["mcp","credentials","security-policy","url-validation"],"backgroundTag":"credentials-in-url-rejected","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}