langflow-ai/langflow · error · Error
No valid MCP server found in the input.
Error message
No valid MCP server found in the input.
What it means
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.
Source
Thrown at src/frontend/src/utils/mcpUtils.ts:74
Object.values(parsed).some(
(v) => v && typeof v === "object" && ("command" in v || "url" in v),
)
) {
serverEntries = Object.entries(parsed).filter(
([, v]) => v && typeof v === "object" && ("command" in v || "url" in v),
);
}
// Case 3: single server object
else if (
parsed &&
typeof parsed === "object" &&
("command" in parsed || "url" in parsed)
) {
serverEntries = [["server", parsed]];
}
if (serverEntries.length === 0) {
throw new Error("No valid MCP server found in the input.");
}
// Validate and map all servers
const validServers = serverEntries.filter(
([, server]) => server.command || server.url,
);
if (validServers.length === 0) {
throw new Error("No valid MCP server found in the input.");
}
return validServers.map(([name, server]) => ({
name: name.slice(0, 30),
command: server.command,
args: server.args || [],
env: server.env && typeof server.env === "object" ? server.env : {},
url: server.url,
headers:
server.headers && typeof server.headers === "object"
? server.headers
: {},View on GitHub (pinned to 976ec789d2)
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
Example fix
// before
{"servers": {"fs": {"command": "npx"}}}
// after
{"mcpServers": {"fs": {"command": "npx"}}} Defensive patterns
Strategy: type-guard
Validate before calling
const parsed = JSON.parse(text);
const hasServerShape =
(parsed?.mcpServers && typeof parsed.mcpServers === "object") ||
Array.isArray(parsed) ||
(typeof parsed === "object" && ("command" in parsed || "url" in parsed));
if (!hasServerShape) showFormatHint(); Type guard
function looksLikeMcpConfig(v: unknown): boolean {
if (typeof v !== "object" || v === null) return false;
const o = v as Record<string, unknown>;
if (o.mcpServers && typeof o.mcpServers === "object" && Object.keys(o.mcpServers).length > 0) return true;
if (Array.isArray(v) && v.length > 0) return true;
return "command" in o || "url" in o;
} Try / catch
try { extractMcpServersFromJson(input); }
catch (e) {
if (e instanceof Error && e.message.startsWith("No valid MCP server")) {
showAcceptedFormatsHelp();
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Invalid JSON format.
- Invalid flow data
- Failed to install MCP
- Deployment name is required
- error: invalid JSON in {source}: {exc}
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/aa64bbd978eda022.
Report an issue: GitHub.