{"record":{"id":"aa70772a46e7c66c","repo":"upstash/context7","slug":"expected-a-toml-array-for-mcp-args","errorCode":null,"errorMessage":"Expected a TOML array for MCP args","messagePattern":"Expected a TOML array for MCP args","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":86,"sourceCode":"  }\n  throw new Error(\"Unterminated TOML basic string in MCP args\");\n}\n\nfunction parseTomlLiteralString(source: string, start: number): TomlStringToken {\n  const endQuote = source.indexOf(\"'\", start + 1);\n  if (endQuote === -1) throw new Error(\"Unterminated TOML literal string in MCP args\");\n  const value = source.slice(start + 1, endQuote);\n  if (value.includes(\"\\n\") || value.includes(\"\\r\")) {\n    throw new Error(\"Multiline strings are not supported in MCP args\");\n  }\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);","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/setup/toml-editor.ts#L68-L104","documentation":"Thrown by parseTomlStringArray, the parser for the MCP server args value, when the value does not begin with '['. The MCP args field must be a TOML array of strings; anything else (bare string, inline table, number, etc.) is rejected at the first character check.","triggerScenarios":"Setting args to a non-array value in an [mcp_servers.*] section, e.g. args = \"--verbose\" or args = { a = 1 }, then invoking the parser/reader for that entry.","commonSituations":"Hand-writing the config and forgetting the brackets; converting from JSON where args was sometimes a bare string; a tool or script generating malformed TOML; misunderstanding that args must always be a list even for one argument.","solutions":["Wrap the value in square brackets: args = [\"--verbose\"].","Make each argument its own quoted string element in the array.","Use an empty array args = [] when there are no arguments.","Verify the entry syntax against the documented [mcp_servers.*] schema."],"exampleFix":"// before (config.toml)\nargs = \"--verbose\"\n// after\nargs = [\"--verbose\"]","handlingStrategy":"validation","validationCode":"function parseArgsValue(v) {\n  const t = typeof v;\n  if (t !== 'string') throw new Error('args must be a string of TOML source starting with [');\n  if (!v.trimStart().startsWith('[')) throw new Error('args must be a TOML array');\n}\nparseArgsValue(argsSource);","typeGuard":"const isTomlArraySource = (v) => typeof v === 'string' && v.trimStart().startsWith('[');","tryCatchPattern":"try { parseConfig(toml); } catch (e) { if (e.message === 'Expected a TOML array for MCP args') { console.error('Wrap the args value in square brackets: args = [\"...\"]'); } else throw e; }","preventionTips":["Always write args as a bracketed array, even for a single argument","Use args = [] when there are no arguments","Copy the documented [mcp_servers.*] schema exactly","Validate the TOML structure before loading the config"],"tags":["toml","parsing","config","mcp"],"backgroundTag":"invalid-config-value","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"}