{"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":"exception","errorClass":"Error","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/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L51-L87","documentation":"A double-quoted string in the MCP args array was opened but never closed before the end of the file — the scanning loop ran off the end without finding a closing quote.","triggerScenarios":"args = [\"--flag missing closing quote, or the closing quote was deleted/turned into a smart quote by an editor.","commonSituations":"Manually editing args and deleting a quote; rich-text editors converting \" to curly quotes; truncated file from a failed write.","solutions":["Add the missing closing double quote on the same line","Ensure plain ASCII quotes (\" not \\u201c/\\u201d)","Validate the TOML with a linter/editor before saving"],"exampleFix":"// before\nargs = [\"--api-key\n// after\nargs = [\"--api-key\"]","handlingStrategy":"validation","validationCode":"const openQuotes = (line.match(/(^|[^\\\\])\"/g) ?? []).length;\nif (openQuotes % 2 !== 0) throw new Error('Unterminated basic string');","typeGuard":"function lineHasBalancedQuotes(line: string): boolean {\n  return ((line.match(/\"/g) ?? []).length) % 2 === 0;\n}","tryCatchPattern":"catch (e) { if (/Unterminated TOML basic string/.test(e.message)) { /* add closing quote, re-run */ } throw e; }","preventionTips":["Disable smart quotes in editors","Run a TOML parser (e.g. SmolToml) as a pre-check"],"tags":["toml","unterminated-string","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"}