Fix review issues from Claude's code review

- Default taskSupport fallback to "forbidden" per MCP spec (was "optional")
- Fix import path to use @/ alias consistently
- Fix misleading "type guard" comment on getTaskSupport
- Extract getTaskSupport to a variable to avoid duplicate calls in render
- Export ExtendedTool and import in tests instead of duplicating

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-02-23 11:15:53 -05:00
commit f64a7ea6e3

View file

@ -51,12 +51,12 @@ import {
hasValidMetaName,
hasValidMetaPrefix,
isReservedMetaKey,
} from "../utils/metaUtils";
} from "@/utils/metaUtils";
/**
* Extended Tool type that includes optional fields used by the inspector.
*/
interface ExtendedTool extends Tool, WithIcons {
export interface ExtendedTool extends Tool, WithIcons {
_meta?: Record<string, unknown>;
execution?: {
taskSupport?: "forbidden" | "required" | "optional";
@ -69,7 +69,7 @@ const hasMeta = (
): tool is ExtendedTool & { _meta: Record<string, unknown> } =>
typeof (tool as ExtendedTool)._meta !== "undefined";
// Type guard to detect execution.taskSupport
// Returns the execution.taskSupport value for a tool, defaulting to "forbidden" per MCP spec
const getTaskSupport = (
tool: Tool | null,
): "forbidden" | "required" | "optional" => {
@ -83,7 +83,7 @@ const getTaskSupport = (
) {
return taskSupport;
}
return "optional";
return "forbidden";
};
// Type guard to safely detect the optional annotations field
@ -264,6 +264,8 @@ const ToolsTab = ({
return trimmedKey !== "" && !hasValidMetaName(trimmedKey);
});
const taskSupport = getTaskSupport(selectedTool);
return (
<TabsContent value="tools">
<div className="grid grid-cols-2 gap-4">
@ -777,7 +779,7 @@ const ToolsTab = ({
</div>
</div>
)}
{getTaskSupport(selectedTool) !== "forbidden" && (
{taskSupport !== "forbidden" && (
<div className="flex items-center space-x-2">
<Checkbox
id="run-as-task"
@ -785,7 +787,7 @@ const ToolsTab = ({
onCheckedChange={(checked: boolean) =>
setRunAsTask(checked)
}
disabled={getTaskSupport(selectedTool) === "required"}
disabled={taskSupport === "required"}
/>
<Label
htmlFor="run-as-task"