{"record":{"id":"592c7e5fad348715","repo":"upstash/context7","slug":"expected-a-comma-or-closing-bracket-in-mcp-args","errorCode":null,"errorMessage":"Expected a comma or closing bracket in MCP args","messagePattern":"Expected a comma or closing bracket in MCP args","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":112,"sourceCode":"    const quote = source[index];\n    if (quote !== '\"' && quote !== \"'\") {\n      throw new Error(\"MCP args must be a TOML array containing only strings\");\n    }\n    if (source.slice(index, index + 3) === quote.repeat(3)) {\n      throw new Error(\"Multiline strings are not supported in MCP args\");\n    }\n\n    const token =\n      quote === '\"' ? parseTomlBasicString(source, index) : parseTomlLiteralString(source, index);\n    tokens.push(token);\n    index = skipTomlArrayTrivia(source, token.end);\n\n    if (source[index] === \",\") {\n      index++;\n      continue;\n    }\n    if (source[index] !== \"]\") {\n      throw new Error(\"Expected a comma or closing bracket in MCP args\");\n    }\n  }\n  throw new Error(\"Unterminated TOML array in MCP args\");\n}\n\nfunction findTomlServerArgs(\n  raw: string,\n  serverName: string\n): { start: number; end: number; tokens: TomlStringToken[] } | null {\n  const escapedName = serverName.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n  const tableKey = `(?:mcp_servers|\"mcp_servers\"|'mcp_servers')`;\n  const serverKey = `(?:${escapedName}|\"${escapedName}\"|'${escapedName}')`;\n  const headerRe = new RegExp(\n    `^[\\\\uFEFF\\\\t ]*\\\\[[\\\\t ]*${tableKey}[\\\\t ]*\\\\.[\\\\t ]*${serverKey}[\\\\t ]*\\\\][\\\\t ]*(?:#.*)?\\\\r?$`,\n    \"m\"\n  );\n  const header = headerRe.exec(raw);\n  if (!header) return null;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L94-L130","documentation":"While walking the args array, after a string element the parser found neither a comma nor the closing bracket — i.e. malformed separation, such as a missing comma between elements or stray characters after an element.","triggerScenarios":"args = [\"a\" \"b\"] (missing comma), args = [\"a\"; \"b\"], or trailing garbage like args = [\"a\" x].","commonSituations":"Hand-adding an element and forgetting the comma; using semicolons (JS style) instead of commas; stray characters from a bad paste.","solutions":["Separate elements with commas: args = [\"a\", \"b\"]","Remove stray characters between elements","A trailing comma before ] is fine; missing commas are not"],"exampleFix":"// before\nargs = [\"--a\" \"--b\"]\n// after\nargs = [\"--a\", \"--b\"]","handlingStrategy":"validation","validationCode":"// strip strings then check only commas/brackets/whitespace remain between elements\nconst stripped = arrayBody.replace(/\"[^\"\\\\n]*\"|'[^'\\\\n]*'/g, '');\nif (!/^[\\\\s,]*\\\\]?$/.test(stripped)) throw new Error('bad separator');","typeGuard":"function hasCleanSeparators(arrayBody: string): boolean {\n  return /^[\\\\s,]*$/.test(arrayBody.replace(/\"[^\"\\\\n]*\"|'[^'\\\\n]*'/g, '').replace(/\\\\]$/, ''));\n}","tryCatchPattern":"catch (e) { if (/comma or closing bracket/.test(e.message)) { /* fix separators */ } throw e; }","preventionTips":["Use commas between all elements","Don't use semicolons"],"tags":["toml","syntax-error","array-parsing"],"backgroundTag":"toml-parse-error","analyzedSha":"edc9eeb77bbfc553e08a122ca783293fdb477daf","analyzedAt":"2026-08-28T10:18:41.476Z","contentChangedAt":"2026-08-28T10:18:41.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}