upstash/context7 · error · Error
Existing MCP server has no safely editable args array
Error message
Existing MCP server has no safely editable args array
What it means
The tool located the named MCP server's table in the TOML file but found no 'args = ...' key (plain, quoted, or single-quoted) inside that table body. It refuses to edit because there is no args array to patch — the server entry is malformed for automated editing.
Source
Thrown at packages/cli/src/setup/toml-editor.ts:143
const headerRe = new RegExp(
`^[\\uFEFF\\t ]*\\[[\\t ]*${tableKey}[\\t ]*\\.[\\t ]*${serverKey}[\\t ]*\\][\\t ]*(?:#.*)?\\r?$`,
"m"
);
const header = headerRe.exec(raw);
if (!header) return null;
const bodyStart = raw.indexOf("\n", header.index + header[0].length) + 1;
const effectiveBodyStart = bodyStart === 0 ? raw.length : bodyStart;
const nextHeaderRe = /^[\t ]*\[[^\r\n]+\][\t ]*(?:#.*)?\r?$/gm;
nextHeaderRe.lastIndex = effectiveBodyStart;
const nextHeader = nextHeaderRe.exec(raw);
const bodyEnd = nextHeader?.index ?? raw.length;
const body = raw.slice(effectiveBodyStart, bodyEnd);
const argsRe = /^[\t ]*(?:args|"args"|'args')[\t ]*=[\t ]*/gm;
const args = argsRe.exec(body);
if (!args) {
throw new Error("Existing MCP server has no safely editable args array");
}
const start = effectiveBodyStart + args.index + args[0].length;
const parsed = parseTomlStringArray(raw, start);
return { start, end: parsed.end, tokens: parsed.tokens };
}
function withoutApiKey(args: string[]): string[] {
const result: string[] = [];
for (let index = 0; index < args.length; index++) {
if (args[index] === "--api-key") {
index++;
continue;
}
result.push(args[index]);
}
return result;
}View on GitHub (pinned to edc9eeb77b)
Solutions
- Add an args = [...] array to the server's TOML table, including the package invocation
- Ensure args appears inside the correct [server] table before the next header
- If you don't want automated patching, run the setup with a mode that doesn't edit this server
Example fix
// before [context7] command = "npx" // after [context7] command = "npx" args = ["-y", "@upstash/context7-mcp"]
Defensive patterns
Strategy: validation
Validate before calling
const serverBody = raw.slice(raw.indexOf(`[${serverName}]`));
if (!/(^|\\n)\\s*(args|"args"|'args')\\s*=/.test(serverBody)) throw new Error('server table lacks args key'); Type guard
function serverHasEditableArgs(raw: string, serverName: string): boolean {
const i = raw.indexOf(`[${serverName}]`);
if (i === -1) return false;
const body = raw.slice(i).split(/\\n\\s*\\[/).slice(0, 1)[0];
return /(args|"args"|'args')\\s*=\\s*\\[/.test(body);
} Try / catch
catch (e) { if (/no safely editable args array/.test(e.message)) { /* add args = [...] to the server table */ } throw e; } Prevention
- Always define command + args in MCP server tables
- Keep args inside the correct table before the next header
When it happens
Trigger: A [mcp.context7] (or similar) server table that defines only command/env but omits args, so the API-key patch cannot find where to insert.
Common situations: Minimal hand-written server entries missing args; args defined in a different table or after another header so it falls outside the server's body; renamed key (arguments instead of args).
Related errors
- Multiline strings are not supported in MCP args
- Unsupported TOML escape \\${escape}
- Expected a TOML array for MCP args
- MCP args must be a TOML array containing only strings
- TOML files containing multiline strings are not safely edita
AI-assisted analysis of upstash/context7@edc9eeb77b (2026-08-28).
Data as JSON: /api/errors/8f3e492ac2ded9f4.
Report an issue: GitHub.