{"record":{"id":"2517f68d2028c59d","repo":"upstash/context7","slug":"unterminated-toml-literal-string-in-mcp-args","errorCode":null,"errorMessage":"Unterminated TOML literal string in MCP args","messagePattern":"Unterminated TOML literal string in MCP args","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":74,"sourceCode":"\n    const width = escape === \"u\" ? 4 : 8;\n    const hex = source.slice(index, index + width);\n    if (!new RegExp(`^[0-9A-Fa-f]{${width}}$`).test(hex)) {\n      throw new Error(`Invalid TOML Unicode escape \\\\${escape}${hex}`);\n    }\n    const codePoint = Number.parseInt(hex, 16);\n    if (codePoint > 0x10ffff || (codePoint >= 0xd800 && codePoint <= 0xdfff)) {\n      throw new Error(`Invalid TOML Unicode code point U+${hex}`);\n    }\n    value += String.fromCodePoint(codePoint);\n    index += width;\n  }\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 };","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/setup/toml-editor.ts#L56-L92","documentation":"Thrown by parseTomlLiteralString when a single-quoted TOML literal string has no closing ' before end of input. Literal strings have no escapes, so the very next ' must terminate the string; if indexOf finds none, the string is unterminated and the parser throws.","triggerScenarios":"Parsing MCP config args where a '...' string is missing its closing quote, e.g. args = ['--flag, or an apostrophe used inside the value was itself a quote character terminating the string early and leaving a later quote unterminated.","commonSituations":"Writing a value containing an apostrophe (e.g. 'don't panic') inside a literal string; hand-editing the config and dropping a closing quote; copy-paste truncation.","solutions":["Add the missing closing single quote.","Escape the apostrophe problem by switching to a double-quoted basic string: \"don't panic\".","Check preceding entries for unbalanced quotes that shifted where strings start and end.","Run a TOML validator over the file to pinpoint the unbalanced quote."],"exampleFix":"// before (config.toml)\nargs = ['don't panic']\n// after\nargs = [\"don't panic\"]","handlingStrategy":"validation","validationCode":"function balancedSingleQuotes(s) { return (s.match(/'/g) || []).length % 2 === 0; }\nif (!balancedSingleQuotes(tomlSource)) console.warn('unbalanced single quotes in TOML');","typeGuard":null,"tryCatchPattern":"try { parseConfig(toml); } catch (e) { if (e.message.includes('Unterminated TOML literal string')) { console.error(\"A '...' string is missing its closing quote — switch to double quotes for values with apostrophes\"); } else throw e; }","preventionTips":["Use double-quoted strings for values containing apostrophes","Verify quote balance after editing literal strings","Lint the TOML file with a reference parser","Don't embed apostrophes carelessly in single-quoted strings"],"tags":["toml","parsing","unterminated-string","config"],"backgroundTag":"invalid-argument-format","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"}