diff --git a/client/src/App.tsx b/client/src/App.tsx index 802c6b08..e17c24ed 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -808,7 +808,7 @@ const App = () => { const callTool = async ( name: string, params: Record, - meta?: Record, + metadata?: Record, ) => { lastToolCallOriginTabRef.current = currentTabRef.current; @@ -824,7 +824,7 @@ const App = () => { const mergedMeta = { ...metadata, // General metadata first progressToken: progressTokenRef.current++, - ...(meta ?? {}), // Tool-specific metadata overrides + ...(metadata ?? {}), // Tool-specific metadata overrides }; const response = await sendMCPRequest( @@ -1148,11 +1148,11 @@ const App = () => { callTool={async ( name: string, params: Record, - meta?: Record, + metadata?: Record, ) => { clearError("tools"); setToolResult(null); - await callTool(name, params, meta); + await callTool(name, params, metadata); }} selectedTool={selectedTool} setSelectedTool={(tool) => { diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index 551862de..4641bab9 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -63,7 +63,7 @@ const ToolsTab = ({ callTool: ( name: string, params: Record, - meta?: Record, + metadata?: Record, ) => Promise; selectedTool: Tool | null; setSelectedTool: (tool: Tool | null) => void; @@ -76,8 +76,8 @@ const ToolsTab = ({ const [params, setParams] = useState>({}); const [isToolRunning, setIsToolRunning] = useState(false); const [isOutputSchemaExpanded, setIsOutputSchemaExpanded] = useState(false); - const [isMetaExpanded, setIsMetaExpanded] = useState(false); - const [metaEntries, setMetaEntries] = useState< + const [isMetadataExpanded, setIsMetadataExpanded] = useState(false); + const [metadataEntries, setMetadataEntries] = useState< { id: string; key: string; value: string }[] >([]); const [hasValidationErrors, setHasValidationErrors] = useState(false); @@ -400,7 +400,7 @@ const ToolsTab = ({ variant="outline" className="h-6 px-2" onClick={() => - setMetaEntries((prev) => [ + setMetadataEntries((prev) => [ ...prev, { id: @@ -419,30 +419,30 @@ const ToolsTab = ({ Add Pair - {metaEntries.length === 0 ? ( + {metadataEntries.length === 0 ? (

- No meta pairs. + No metadata pairs.

) : (
- {metaEntries.map((entry, index) => ( + {metadataEntries.map((entry, index) => (
{ const value = e.target.value; - setMetaEntries((prev) => + setMetadataEntries((prev) => prev.map((m, i) => i === index ? { ...m, key: value } : m, ), @@ -451,18 +451,18 @@ const ToolsTab = ({ className="h-8 flex-1" /> { const value = e.target.value; - setMetaEntries((prev) => + setMetadataEntries((prev) => prev.map((m, i) => i === index ? { ...m, value } : m, ), @@ -475,7 +475,7 @@ const ToolsTab = ({ variant="ghost" className="h-8 w-8 p-0 ml-auto shrink-0" onClick={() => - setMetaEntries((prev) => + setMetadataEntries((prev) => prev.filter((_, i) => i !== index), ) } @@ -533,10 +533,12 @@ const ToolsTab = ({
@@ -565,17 +569,16 @@ const ToolsTab = ({ try { setIsToolRunning(true); - const meta = metaEntries.reduce>( - (acc, { key, value }) => { - if (key.trim() !== "") acc[key] = value; - return acc; - }, - {}, - ); + const metadata = metadataEntries.reduce< + Record + >((acc, { key, value }) => { + if (key.trim() !== "") acc[key] = value; + return acc; + }, {}); await callTool( selectedTool.name, params, - Object.keys(meta).length ? meta : undefined, + Object.keys(metadata).length ? metadata : undefined, ); } finally { setIsToolRunning(false); diff --git a/client/src/components/__tests__/ToolsTab.test.tsx b/client/src/components/__tests__/ToolsTab.test.tsx index 0c20e7c8..3e07d017 100644 --- a/client/src/components/__tests__/ToolsTab.test.tsx +++ b/client/src/components/__tests__/ToolsTab.test.tsx @@ -716,10 +716,10 @@ describe("ToolsTab", () => { }); }); - describe("Meta Display", () => { - const toolWithMeta = { + describe("Metadata Display", () => { + const toolWithMetadata = { name: "metaTool", - description: "Tool with meta", + description: "Tool with metadata", inputSchema: { type: "object" as const, properties: { @@ -732,10 +732,10 @@ describe("ToolsTab", () => { }, } as unknown as Tool; - it("should display meta section when tool has _meta", () => { + it("should display metadata section when tool has _meta", () => { renderToolsTab({ - tools: [toolWithMeta], - selectedTool: toolWithMeta, + tools: [toolWithMetadata], + selectedTool: toolWithMetadata, }); expect(screen.getByText("Meta:")).toBeInTheDocument(); @@ -744,10 +744,10 @@ describe("ToolsTab", () => { ).toBeInTheDocument(); }); - it("should toggle meta schema expansion", () => { + it("should toggle metadata schema expansion", () => { renderToolsTab({ - tools: [toolWithMeta], - selectedTool: toolWithMeta, + tools: [toolWithMetadata], + selectedTool: toolWithMetadata, }); // There might be multiple Expand buttons (Output Schema, Meta). We need the one within Meta section @@ -777,13 +777,13 @@ describe("ToolsTab", () => { }); }); - describe("Meta submission", () => { - it("should send meta values when provided", async () => { + describe("Metadata submission", () => { + it("should send metadata values when provided", async () => { const callToolMock = jest.fn(async () => {}); renderToolsTab({ selectedTool: mockTools[0], callTool: callToolMock }); - // Add a meta key/value pair + // Add a metadata key/value pair const addPairButton = screen.getByRole("button", { name: /add pair/i }); await act(async () => { fireEvent.click(addPairButton); @@ -815,19 +815,19 @@ describe("ToolsTab", () => { }); }); - describe("ToolResults Meta", () => { - it("should display meta information when present in toolResult", () => { - const resultWithMeta = { + describe("ToolResults Metadata", () => { + it("should display metadata information when present in toolResult", () => { + const resultWithMetadata = { content: [], _meta: { info: "details", version: 2 }, }; renderToolsTab({ selectedTool: mockTools[0], - toolResult: resultWithMeta, + toolResult: resultWithMetadata, }); - // Only ToolResults meta should be present since selectedTool has no _meta + // Only ToolResults metadata should be present since selectedTool has no _meta expect(screen.getAllByText("Meta:")).toHaveLength(1); expect(screen.getByText(/info/i)).toBeInTheDocument(); expect(screen.getByText(/version/i)).toBeInTheDocument(); diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index 4f639c08..4584ff0a 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -167,9 +167,9 @@ export function useConnection({ // Add metadata to the request if available, but skip for tool calls // as they handle metadata merging separately - const shouldAddGeneralMeta = + const shouldAddGeneralMetadata = request.method !== "tools/call" && Object.keys(metadata).length > 0; - const requestWithMeta = shouldAddGeneralMeta + const requestWithMetadata = shouldAddGeneralMetadata ? { ...request, params: { @@ -208,16 +208,16 @@ export function useConnection({ let response; try { response = await mcpClient.request( - requestWithMeta, + requestWithMetadata, schema, mcpRequestOptions, ); - pushHistory(requestWithMeta, response); + pushHistory(requestWithMetadata, response); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - pushHistory(requestWithMeta, { error: errorMessage }); + pushHistory(requestWithMetadata, { error: errorMessage }); throw error; }