{"record":{"id":"1f2152076949cb61","repo":"nanocoai/nanoclaw","slug":"args-env-and-cwd-are-only-valid-with-command","errorCode":null,"errorMessage":"args, env, and cwd are only valid with command","messagePattern":"args, env, and cwd are only valid with command","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/container-config.ts","lineNumber":149,"sourceCode":"  // (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'))) {\n        throw new Error(`url query parameter \"${key}\" looks like a credential; use OneCLI for authentication`);\n      }","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/container-config.ts#L131-L167","documentation":"Thrown when a url-based MCP entry includes `args`, `env`, or `cwd`. Those fields configure the local process for stdio transport and have no meaning for a remote HTTP endpoint, so parseMcpServerConfig rejects the combination (container-config.ts:149).","triggerScenarios":"An entry with url plus any of args/env/cwd, e.g. {\"url\":\"https://...\",\"env\":{\"FOO\":\"bar\"}} via ncl or the self-mod tool.","commonSituations":"Copying a stdio example and swapping command for url while keeping env; trying to set env vars for a remote server via config instead of headers or OneCLI.","solutions":["Remove args/env/cwd from the url entry","Pass server auth via headers or OneCLI credential injection, not env","For local processes needing env, keep stdio transport with command"],"exampleFix":"// before\n{\"url\":\"https://mcp.example.com\",\"env\":{\"KEY\":\"val\"}}\n// after\n{\"url\":\"https://mcp.example.com\",\"headers\":{\"Authorization\":\"Bearer ...\"}}","handlingStrategy":"validation","validationCode":"if (entry.url !== undefined) { delete entry.args; delete entry.env; delete entry.cwd; }","typeGuard":"const isCleanHttpEntry = (e: any) => e.url !== undefined && e.args === undefined && e.env === undefined && e.cwd === undefined;","tryCatchPattern":"catch (err) { if (err.message.includes('only valid with command')) stripStdioFields(); else throw err; }","preventionTips":["Remember the field split: command→args/env/cwd, url→headers","Use headers or OneCLI for http-server auth"],"tags":["mcp","config-validation","transport-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}