{"record":{"id":"aa64bbd978eda022","repo":"langflow-ai/langflow","slug":"no-valid-mcp-server-found-in-the-input","errorCode":null,"errorMessage":"No valid MCP server found in the input.","messagePattern":"No valid MCP server found in the input\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/frontend/src/utils/mcpUtils.ts","lineNumber":74,"sourceCode":"    Object.values(parsed).some(\n      (v) => v && typeof v === \"object\" && (\"command\" in v || \"url\" in v),\n    )\n  ) {\n    serverEntries = Object.entries(parsed).filter(\n      ([, v]) => v && typeof v === \"object\" && (\"command\" in v || \"url\" in v),\n    );\n  }\n  // Case 3: single server object\n  else if (\n    parsed &&\n    typeof parsed === \"object\" &&\n    (\"command\" in parsed || \"url\" in parsed)\n  ) {\n    serverEntries = [[\"server\", parsed]];\n  }\n\n  if (serverEntries.length === 0) {\n    throw new Error(\"No valid MCP server found in the input.\");\n  }\n  // Validate and map all servers\n  const validServers = serverEntries.filter(\n    ([, server]) => server.command || server.url,\n  );\n  if (validServers.length === 0) {\n    throw new Error(\"No valid MCP server found in the input.\");\n  }\n  return validServers.map(([name, server]) => ({\n    name: name.slice(0, 30),\n    command: server.command,\n    args: server.args || [],\n    env: server.env && typeof server.env === \"object\" ? server.env : {},\n    url: server.url,\n    headers:\n      server.headers && typeof server.headers === \"object\"\n        ? server.headers\n        : {},","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/frontend/src/utils/mcpUtils.ts#L56-L92","documentation":"Thrown by extractMcpServersFromJson when the input parsed successfully as JSON but none of the recognized shapes matched: no mcpServers object, no top-level array of server configs, and no single object with command/url keys. serverEntries stays empty, so there is nothing that even looks like an MCP server definition.","triggerScenarios":"Passing valid JSON that is a different payload entirely — e.g. an API response, a config with servers nested under a custom key like 'servers' or 'tools', or {mcpServers: {}} with an empty object (falsy, fails the mcpServers check).","commonSituations":"Wrong nesting level (servers under mcpServers.servers), renamed top-level key from a different MCP client's config format, or empty-object configs after sanitization.","solutions":["Restructure the JSON to one of the three accepted shapes: {mcpServers:{name:{command|url,...}}}, an array of {command|url} objects, or a single {command|url} object","Check the key is exactly 'mcpServers' (case-sensitive) and its value is a non-empty object","If migrating from another client format, map its server key into mcpServers before importing"],"exampleFix":"// before\n{\"servers\": {\"fs\": {\"command\": \"npx\"}}}\n\n// after\n{\"mcpServers\": {\"fs\": {\"command\": \"npx\"}}}","handlingStrategy":"type-guard","validationCode":"const parsed = JSON.parse(text);\nconst hasServerShape =\n  (parsed?.mcpServers && typeof parsed.mcpServers === \"object\") ||\n  Array.isArray(parsed) ||\n  (typeof parsed === \"object\" && (\"command\" in parsed || \"url\" in parsed));\nif (!hasServerShape) showFormatHint();","typeGuard":"function looksLikeMcpConfig(v: unknown): boolean {\n  if (typeof v !== \"object\" || v === null) return false;\n  const o = v as Record<string, unknown>;\n  if (o.mcpServers && typeof o.mcpServers === \"object\" && Object.keys(o.mcpServers).length > 0) return true;\n  if (Array.isArray(v) && v.length > 0) return true;\n  return \"command\" in o || \"url\" in o;\n}","tryCatchPattern":"try { extractMcpServersFromJson(input); }\ncatch (e) {\n  if (e instanceof Error && e.message.startsWith(\"No valid MCP server\")) {\n    showAcceptedFormatsHelp();\n  } else throw e;\n}","preventionTips":["Use exactly the mcpServers top-level key (case-sensitive) with a non-empty object","Only import config files produced by a real MCP client","Show the three accepted shapes in the import UI so users self-correct"],"tags":["frontend","mcp","json","validation","config-format"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}