{"record":{"id":"e6289e3aaa17b633","repo":"upstash/context7","slug":"unterminated-toml-basic-string-in-mcp-args","errorCode":null,"errorMessage":"Unterminated TOML basic string in MCP args","messagePattern":"Unterminated TOML basic string in MCP args","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":69,"sourceCode":"      continue;\n    }\n    if (escape !== \"u\" && escape !== \"U\") {\n      throw new Error(`Unsupported TOML escape \\\\${escape}`);\n    }\n\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","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/setup/toml-editor.ts#L51-L87","documentation":"Thrown by parseTomlBasicString when the loop reaches the end of the source without finding the closing double quote of a basic string. It is a hard stop after the scanning while-loop exits, meaning the string opened with \" but was never closed before EOF.","triggerScenarios":"Parsing MCP config args where a double-quoted string is missing its closing quote, e.g. args = [\"--flag, or a quote character earlier in the file swallowed the rest of the content into one unterminated string.","commonSituations":"Hand-editing config.toml and deleting a closing quote; an unescaped \" inside a basic string (should be \\\") ending the string early and leaving a later one unterminated; truncated or partially written config files.","solutions":["Add the missing closing double quote to the string in the MCP config.","Escape any literal \" inside the string as \\\" so it does not terminate the string early.","Check the lines above the reported location — an earlier unbalanced quote may be consuming subsequent content.","Validate the whole TOML file with a standard TOML parser/linter to locate the unbalanced quote."],"exampleFix":"// before (config.toml)\nargs = [\"--name \"my server\"]\n// after\nargs = [\"--name\", \"my server\"]","handlingStrategy":"validation","validationCode":"function balancedDoubleQuotes(s) { return (s.match(/(?<!\\\\)\"/g) || []).length % 2 === 0; }\nif (!balancedDoubleQuotes(tomlSource)) console.warn('unbalanced double quotes in TOML');","typeGuard":null,"tryCatchPattern":"try { parseConfig(toml); } catch (e) { if (e.message.includes('Unterminated TOML basic string')) { console.error('A \"...\" string is missing its closing quote — escape inner quotes as \\\"'); } else throw e; }","preventionTips":["Escape literal double quotes inside basic strings as \\\"","Count quotes in hand-edited entries before saving","Run a TOML linter over the whole file to catch unbalanced quotes early","Avoid hand-editing generated config files; regenerate instead"],"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"}