diff --git a/client/src/App.tsx b/client/src/App.tsx index 184f04d9..12e9a7bd 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1526,6 +1526,9 @@ const App = () => { error={errors.prompts} /> { clearError("tools"); diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index ac898235..febea1d8 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -177,6 +177,7 @@ const ToolsTab = ({ error, resourceContent, onReadResource, + serverSupportsTaskRequests, }: { tools: Tool[]; listTools: () => void; @@ -195,6 +196,7 @@ const ToolsTab = ({ error: string | null; resourceContent: Record; onReadResource?: (uri: string) => void; + serverSupportsTaskRequests: boolean; }) => { const [params, setParams] = useState>({}); const [runAsTask, setRunAsTask] = useState(false); @@ -239,15 +241,17 @@ const ToolsTab = ({ ]; }); setParams(Object.fromEntries(params)); - const taskSupport = getTaskSupport(selectedTool); - setRunAsTask(taskSupport === "required"); + const toolTaskSupport = serverSupportsTaskRequests + ? getTaskSupport(selectedTool) + : "forbidden"; + setRunAsTask(toolTaskSupport === "required"); // Reset validation errors when switching tools setHasValidationErrors(false); // Clear form refs for the previous tool formRefs.current = {}; - }, [selectedTool]); + }, [selectedTool, serverSupportsTaskRequests]); const hasReservedMetadataEntry = metadataEntries.some(({ key }) => { const trimmedKey = key.trim(); @@ -264,7 +268,9 @@ const ToolsTab = ({ return trimmedKey !== "" && !hasValidMetaName(trimmedKey); }); - const taskSupport = getTaskSupport(selectedTool); + const taskSupport = serverSupportsTaskRequests + ? getTaskSupport(selectedTool) + : "forbidden"; return ( diff --git a/client/src/components/__tests__/ToolsTab.test.tsx b/client/src/components/__tests__/ToolsTab.test.tsx index 9978aba1..5678914d 100644 --- a/client/src/components/__tests__/ToolsTab.test.tsx +++ b/client/src/components/__tests__/ToolsTab.test.tsx @@ -73,6 +73,7 @@ describe("ToolsTab", () => { error: null, resourceContent: {}, onReadResource: jest.fn(), + serverSupportsTaskRequests: true, }; const renderToolsTab = (props = {}) => { @@ -155,6 +156,38 @@ describe("ToolsTab", () => { expect(requiredCheckbox).toBeDisabled(); }); + it("should hide run-as-task checkbox when serverSupportsTaskRequests is false even for required/optional tools", async () => { + const requiredTool: ExtendedTool = { + ...mockTools[0], + name: "requiredTool", + execution: { taskSupport: "required" }, + }; + const optionalTool: ExtendedTool = { + ...mockTools[0], + name: "optionalTool", + execution: { taskSupport: "optional" }, + }; + + const { rerender } = renderToolsTab({ + selectedTool: requiredTool, + serverSupportsTaskRequests: false, + }); + + expect(screen.queryByLabelText(/run as task/i)).not.toBeInTheDocument(); + + rerender( + + + , + ); + + expect(screen.queryByLabelText(/run as task/i)).not.toBeInTheDocument(); + }); + it("should handle integer type inputs", async () => { renderToolsTab({ selectedTool: mockTools[1], // Use the tool with integer type