upstash/context7 · error · 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 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.

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 edc9eeb77b)

Solutions

  1. Put the whole value on one line inside the quotes
  2. Use \n escape sequences instead of literal newlines inside double-quoted strings
  3. Reformat the file so each array element is a single-line string

Example fix

// before
args = ["--header",
  "x-api-key: k"]
// after
args = ["--header", "x-api-key: k"]
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking the editor, check for raw newlines inside quoted args lines
const bad = raw.split('\n').some(line => (line.match(/"/g) || []).length % 2 === 1);
if (bad) throw new Error('Odd number of quotes on a line — likely a multiline string');

Type guard

function isSingleLineQuotedLine(line: string): boolean {
  return (line.match(/"/g) ?? []).length % 2 === 0 && !/[\r\n]/.test(line);
}

Try / catch

catch (e) { if (e instanceof Error && e.message.includes('Multiline strings')) { /* reformat file to single-line strings, then retry */ } throw e; }

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of upstash/context7@edc9eeb77b (2026-08-28). Data as JSON: /api/errors/aa71b24eb040d0ff. Report an issue: GitHub.