{"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":"validation","errorClass":null,"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/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/setup/toml-editor.ts#L23-L59","documentation":"This error is thrown by parseTomlBasicString while tokenizing a TOML double-quoted basic string in the MCP config file. TOML supports multi-line basic strings (triple-quoted), but this minimal TOML parser, used to read/edit MCP server args, intentionally does not implement them. When it encounters a raw newline or carriage return inside a single-quoted double-quoted string before the closing quote, it throws instead of silently mis-parsing.","triggerScenarios":"Calling the toml-editor APIs (e.g. reading or parsing the args value of an [mcp_servers.*] entry) when a \"...\" string spans a physical line break, or when the string contains a literal CR/LF character rather than the \\n escape sequence.","commonSituations":"Users hand-edit config.toml and break a long string across lines; editors or copy-paste inject real newlines into args values; users copy TOML examples using triple-quoted multi-line strings that this parser rejects.","solutions":["Put the entire string value on one line inside a single pair of double quotes.","Replace real line breaks with the TOML escape sequences \\n or \\r inside the string.","Use a single-quoted literal string on one line if the value contains backslashes and no line breaks.","Split a long argument into multiple array elements in the args array instead of one multi-line string."],"exampleFix":"// before (config.toml)\nargs = [\"--prompt\",\n        \"hello world\"]\n// after\nargs = [\"--prompt\", \"hello world\"]","handlingStrategy":"validation","validationCode":"function hasNoRawNewline(s) { return !/[\\n\\r]/.test(s); }\nif (!args.every(a => typeof a === 'string' && hasNoRawNewline(a))) throw new Error('args strings must be single-line');","typeGuard":"const isSingleLineString = (v) => typeof v === 'string' && !v.includes('\\n') && !v.includes('\\r');","tryCatchPattern":"try { parseConfig(toml); } catch (e) { if (e.message.includes('Multiline strings are not supported')) { console.error('MCP args contain a raw line break; join the string onto one line'); } else throw e; }","preventionTips":["Keep every TOML string on one physical line","Use \\n escapes instead of real line breaks inside values","Split long values into multiple args array elements","Avoid triple-quoted multi-line TOML strings in MCP config"],"tags":["toml","parsing","config","mcp"],"backgroundTag":"invalid-config-value","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"}