upstash/context7 · error · Error
Unsupported TOML escape \\${escape}
Error message
Unsupported TOML escape \\${escape} What it means
The parser hit a backslash escape inside a double-quoted TOML string that it does not support. Only the standard TOML escapes (b, t, n, f, r, quote, backslash) plus \u and \U unicode escapes are handled; anything else (e.g. \x, \0, \d) is rejected.
Source
Thrown at packages/cli/src/setup/toml-editor.ts:54
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)) {
throw new Error(`Invalid TOML Unicode escape \\${escape}${hex}`);
}
const codePoint = Number.parseInt(hex, 16);
if (codePoint > 0x10ffff || (codePoint >= 0xd800 && codePoint <= 0xdfff)) {
throw new Error(`Invalid TOML Unicode code point U+${hex}`);
}
value += String.fromCodePoint(codePoint);
index += width;
}
throw new Error("Unterminated TOML basic string in MCP args");
}
function parseTomlLiteralString(source: string, start: number): TomlStringToken {View on GitHub (pinned to edc9eeb77b)
Solutions
- Double the backslash for literal backslashes: "C:\\Users\\me"
- Use only supported escapes: \n \t \r \f \b \" \\ or \uXXXX / \UXXXXXXXX
- For regexes, use a literal single-quoted TOML string ('...') where backslashes are literal
Example fix
// before args = ["--path", "C:\Users\me"] // after args = ["--path", "C:\\Users\\me"]
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ['b','t','n','f','r','"','\\\\','u','U'];
const re = /\\([^btnfr"\\uU])/g;
if (re.test(str)) throw new Error('Unsupported escape: ' + re.exec(str)?.[1]); Type guard
function hasOnlySupportedTomlEscapes(s: string): boolean {
return !/\\[^btnfr"\\uU]/.test(s);
} Try / catch
catch (e) { if (/Unsupported TOML escape/.test(e.message)) { /* rewrite escapes or use literal string */ } throw e; } Prevention
- Prefer single-quoted literal strings for regexes/paths
- Double backslashes in basic strings
- Escape via JSON.parse round-trip tooling carefully
When it happens
Trigger: A double-quoted args string containing an escape like "\x41", "\d+", or a Windows-style path written as "C:\Users" (where \U is treated as a unicode escape start or fails).
Common situations: Writing regex patterns or Windows paths in args without doubling backslashes; copy-pasting JSON/JS escape syntax into TOML; using \x hex escapes that TOML doesn't have.
Related errors
- Multiline strings are not supported in MCP args
- Invalid TOML Unicode escape \\${escape}${hex}
- Invalid TOML Unicode code point U+${hex}
- Expected a TOML array for MCP args
- MCP args must be a TOML array containing only strings
AI-assisted analysis of upstash/context7@edc9eeb77b (2026-08-28).
Data as JSON: /api/errors/8c170a8235dfde3c.
Report an issue: GitHub.