diff --git a/client/src/components/DynamicJsonForm.tsx b/client/src/components/DynamicJsonForm.tsx index 7da1762..f5b0d63 100644 --- a/client/src/components/DynamicJsonForm.tsx +++ b/client/src/components/DynamicJsonForm.tsx @@ -108,6 +108,21 @@ const DynamicJsonForm = ({ } }; + const formatJson = () => { + try { + const jsonStr = rawJsonValue.trim(); + if (!jsonStr) { + return; + } + const formatted = JSON.stringify(JSON.parse(jsonStr), null, 2); + setRawJsonValue(formatted); + debouncedUpdateParent(formatted); + setJsonError(undefined); + } catch (err) { + setJsonError(err instanceof Error ? err.message : "Invalid JSON"); + } + }; + const renderFormFields = ( propSchema: JsonSchemaType, currentValue: JsonValue, @@ -353,7 +368,12 @@ const DynamicJsonForm = ({ return (
- {JSON.stringify(JSON.parse(request.request), null, 2)}
-
+
- {JSON.stringify(
- JSON.parse(request.response),
- null,
- 2,
- )}
-
+
- {JSON.stringify(notification, null, 2)}
-
+ "{value}"
+ setIsExpanded(!isExpanded)}
+ title={isExpanded ? "Click to collapse" : "Click to expand"}
+ >
+ {isExpanded ? `"${value}"` : `"${value.slice(0, maxLength)}..."`}
+
+
- {resourceContent}
-
+ diff --git a/client/src/components/SamplingTab.tsx b/client/src/components/SamplingTab.tsx index 5c45400..21fc7dd 100644 --- a/client/src/components/SamplingTab.tsx +++ b/client/src/components/SamplingTab.tsx @@ -5,6 +5,7 @@ import { CreateMessageRequest, CreateMessageResult, } from "@modelcontextprotocol/sdk/types.js"; +import JsonView from "./JsonView"; export type PendingRequest = { id: number; @@ -43,9 +44,9 @@ const SamplingTab = ({ pendingRequests, onApprove, onReject }: Props) => {
- {JSON.stringify(request.request, null, 2)}
-
+
- {escapeUnicode(toolResult)}
-
+
- {escapeUnicode(error)}
-
+
- {item.text}
-
+
- {escapeUnicode(item.resource)}
-
+
- {escapeUnicode(toolResult.toolResult)}
-
+