{"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":"exception","errorClass":"Error","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/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L56-L92","documentation":"A single-quoted (literal) TOML string in the args array was opened but no closing single quote exists anywhere after it in the file.","triggerScenarios":"args = ['--flag with no closing ', or the closing ' removed during editing; note literal strings cannot contain escapes so a stray ' inside the value ends the string early.","commonSituations":"Using a literal string for a value that itself contains an apostrophe (e.g. 'it's'); deleted closing quote; editor smart-quote substitution.","solutions":["Add the closing single quote","If the value contains an apostrophe, switch to a double-quoted basic string and escape as needed","Check for smart quotes and replace with ASCII quotes"],"exampleFix":"// before\nargs = ['--greeting 'hello''\n// after\nargs = [\"--greeting 'hello'\"]","handlingStrategy":"validation","validationCode":"const idx = raw.indexOf(\"'\");\n// per line: literal strings must open and close on the same line\nfor (const line of raw.split('\\n')) {\n  if (((line.match(/'/g) ?? []).length) % 2 !== 0) throw new Error('Unterminated literal string');\n}","typeGuard":"function literalStringClosed(line: string): boolean {\n  return (line.match(/'/g) ?? []).length % 2 === 0;\n}","tryCatchPattern":"catch (e) { if (/Unterminated TOML literal string/.test(e.message)) { /* close the string or switch to basic string */ } throw e; }","preventionTips":["Avoid literal strings for values containing apostrophes","Pre-check file with a full TOML parser"],"tags":["toml","unterminated-string","literal-string"],"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-14T00:17:10.932Z"}