upstash/context7 · error
MCP args must be a TOML array containing only strings
Error message
MCP args must be a TOML array containing only strings
What it means
Thrown by parseTomlStringArray when, after skipping whitespace inside the args array, it encounters a token that is not an opening quote. The MCP args array is restricted to containing only string elements — numbers, booleans, nested arrays, inline tables, and bare words are all rejected.
Solutions
- Quote every element: args = ["--verbose"] instead of [--verbose].
- Convert numeric or boolean arguments to strings: args = ["--retries", "3"].
- Flatten or remove nested arrays/tables — each element must be a plain string.
- Regenerate the config ensuring the source array contains only strings (map String() over values).
Example fix
// before (config.toml) args = ["--retries", 3] // after args = ["--retries", "3"]
Defensive patterns
Strategy: validation
Validate before calling
function argsAreAllStrings(arr) { return Array.isArray(arr) && arr.every(x => typeof x === 'string'); }
if (!argsAreAllStrings(rawArgs)) throw new Error('every MCP arg must be a string'); Type guard
const isStringArray = (v) => Array.isArray(v) && v.every(x => typeof x === 'string');
Try / catch
try { parseConfig(toml); } catch (e) { if (e.message.includes('only strings')) { console.error('Quote every element of the args array; convert numbers/booleans to strings'); } else throw e; } Prevention
- Quote every element in the args array
- Convert numeric/boolean flags to strings explicitly
- Sanitize generated configs so arrays contain only strings
- Never write shell-style unquoted args in TOML
When it happens
Trigger: An args array in the MCP config contains a non-string element, e.g. args = [--verbose], args = [1], args = [true], or args = ["--x", {y=1}].
Common situations: Writing shell-style unquoted arguments in the config; assuming numbers/booleans are auto-converted to strings; generating TOML from a JSON args array that contained non-string values.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Expected a comma or closing bracket in MCP args
- Expected a TOML array for MCP args
- Multiline strings are not supported in MCP args
- Unsupported TOML escape \\
- Unterminated TOML array in MCP args
AI-assisted analysis of upstash/context7@4416fb855b (2026-09-16).
Data as JSON: /api/errors/b1b9d5a106f61950.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/setup/toml-editor.ts:96
}
return { value, start, end: endQuote + 1 };
}
function parseTomlStringArray(
source: string,
start: number
): { tokens: TomlStringToken[]; end: number } {
if (source[start] !== "[") throw new Error("Expected a TOML array for MCP args");
const tokens: TomlStringToken[] = [];
let index = start + 1;
while (index < source.length) {
index = skipTomlArrayTrivia(source, index);
if (source[index] === "]") return { tokens, end: index + 1 };
const quote = source[index];
if (quote !== '"' && quote !== "'") {
throw new Error("MCP args must be a TOML array containing only strings");
}
if (source.slice(index, index + 3) === quote.repeat(3)) {
throw new Error("Multiline strings are not supported in MCP args");
}
const token =
quote === '"' ? parseTomlBasicString(source, index) : parseTomlLiteralString(source, index);
tokens.push(token);
index = skipTomlArrayTrivia(source, token.end);
if (source[index] === ",") {
index++;
continue;
}
if (source[index] !== "]") {
throw new Error("Expected a comma or closing bracket in MCP args");
}
}View on GitHub (pinned to 4416fb855b)