{"record":{"id":"8b839d8488bf071f","repo":"upstash/context7","slug":"unterminated-toml-array-in-mcp-args","errorCode":null,"errorMessage":"Unterminated TOML array in MCP args","messagePattern":"Unterminated TOML array in MCP args","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":115,"sourceCode":"    }\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  }\n  throw new Error(\"Unterminated TOML array in MCP args\");\n}\n\nfunction findTomlServerArgs(\n  raw: string,\n  serverName: string\n): { start: number; end: number; tokens: TomlStringToken[] } | null {\n  const escapedName = serverName.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n  const tableKey = `(?:mcp_servers|\"mcp_servers\"|'mcp_servers')`;\n  const serverKey = `(?:${escapedName}|\"${escapedName}\"|'${escapedName}')`;\n  const headerRe = new RegExp(\n    `^[\\\\uFEFF\\\\t ]*\\\\[[\\\\t ]*${tableKey}[\\\\t ]*\\\\.[\\\\t ]*${serverKey}[\\\\t ]*\\\\][\\\\t ]*(?:#.*)?\\\\r?$`,\n    \"m\"\n  );\n  const header = headerRe.exec(raw);\n  if (!header) return null;\n\n  const bodyStart = raw.indexOf(\"\\n\", header.index + header[0].length) + 1;\n  const effectiveBodyStart = bodyStart === 0 ? raw.length : bodyStart;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L97-L133","documentation":"The args array was opened with '[' but the scanning loop reached the end of the file without finding the matching ']' — the array is never closed.","triggerScenarios":"args = [\"--flag\" followed by EOF, or a ']' deleted/typo'd as ')' or '}'.","commonSituations":"Truncating the file while editing; mismatched bracket types from manual editing; nested brackets elsewhere confusing hand edits.","solutions":["Add the closing ] on the args array","Check for ) or } typed instead of ]","Run a TOML validator before saving"],"exampleFix":"// before\nargs = [\"--a\", \"--b\"\n// after\nargs = [\"--a\", \"--b\"]","handlingStrategy":"validation","validationCode":"// bracket balance ignoring quotes (file already known to have no multiline strings)\nlet depth = 0;\nfor (const ch of raw) { if (ch === '[') depth++; else if (ch === ']') depth--; }\nif (depth !== 0) throw new Error('unbalanced brackets');","typeGuard":"function bracketsBalanced(raw: string): boolean {\n  let d = 0;\n  for (const ch of raw.replace(/\"[^\"\\\\n]*\"|'[^'\\\\n]*'/g, '')) {\n    if (ch === '[') d++; else if (ch === ']') d--;\n  }\n  return d === 0;\n}","tryCatchPattern":"catch (e) { if (/Unterminated TOML array/.test(e.message)) { /* add missing ] */ } throw e; }","preventionTips":["Close every array you open","Use an editor with bracket matching"],"tags":["toml","unterminated-array","syntax-error"],"backgroundTag":"toml-parse-error","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"}