upstash/context7 · error · Error
Expected a TOML array for MCP args
Error message
Expected a TOML array for MCP args
What it means
The parser found the server's args key but the value does not start with '[' — it expected a TOML array. This happens when args is a plain string, a number, or the '=' is followed by something else.
Source
Thrown at packages/cli/src/setup/toml-editor.ts:86
}
throw new Error("Unterminated TOML basic string in MCP args");
}
function parseTomlLiteralString(source: string, start: number): TomlStringToken {
const endQuote = source.indexOf("'", start + 1);
if (endQuote === -1) throw new Error("Unterminated TOML literal string in MCP args");
const value = source.slice(start + 1, endQuote);
if (value.includes("\n") || value.includes("\r")) {
throw new Error("Multiline strings are not supported in MCP args");
}
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);View on GitHub (pinned to edc9eeb77b)
Solutions
- Change the value to a TOML array of strings: args = ["--flag", "--other"]
- Ensure nothing (comments excepted) sits between = and [
- Reload/re-run the setup command after fixing
Example fix
// before args = "--api-key ABC" // after args = ["--api-key", "ABC"]
Defensive patterns
Strategy: validation
Validate before calling
const m = body.match(/^args\\s*=\\s*(.)/m);
if (!m || m[1] !== '[') throw new Error('args must be an array'); Type guard
function argsValueStartsArray(raw: string): boolean {
const m = raw.match(/args\\s*=\\s*\\S/);
return !!m && m[0].endsWith('[');
} Try / catch
catch (e) { if (/Expected a TOML array/.test(e.message)) { /* rewrite args as an array of strings */ } throw e; } Prevention
- Always define args as an array of quoted strings
- Validate config with the target tool before running setup
When it happens
Trigger: args = "--flag --other" (string instead of array) or args = 42 in the MCP server's TOML table.
Common situations: Converting an inline command string to a server entry; copy-pasting from docs that use string form; leftover placeholder values.
Related errors
- Multiline strings are not supported in MCP args
- Unsupported TOML escape \\${escape}
- MCP args must be a TOML array containing only strings
- Existing MCP server has no safely editable args array
- TOML files containing multiline strings are not safely edita
AI-assisted analysis of upstash/context7@edc9eeb77b (2026-08-28).
Data as JSON: /api/errors/aa70772a46e7c66c.
Report an issue: GitHub.