{"record":{"id":"b1b9d5a106f61950","repo":"upstash/context7","slug":"mcp-args-must-be-a-toml-array-containing-only-stri","errorCode":null,"errorMessage":"MCP args must be a TOML array containing only strings","messagePattern":"MCP args must be a TOML array containing only strings","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":96,"sourceCode":"  }\n  return { value, start, end: endQuote + 1 };\n}\n\nfunction parseTomlStringArray(\n  source: string,\n  start: number\n): { tokens: TomlStringToken[]; end: number } {\n  if (source[start] !== \"[\") throw new Error(\"Expected a TOML array for MCP args\");\n\n  const tokens: TomlStringToken[] = [];\n  let index = start + 1;\n  while (index < source.length) {\n    index = skipTomlArrayTrivia(source, index);\n    if (source[index] === \"]\") return { tokens, end: index + 1 };\n\n    const quote = source[index];\n    if (quote !== '\"' && quote !== \"'\") {\n      throw new Error(\"MCP args must be a TOML array containing only strings\");\n    }\n    if (source.slice(index, index + 3) === quote.repeat(3)) {\n      throw new Error(\"Multiline strings are not supported in MCP args\");\n    }\n\n    const token =\n      quote === '\"' ? parseTomlBasicString(source, index) : parseTomlLiteralString(source, index);\n    tokens.push(token);\n    index = skipTomlArrayTrivia(source, token.end);\n\n    if (source[index] === \",\") {\n      index++;\n      continue;\n    }\n    if (source[index] !== \"]\") {\n      throw new Error(\"Expected a comma or closing bracket in MCP args\");\n    }\n  }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/setup/toml-editor.ts#L78-L114","documentation":"Thrown by parseTomlStringArray when, after skipping whitespace inside the args array, it encounters a token that is not an opening quote. The MCP args array is restricted to containing only string elements — numbers, booleans, nested arrays, inline tables, and bare words are all rejected.","triggerScenarios":"An args array in the MCP config contains a non-string element, e.g. args = [--verbose], args = [1], args = [true], or args = [\"--x\", {y=1}].","commonSituations":"Writing shell-style unquoted arguments in the config; assuming numbers/booleans are auto-converted to strings; generating TOML from a JSON args array that contained non-string values.","solutions":["Quote every element: args = [\"--verbose\"] instead of [--verbose].","Convert numeric or boolean arguments to strings: args = [\"--retries\", \"3\"].","Flatten or remove nested arrays/tables — each element must be a plain string.","Regenerate the config ensuring the source array contains only strings (map String() over values)."],"exampleFix":"// before (config.toml)\nargs = [\"--retries\", 3]\n// after\nargs = [\"--retries\", \"3\"]","handlingStrategy":"validation","validationCode":"function argsAreAllStrings(arr) { return Array.isArray(arr) && arr.every(x => typeof x === 'string'); }\nif (!argsAreAllStrings(rawArgs)) throw new Error('every MCP arg must be a string');","typeGuard":"const isStringArray = (v) => Array.isArray(v) && v.every(x => typeof x === 'string');","tryCatchPattern":"try { parseConfig(toml); } catch (e) { if (e.message.includes('only strings')) { console.error('Quote every element of the args array; convert numbers/booleans to strings'); } else throw e; }","preventionTips":["Quote every element in the args array","Convert numeric/boolean flags to strings explicitly","Sanitize generated configs so arrays contain only strings","Never write shell-style unquoted args in TOML"],"tags":["toml","parsing","type-mismatch","config"],"backgroundTag":"type-mismatch","analyzedSha":"4416fb855b8f752be735e34f943b5d0762701aad","analyzedAt":"2026-09-16T20:28:07.148Z","contentChangedAt":"2026-09-16T20:28:07.148Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}