{"record":{"id":"aa71b24eb040d0ff","repo":"upstash/context7","slug":"multiline-strings-are-not-supported-in-mcp-args","errorCode":null,"errorMessage":"Multiline strings are not supported in MCP args","messagePattern":"Multiline strings are not supported in MCP args","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":41,"sourceCode":"  while (index < source.length) {\n    if (/\\s/.test(source[index])) {\n      index++;\n      continue;\n    }\n    if (source[index] !== \"#\") break;\n    while (index < source.length && source[index] !== \"\\n\") index++;\n  }\n  return index;\n}\n\nfunction parseTomlBasicString(source: string, start: number): TomlStringToken {\n  let value = \"\";\n  let index = start + 1;\n  while (index < source.length) {\n    const char = source[index++];\n    if (char === '\"') return { value, start, end: index };\n    if (char === \"\\n\" || char === \"\\r\") {\n      throw new Error(\"Multiline strings are not supported in MCP args\");\n    }\n    if (char !== \"\\\\\") {\n      value += char;\n      continue;\n    }\n\n    const escape = source[index++];\n    if (Object.hasOwn(TOML_BASIC_ESCAPES, escape)) {\n      value += TOML_BASIC_ESCAPES[escape];\n      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)) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L23-L59","documentation":"This error is thrown by a minimal TOML parser used to edit MCP server args in a TOML config file. A basic (double-quoted) string that spans multiple lines was encountered, but the parser only supports single-line strings to keep edits safe and lossless.","triggerScenarios":"A values like args = [\"--flag\"] where the string literal contains a raw newline or carriage return before the closing quote — e.g. pressing Enter inside a quoted value, or copying a multiline command into the args array.","commonSituations":"Hand-editing an MCP config (.claude.json / mcp.toml style files) and breaking a string across lines; pasting multiline shell commands into args; some editors auto-wrapping long lines with real newlines inside quotes.","solutions":["Put the whole value on one line inside the quotes","Use \\n escape sequences instead of literal newlines inside double-quoted strings","Reformat the file so each array element is a single-line string"],"exampleFix":"// before\nargs = [\"--header\",\n  \"x-api-key: k\"]\n// after\nargs = [\"--header\", \"x-api-key: k\"]","handlingStrategy":"validation","validationCode":"// Before invoking the editor, check for raw newlines inside quoted args lines\nconst bad = raw.split('\\n').some(line => (line.match(/\"/g) || []).length % 2 === 1);\nif (bad) throw new Error('Odd number of quotes on a line — likely a multiline string');","typeGuard":"function isSingleLineQuotedLine(line: string): boolean {\n  return (line.match(/\"/g) ?? []).length % 2 === 0 && !/[\\r\\n]/.test(line);\n}","tryCatchPattern":"catch (e) { if (e instanceof Error && e.message.includes('Multiline strings')) { /* reformat file to single-line strings, then retry */ } throw e; }","preventionTips":["Keep every TOML string on one line","Use \\n escapes instead of literal newlines","Lint TOML in CI"],"tags":["toml","config-parsing","mcp","multiline-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"}