{"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":"exception","errorClass":"Error","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/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L68-L104","documentation":"The parser found the server's args key but the value does not start with '[' — it expected a TOML array. This happens when args is a plain string, a number, or the '=' is followed by something else.","triggerScenarios":"args = \"--flag --other\" (string instead of array) or args = 42 in the MCP server's TOML table.","commonSituations":"Converting an inline command string to a server entry; copy-pasting from docs that use string form; leftover placeholder values.","solutions":["Change the value to a TOML array of strings: args = [\"--flag\", \"--other\"]","Ensure nothing (comments excepted) sits between = and [","Reload/re-run the setup command after fixing"],"exampleFix":"// before\nargs = \"--api-key ABC\"\n// after\nargs = [\"--api-key\", \"ABC\"]","handlingStrategy":"validation","validationCode":"const m = body.match(/^args\\\\s*=\\\\s*(.)/m);\nif (!m || m[1] !== '[') throw new Error('args must be an array');","typeGuard":"function argsValueStartsArray(raw: string): boolean {\n  const m = raw.match(/args\\\\s*=\\\\s*\\\\S/);\n  return !!m && m[0].endsWith('[');\n}","tryCatchPattern":"catch (e) { if (/Expected a TOML array/.test(e.message)) { /* rewrite args as an array of strings */ } throw e; }","preventionTips":["Always define args as an array of quoted strings","Validate config with the target tool before running setup"],"tags":["toml","type-mismatch","array-expected","mcp"],"backgroundTag":"toml-type-mismatch","analyzedSha":"edc9eeb77bbfc553e08a122ca783293fdb477daf","analyzedAt":"2026-08-28T10:18:41.476Z","contentChangedAt":"2026-08-28T10:18:41.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}