Phase 2: Refactor Tools cluster to use MCP SDK types

Replace ad hoc local types with MCP SDK schema types across the Tools
group components and ToolsScreen, per the v2 UX interfaces plan.

- ToolListItem: accept `tool: Tool` instead of flat `name`/`title`
- ToolControls: accept `Tool[]` + `selectedName` instead of `ToolListItemProps[]`
- ToolDetailPanel: accept `tool: Tool` instead of flat props; use SDK
  `ToolAnnotations` (readOnlyHint/destructiveHint/idempotentHint/openWorldHint);
  use `ProgressNotification['params']` for progress
- ToolResultPanel: accept `CallToolResult` instead of `ResultContentItem[]`
- ToolsScreen: accept `Tool[]` + `selectedToolName` + `ToolCallState`;
  derive selected tool via `tools.find()`; own `formValues` state locally
- Delete local `ToolAnnotations`, `ResultContentItem` types
- Update all stories with real SDK `Tool` fixtures
- Update ConnectedView ToolsActive story

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-18 16:57:10 -04:00
commit 92ecfcbd6c
2 changed files with 388 additions and 411 deletions

View file

@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
import { fn } from "storybook/test";
import { ToolListItem } from "./ToolListItem";
@ -13,31 +14,44 @@ const meta: Meta<typeof ToolListItem> = {
export default meta;
type Story = StoryObj<typeof ToolListItem>;
const weatherTool: Tool = {
name: "get_weather",
inputSchema: { type: "object" },
};
const weatherToolWithTitle: Tool = {
name: "get_weather",
title: "Get Weather",
inputSchema: { type: "object" },
};
export const Default: Story = {
args: {
name: "get_weather",
tool: weatherTool,
selected: false,
},
};
export const Selected: Story = {
args: {
name: "get_weather",
tool: weatherTool,
selected: true,
},
};
export const WithTitle: Story = {
args: {
name: "get_weather",
title: "Get Weather",
tool: weatherToolWithTitle,
selected: false,
},
};
export const LongName: Story = {
args: {
name: "this_is_a_very_long_tool_name_that_might_need_to_wrap_across_multiple_lines_in_the_ui",
tool: {
name: "this_is_a_very_long_tool_name_that_might_need_to_wrap_across_multiple_lines_in_the_ui",
inputSchema: { type: "object" },
},
selected: false,
},
};

View file

@ -1,8 +1,8 @@
import { Stack, Text, UnstyledButton } from "@mantine/core";
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
export interface ToolListItemProps {
name: string;
title?: string;
tool: Tool;
selected: boolean;
onClick: () => void;
}
@ -22,12 +22,8 @@ function resolveLabel(name: string, title?: string): string {
return title ?? name;
}
export function ToolListItem({
name,
title,
selected,
onClick,
}: ToolListItemProps) {
export function ToolListItem({ tool, selected, onClick }: ToolListItemProps) {
const { name, title } = tool;
return (
<UnstyledButton
w="100%"