{"record":{"id":"b1b9d5a106f61950","repo":"upstash/context7","slug":"mcp-args-must-be-a-toml-array-containing-only-stri","errorCode":null,"errorMessage":"MCP args must be a TOML array containing only strings","messagePattern":"MCP args must be a TOML array containing only strings","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":96,"sourceCode":"  }\n  return { value, start, end: endQuote + 1 };\n}\n\nfunction parseTomlStringArray(\n  source: string,\n  start: number\n): { tokens: TomlStringToken[]; end: number } {\n  if (source[start] !== \"[\") throw new Error(\"Expected a TOML array for MCP args\");\n\n  const tokens: TomlStringToken[] = [];\n  let index = start + 1;\n  while (index < source.length) {\n    index = skipTomlArrayTrivia(source, index);\n    if (source[index] === \"]\") return { tokens, end: index + 1 };\n\n    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  }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L78-L114","documentation":"Inside the args array, an element does not start with a quote — every element must be a quoted string (basic or literal). Numbers, booleans, nested arrays, or bare words trigger this.","triggerScenarios":"args = [8080], args = [true], args = [--flag] (bare word), or args = [[\"a\"]] (nested array).","commonSituations":"Port numbers or flags written without quotes; JSON-style mixed arrays pasted in; forgetting TOML requires quoted strings in this context.","solutions":["Quote every element: args = [\"8080\", \"true\", \"--flag\"]","Remove non-string elements — the tool expects string args only","Validate the file with a TOML linter"],"exampleFix":"// before\nargs = [\"--port\", 8080]\n// after\nargs = [\"--port\", \"8080\"]","handlingStrategy":"validation","validationCode":"// after locating the array body, every element must start with a quote\nconst elems = arrayBody.split(',').map(e => e.trim());\nif (elems.some(e => e && !e.startsWith('\"') && !e.startsWith(\"'\"))) throw new Error('non-string element');","typeGuard":"function isStringOnlyArray(source: string): boolean {\n  return /^\\\\[[\\\\s]*(\"[^\"\\\\n]*\"|'[^'\\\\n]*')(\\\\s*,\\\\s*(\"[^\"\\\\n]*\"|'[^'\\\\n]*'))*\\\\s*\\\\]?/.test(source.trim()) || source.trim() === '[]';\n}","tryCatchPattern":"catch (e) { if (/only strings/.test(e.message)) { /* quote the offending element */ } throw e; }","preventionTips":["Quote every array element including numbers","Don't paste JSON arrays verbatim"],"tags":["toml","array-element","string-expected","mcp"],"backgroundTag":"toml-type-mismatch","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"}