upstash/context7 · error

Multiline strings are not supported in MCP args

Error message

Multiline strings are not supported in MCP args

What it means

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.

Solutions

  1. Put the entire string value on one line inside a single pair of double quotes.
  2. Replace real line breaks with the TOML escape sequences \n or \r inside the string.
  3. Use a single-quoted literal string on one line if the value contains backslashes and no line breaks.
  4. Split a long argument into multiple array elements in the args array instead of one multi-line string.

Example fix

// before (config.toml)
args = ["--prompt",
        "hello world"]
// after
args = ["--prompt", "hello world"]
Defensive patterns

Strategy: validation

Validate before calling

function hasNoRawNewline(s) { return !/[\n\r]/.test(s); }
if (!args.every(a => typeof a === 'string' && hasNoRawNewline(a))) throw new Error('args strings must be single-line');

Type guard

const isSingleLineString = (v) => typeof v === 'string' && !v.includes('\n') && !v.includes('\r');

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of upstash/context7@4416fb855b (2026-09-16). Data as JSON: /api/errors/aa71b24eb040d0ff. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/setup/toml-editor.ts:41

  while (index < source.length) {
    if (/\s/.test(source[index])) {
      index++;
      continue;
    }
    if (source[index] !== "#") break;
    while (index < source.length && source[index] !== "\n") index++;
  }
  return index;
}

function parseTomlBasicString(source: string, start: number): TomlStringToken {
  let value = "";
  let index = start + 1;
  while (index < source.length) {
    const char = source[index++];
    if (char === '"') return { value, start, end: index };
    if (char === "\n" || char === "\r") {
      throw new Error("Multiline strings are not supported in MCP args");
    }
    if (char !== "\\") {
      value += char;
      continue;
    }

    const escape = source[index++];
    if (Object.hasOwn(TOML_BASIC_ESCAPES, escape)) {
      value += TOML_BASIC_ESCAPES[escape];
      continue;
    }
    if (escape !== "u" && escape !== "U") {
      throw new Error(`Unsupported TOML escape \\${escape}`);
    }

    const width = escape === "u" ? 4 : 8;
    const hex = source.slice(index, index + width);
    if (!new RegExp(`^[0-9A-Fa-f]{${width}}$`).test(hex)) {

View on GitHub (pinned to 4416fb855b)