fix: add error handling and message on mcp servers, fixed tool mode on mcp (#8717)

* Added mcp error handling

* Added error param to servers

* Added error display on mcp servers page

* Added error display on mcp component

* Added error handling for other types of errors

* uv lock update and add error handling

* update mcp version

* fixed tool mode not working on mcp component

* update mcp to 1.9.4

* Removed server parameters custom commands on connection to stdio

* removed unused import

* disable mcp notice

* Removed drop state when home type is mcp

* Added loading before showing tools

* Updated mcp to 1.9.4

* Decreased mcp timeout

* Implemented error surfacing with exec command

* removed non default keys either way when mcp_server is used

* update to session handling

* [autofix.ci] apply automated fixes

* updated it to check if it is the same server to not clear on startup

* update to components

* Update mcp_component.py

* Update mcp_component.py

* Update mcp_component.py

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Lucas Oliveira 2025-06-26 19:22:01 -03:00 • committed by GitHub
commit f4d761e63d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 178 additions and 45 deletions

View file

@ -82,6 +82,7 @@ export default function Dropdown({
// We should only reset the value if it's not in options and not in filteredOptions
// and not a recently added custom value
if (!options.includes(value) && !filteredOptions.includes(value)) {
if (value) onSelect("", undefined, true);
return null;
}
return value;

View file

@ -25,7 +25,9 @@ export default function McpComponent({
name: server.name,
description:
server.toolsCount === null
? "Loading..."
? server.error
? "Error"
: "Loading..."
: !server.toolsCount
? "No actions found"
: `${server.toolsCount} action${server.toolsCount === 1 ? "" : "s"}`,

View file

@ -29,8 +29,16 @@ export const useGetMCPServers: useQueryFunctionType<
if (cachedData && Array.isArray(cachedData)) {
const merged = data.map((server) => {
const cached = cachedData.find((s) => s.name === server.name);
return cached && (cached.toolsCount !== null || cached.mode !== null)
? { ...server, toolsCount: cached.toolsCount, mode: cached.mode }
return cached &&
(cached.toolsCount !== null ||
cached.mode !== null ||
cached.error !== null)
? {
...server,
toolsCount: cached.toolsCount,
mode: cached.mode,
error: cached.error,
}
: server;
});
return merged;

View file

@ -14,4 +14,4 @@ export const ENABLE_WIDGET = true;
export const ENABLE_VOICE_ASSISTANT = true;
export const ENABLE_IMAGE_ON_PLAYGROUND = false;
export const ENABLE_MCP = true;
export const ENABLE_MCP_NOTICE = true;
export const ENABLE_MCP_NOTICE = false;

View file

@ -220,7 +220,7 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
return (
<CardsWrapComponent
onFileDrop={handleFileDrop}
onFileDrop={flowType === "mcp" ? undefined : handleFileDrop}
dragMessage={`Drop your ${isEmptyFolder ? "flows or components" : flowType} here`}
>
<div

View file

@ -1,4 +1,5 @@
import ForwardedIconComponent from "@/components/common/genericIconComponent";
import ShadTooltip from "@/components/common/shadTooltipComponent";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
@ -14,6 +15,7 @@ import AddMcpServerModal from "@/modals/addMcpServerModal";
import DeleteConfirmationModal from "@/modals/deleteConfirmationModal";
import useAlertStore from "@/stores/alertStore";
import { MCPServerInfoType } from "@/types/mcp";
import { cn } from "@/utils/utils";
import { useState } from "react";
export default function MCPServersPage() {
@ -101,11 +103,20 @@ export default function MCPServersPage() {
>
<div className="flex items-center gap-2">
<span className="text-sm font-medium">{server.name}</span>
<span className="text-mmd text-muted-foreground">
{server.toolsCount === null
? "Loading..."
: `${server.toolsCount} action${server.toolsCount === 1 ? "" : "s"}`}
</span>
<ShadTooltip content={server.error}>
<span
className={cn(
"cursor-default select-none !text-mmd text-muted-foreground",
server.error && "text-accent-red-foreground",
)}
>
{server.toolsCount === null
? server.error
? "Error"
: "Loading..."
: `${server.toolsCount} action${server.toolsCount === 1 ? "" : "s"}`}
</span>
</ShadTooltip>
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>

View file

@ -14,6 +14,7 @@ export type MCPServerInfoType = {
description?: string;
mode: string | null;
toolsCount: number | null;
error?: string;
};
export type MCPServerType = {