@miragon/mcp-toolkit-ui 0.10.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/app/adapt-data-widget.d.ts +26 -5
- package/dist/app/adapt-data-widget.d.ts.map +1 -1
- package/dist/app/adapt-data-widget.js +39 -5
- package/dist/app/adapt-data-widget.js.map +1 -1
- package/dist/app/host-bridge.d.ts +52 -46
- package/dist/app/host-bridge.d.ts.map +1 -1
- package/dist/app/host-bridge.js +30 -52
- package/dist/app/host-bridge.js.map +1 -1
- package/dist/app/index.d.ts +5 -4
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +9 -8
- package/dist/app/index.js.map +1 -1
- package/dist/app/mcp-app-view.d.ts.map +1 -1
- package/dist/app/mcp-app-view.js +37 -24
- package/dist/app/mcp-app-view.js.map +1 -1
- package/dist/app/mcp-toolkit-app.d.ts +21 -10
- package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
- package/dist/app/mcp-toolkit-app.js +26 -12
- package/dist/app/mcp-toolkit-app.js.map +1 -1
- package/dist/app/mcp-use-host-bridge.d.ts +29 -0
- package/dist/app/mcp-use-host-bridge.d.ts.map +1 -0
- package/dist/app/mcp-use-host-bridge.js +120 -0
- package/dist/app/mcp-use-host-bridge.js.map +1 -0
- package/dist/app/use-host-actions.d.ts +6 -6
- package/dist/app/use-host-actions.js +6 -6
- package/dist/app/widget-fixture.d.ts +24 -21
- package/dist/app/widget-fixture.d.ts.map +1 -1
- package/dist/app/widget-fixture.js +27 -123
- package/dist/app/widget-fixture.js.map +1 -1
- package/dist/hooks/use-tool-result-recovery.d.ts +40 -15
- package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
- package/dist/hooks/use-tool-result-recovery.js +57 -4
- package/dist/hooks/use-tool-result-recovery.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +16 -8
- package/src/app/adapt-data-widget.tsx +50 -6
- package/src/app/host-bridge.test.ts +107 -0
- package/src/app/host-bridge.tsx +85 -82
- package/src/app/index.ts +15 -10
- package/src/app/mcp-app-view.tsx +41 -32
- package/src/app/mcp-toolkit-app.tsx +33 -16
- package/src/app/mcp-use-host-bridge.tsx +164 -0
- package/src/app/use-host-actions.tsx +6 -6
- package/src/app/widget-fixture.tsx +35 -156
- package/src/hooks/use-tool-result-recovery.ts +75 -19
- package/src/index.ts +1 -1
- package/ui-catalog.json +81 -27
package/ui-catalog.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$comment": "Machine-readable catalog of prompt-relevant @miragon/mcp-toolkit-ui building blocks. Hand-maintained, source of truth is packages/ui/src/. A Vitest drift-guard (src/ui-catalog.test.ts) asserts every `export` named here is actually exported from its `importPath` barrel, so this file cannot silently drift from the code. Consumed by the docs/reference/components.md page and the build-mcp-widget skill. Versioned by the @miragon/mcp-toolkit-ui tarball it ships in
|
|
2
|
+
"$comment": "Machine-readable catalog of prompt-relevant @miragon/mcp-toolkit-ui building blocks. Hand-maintained, source of truth is packages/ui/src/. A Vitest drift-guard (src/ui-catalog.test.ts) asserts every `export` named here is actually exported from its `importPath` barrel, so this file cannot silently drift from the code. Consumed by the docs/reference/components.md page and the build-mcp-widget skill. Versioned by the @miragon/mcp-toolkit-ui tarball it ships in — it carries no version field of its own. `importPath` is one of: '@miragon/mcp-toolkit-ui' (root barrel, mcp-use/react-free), '@miragon/mcp-toolkit-ui/app' (MCP app shell, imports mcp-use/react), '@miragon/mcp-toolkit-ui/hooks' (view-tool hooks).",
|
|
3
3
|
"importPaths": {
|
|
4
4
|
"root": "@miragon/mcp-toolkit-ui",
|
|
5
5
|
"app": "@miragon/mcp-toolkit-ui/app",
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
"description": "Size the placeholder (e.g. 'h-20 w-full')."
|
|
317
317
|
}
|
|
318
318
|
],
|
|
319
|
-
"whenToUse": "Loading placeholder while a self-fetch is in flight
|
|
319
|
+
"whenToUse": "Loading placeholder while a self-fetch is in flight — avoids layout shift on first paint."
|
|
320
320
|
},
|
|
321
321
|
{
|
|
322
322
|
"name": "Separator",
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
"name": "span",
|
|
369
369
|
"type": "number",
|
|
370
370
|
"required": false,
|
|
371
|
-
"description": "Column span 1
|
|
371
|
+
"description": "Column span 1–12. Default 12 (full width); out-of-range falls back to full width."
|
|
372
372
|
},
|
|
373
373
|
{
|
|
374
374
|
"name": "children",
|
|
@@ -396,7 +396,7 @@
|
|
|
396
396
|
"name": "cells",
|
|
397
397
|
"type": "KpiCell[]",
|
|
398
398
|
"required": true,
|
|
399
|
-
"description": "Metric cells flowed as columns (1
|
|
399
|
+
"description": "Metric cells flowed as columns (1–6, clamped). Each: { label, value, fraction?, trend?, trendDirection?, tone?, onClick?, ariaLabel? }. A cell with onClick renders as a button (drill into a detail view)."
|
|
400
400
|
},
|
|
401
401
|
{
|
|
402
402
|
"name": "boxed",
|
|
@@ -433,7 +433,7 @@
|
|
|
433
433
|
"description": "Pill label. Defaults to 'Live'."
|
|
434
434
|
}
|
|
435
435
|
],
|
|
436
|
-
"whenToUse": "Signal live/real-time data in a widget header
|
|
436
|
+
"whenToUse": "Signal live/real-time data in a widget header — a tinted pill with a pulsing dot."
|
|
437
437
|
},
|
|
438
438
|
{
|
|
439
439
|
"name": "CountPill",
|
|
@@ -594,7 +594,7 @@
|
|
|
594
594
|
"name": "searchPlaceholder",
|
|
595
595
|
"type": "string",
|
|
596
596
|
"required": false,
|
|
597
|
-
"description": "Placeholder for the search input. Default 'Filter
|
|
597
|
+
"description": "Placeholder for the search input. Default 'Filter…'."
|
|
598
598
|
}
|
|
599
599
|
],
|
|
600
600
|
"whenToUse": "Filter a list/table of widget items with a search box + chip row. Pair with useDebouncedValue so a server-side filter only re-queries once typing pauses."
|
|
@@ -616,13 +616,13 @@
|
|
|
616
616
|
"name": "onDrill",
|
|
617
617
|
"type": "() => void",
|
|
618
618
|
"required": true,
|
|
619
|
-
"description": "Drill/navigation handler
|
|
619
|
+
"description": "Drill/navigation handler — wire to in-widget navigation (e.g. useHostActions().showWidget)."
|
|
620
620
|
},
|
|
621
621
|
{
|
|
622
622
|
"name": "icon",
|
|
623
623
|
"type": "ReactNode",
|
|
624
624
|
"required": false,
|
|
625
|
-
"description": "Optional leading glyph; the trailing
|
|
625
|
+
"description": "Optional leading glyph; the trailing → is always rendered."
|
|
626
626
|
},
|
|
627
627
|
{
|
|
628
628
|
"name": "size",
|
|
@@ -805,7 +805,7 @@
|
|
|
805
805
|
"description": "Gate the query."
|
|
806
806
|
}
|
|
807
807
|
],
|
|
808
|
-
"whenToUse": "Self-fetch from a *_show_* widget tool. Unwraps the McpAppView view envelope via parseViewToolResult (single-step
|
|
808
|
+
"whenToUse": "Self-fetch from a *_show_* widget tool. Unwraps the McpAppView view envelope via parseViewToolResult (single-step → flat data, multi-step → keyed by step id) — the envelope-aware sibling of useToolQuery."
|
|
809
809
|
},
|
|
810
810
|
{
|
|
811
811
|
"name": "useViewData",
|
|
@@ -863,7 +863,7 @@
|
|
|
863
863
|
"kind": "hook",
|
|
864
864
|
"group": "host-hooks",
|
|
865
865
|
"props": [],
|
|
866
|
-
"whenToUse": "THE host seam for portable widgets. Returns a HostBridge { callTool, sendFollowup, openExternal, getWidgetData, setModelContext?, theme? }. Use this instead of mcp-use/react or window.openai directly so the same widget runs in the mcp-use host, ChatGPT, or standalone.
|
|
866
|
+
"whenToUse": "THE host seam for portable widgets. Returns a HostBridge { callTool, sendFollowup, openExternal, getWidgetData, setModelContext?, theme? }. Use this instead of mcp-use/react or window.openai directly so the same widget runs in the mcp-use host, ChatGPT, or standalone. Requires a provider: McpToolkitApp (toolkit host), WidgetFixtureHost (dev), or an explicit HostBridgeProvider."
|
|
867
867
|
},
|
|
868
868
|
{
|
|
869
869
|
"name": "useHostActions",
|
|
@@ -894,7 +894,7 @@
|
|
|
894
894
|
"description": "Natural-language description of what to show."
|
|
895
895
|
}
|
|
896
896
|
],
|
|
897
|
-
"whenToUse": "Build the intent string for host.showWidget(...)
|
|
897
|
+
"whenToUse": "Build the intent string for host.showWidget(...) — appends a '(use <toolName>)' hint so the agent picks the right tool unambiguously."
|
|
898
898
|
},
|
|
899
899
|
{
|
|
900
900
|
"name": "HostBridgeProvider",
|
|
@@ -907,7 +907,7 @@
|
|
|
907
907
|
"name": "bridge",
|
|
908
908
|
"type": "HostBridge",
|
|
909
909
|
"required": true,
|
|
910
|
-
"description": "The explicit bridge to provide (createChatGptHostBridge / createStandaloneHostBridge
|
|
910
|
+
"description": "The explicit bridge to provide (createChatGptHostBridge / createStandaloneHostBridge, or toHostBridge over a custom surface)."
|
|
911
911
|
},
|
|
912
912
|
{
|
|
913
913
|
"name": "children",
|
|
@@ -916,7 +916,23 @@
|
|
|
916
916
|
"description": "Subtree whose useHostBridge() resolves to this bridge."
|
|
917
917
|
}
|
|
918
918
|
],
|
|
919
|
-
"whenToUse": "Wrap a portable widget in the bridge for the host it runs in.
|
|
919
|
+
"whenToUse": "Wrap a portable widget in the bridge for the host it runs in. Inside the toolkit's own host you do not need it — McpToolkitApp installs the mcp-use bridge via McpUseHostBridgeProvider."
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
"name": "McpUseHostBridgeProvider",
|
|
923
|
+
"export": "McpUseHostBridgeProvider",
|
|
924
|
+
"importPath": "@miragon/mcp-toolkit-ui/app",
|
|
925
|
+
"kind": "component",
|
|
926
|
+
"group": "host-hooks",
|
|
927
|
+
"props": [
|
|
928
|
+
{
|
|
929
|
+
"name": "children",
|
|
930
|
+
"type": "ReactNode",
|
|
931
|
+
"required": true,
|
|
932
|
+
"description": "Subtree whose useHostBridge() resolves to the mcp-use bridge."
|
|
933
|
+
}
|
|
934
|
+
],
|
|
935
|
+
"whenToUse": "Composes the mcp-use 2.x view hooks into the HostBridge and provides it. Already included in McpToolkitApp — reach for it only when building a custom shell under your own bootstrapView call. Throws outside a bootstrapView-mounted view."
|
|
920
936
|
},
|
|
921
937
|
{
|
|
922
938
|
"name": "createStandaloneHostBridge",
|
|
@@ -932,7 +948,7 @@
|
|
|
932
948
|
"description": "{ callTool (required), getData?, onFollowup?, onOpenExternal?, onModelContext?, theme? }."
|
|
933
949
|
}
|
|
934
950
|
],
|
|
935
|
-
"whenToUse": "Build a HostBridge for a standalone web app against any MCP server (callTool usually wraps a @modelcontextprotocol/
|
|
951
|
+
"whenToUse": "Build a HostBridge for a standalone web app against any MCP server (callTool usually wraps a @modelcontextprotocol/client client). The WidgetFixtureHost builds on this too."
|
|
936
952
|
},
|
|
937
953
|
{
|
|
938
954
|
"name": "createChatGptHostBridge",
|
|
@@ -948,7 +964,7 @@
|
|
|
948
964
|
"description": "Explicit window.openai for testing; defaults to the real one."
|
|
949
965
|
}
|
|
950
966
|
],
|
|
951
|
-
"whenToUse": "Build a HostBridge mapping the bridge verbs onto the OpenAI Apps SDK (ChatGPT). Defensive
|
|
967
|
+
"whenToUse": "Build a HostBridge mapping the bridge verbs onto the OpenAI Apps SDK (ChatGPT). Defensive — missing host methods degrade to logged no-ops."
|
|
952
968
|
},
|
|
953
969
|
{
|
|
954
970
|
"name": "adaptDataWidget",
|
|
@@ -961,7 +977,7 @@
|
|
|
961
977
|
"name": "Widget",
|
|
962
978
|
"type": "ComponentType<{ data: T | null } & Record<string, unknown>>",
|
|
963
979
|
"required": true,
|
|
964
|
-
"description": "A single-data widget
|
|
980
|
+
"description": "A single-data widget — write it as ({ data }) and it stays host-agnostic."
|
|
965
981
|
},
|
|
966
982
|
{
|
|
967
983
|
"name": "dataType",
|
|
@@ -973,11 +989,33 @@
|
|
|
973
989
|
"name": "describeForModel",
|
|
974
990
|
"type": "DescribeForModel<T>",
|
|
975
991
|
"required": false,
|
|
976
|
-
"description": "(data, props) => string. Wraps the widget in <
|
|
992
|
+
"description": "(data, props) => string. Wraps the widget in <HostModelContext> so the model knows what the user is looking at."
|
|
977
993
|
}
|
|
978
994
|
],
|
|
979
995
|
"whenToUse": "Register a hand-built ({ data }) widget as a framework WidgetComponent. The adapter finds the matching step in context.steps[_dataType].data and forwards result.data as the data prop, and spreads per-cell layout props. Lets render-view and *_show_* tools share one widget."
|
|
980
996
|
},
|
|
997
|
+
{
|
|
998
|
+
"name": "HostModelContext",
|
|
999
|
+
"export": "HostModelContext",
|
|
1000
|
+
"importPath": "@miragon/mcp-toolkit-ui/app",
|
|
1001
|
+
"kind": "component",
|
|
1002
|
+
"group": "widget-authoring",
|
|
1003
|
+
"props": [
|
|
1004
|
+
{
|
|
1005
|
+
"name": "content",
|
|
1006
|
+
"type": "string",
|
|
1007
|
+
"required": true,
|
|
1008
|
+
"description": "The model-facing description of what the user is looking at (view identity, filters, headline numbers)."
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
"name": "children",
|
|
1012
|
+
"type": "ReactNode",
|
|
1013
|
+
"required": true,
|
|
1014
|
+
"description": "The widget subtree the description belongs to."
|
|
1015
|
+
}
|
|
1016
|
+
],
|
|
1017
|
+
"whenToUse": "Report model context from a widget that self-fetches (cockpit views) — the host-portable replacement for mcp-use/react's ModelContext. Inside an mcp-use view it renders the native aggregating ModelContext; in every other mount (widget playground, ChatGPT, standalone) it routes through the HostBridge's setModelContext. NEVER import ModelContext from mcp-use/react in a widget: it throws outside a bootstrapView mount."
|
|
1018
|
+
},
|
|
981
1019
|
{
|
|
982
1020
|
"name": "DescribeForModel",
|
|
983
1021
|
"export": "DescribeForModel",
|
|
@@ -992,7 +1030,7 @@
|
|
|
992
1030
|
"description": "The describeForModel callback signature for adaptDataWidget."
|
|
993
1031
|
}
|
|
994
1032
|
],
|
|
995
|
-
"whenToUse": "Type the model-context line builder you pass to adaptDataWidget
|
|
1033
|
+
"whenToUse": "Type the model-context line builder you pass to adaptDataWidget — report view identity, active filters, and headline numbers so the agent has context on the next turn."
|
|
996
1034
|
},
|
|
997
1035
|
{
|
|
998
1036
|
"name": "parseToolResult",
|
|
@@ -1014,7 +1052,7 @@
|
|
|
1014
1052
|
"description": "Channel preference. Default 'structured' (structuredContent-first)."
|
|
1015
1053
|
}
|
|
1016
1054
|
],
|
|
1017
|
-
"whenToUse": "Decode a raw callTool result to its data payload. Structured-first: isError
|
|
1055
|
+
"whenToUse": "Decode a raw callTool result to its data payload. Structured-first: isError → throw, then structuredContent, then JSON-decoded text, then raw. useToolQuery decodes through this for you."
|
|
1018
1056
|
},
|
|
1019
1057
|
{
|
|
1020
1058
|
"name": "parseViewToolResult",
|
|
@@ -1030,7 +1068,7 @@
|
|
|
1030
1068
|
"description": "The raw result of a *_show_* widget tool."
|
|
1031
1069
|
}
|
|
1032
1070
|
],
|
|
1033
|
-
"whenToUse": "Unwrap a *_show_* view envelope (context.stepData) to the flat widget data: single-step
|
|
1071
|
+
"whenToUse": "Unwrap a *_show_* view envelope (context.stepData) to the flat widget data: single-step → that step's data; multi-step → object keyed by step id. Non-envelope results pass through parseToolResult."
|
|
1034
1072
|
},
|
|
1035
1073
|
{
|
|
1036
1074
|
"name": "cn",
|
|
@@ -1108,7 +1146,7 @@
|
|
|
1108
1146
|
"description": "Subtree that inherits the theme's CSS variables and dark class."
|
|
1109
1147
|
}
|
|
1110
1148
|
],
|
|
1111
|
-
"whenToUse": "Wrap a widget (or a whole app) to apply a ThemeDefinition. Renders a wrapper carrying the theme's CSS variables inline (overriding :root) and toggles the .dark class on the scope per mode. React + DOM only
|
|
1149
|
+
"whenToUse": "Wrap a widget (or a whole app) to apply a ThemeDefinition. Renders a wrapper carrying the theme's CSS variables inline (overriding :root) and toggles the .dark class on the scope per mode. React + DOM only — no host required."
|
|
1112
1150
|
},
|
|
1113
1151
|
{
|
|
1114
1152
|
"name": "useTheme",
|
|
@@ -1126,7 +1164,7 @@
|
|
|
1126
1164
|
"kind": "object",
|
|
1127
1165
|
"group": "theming",
|
|
1128
1166
|
"props": [],
|
|
1129
|
-
"whenToUse": "Ready-made white-label themes (themePresets.miragon, .violet, .emerald)
|
|
1167
|
+
"whenToUse": "Ready-made white-label themes (themePresets.miragon, .violet, .emerald) — a demonstration of createTheme and a fork-able starting point. Pass one to ThemeProvider's theme prop."
|
|
1130
1168
|
},
|
|
1131
1169
|
{
|
|
1132
1170
|
"name": "LocaleProvider",
|
|
@@ -1154,7 +1192,7 @@
|
|
|
1154
1192
|
"description": "Subtree whose widgets read the locale via useLocale/useTranslate."
|
|
1155
1193
|
}
|
|
1156
1194
|
],
|
|
1157
|
-
"whenToUse": "Wrap a widget (or a whole app) to provide the active locale + an optional translator. Widgets read it with useLocale/useTranslate. Pure React (no host required), mirroring ThemeProvider
|
|
1195
|
+
"whenToUse": "Wrap a widget (or a whole app) to provide the active locale + an optional translator. Widgets read it with useLocale/useTranslate. Pure React (no host required), mirroring ThemeProvider — pairs with createTranslator from @miragon/mcp-toolkit-core."
|
|
1158
1196
|
},
|
|
1159
1197
|
{
|
|
1160
1198
|
"name": "useLocale",
|
|
@@ -1200,7 +1238,23 @@
|
|
|
1200
1238
|
"description": "Override UI strings (loading, refresh, fullscreen)."
|
|
1201
1239
|
}
|
|
1202
1240
|
],
|
|
1203
|
-
"whenToUse": "The
|
|
1241
|
+
"whenToUse": "The consumer root for the widget bundle — mount it with mountMcpToolkitApp, which wraps mcp-use's bootstrapView (ext-apps handshake, error boundary, auto-resize). Composes ThemeProvider and McpUseHostBridgeProvider around McpAppView. You usually do NOT write this when authoring a single widget; you register the widget in its widgets map."
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
"name": "mountMcpToolkitApp",
|
|
1245
|
+
"export": "mountMcpToolkitApp",
|
|
1246
|
+
"importPath": "@miragon/mcp-toolkit-ui/app",
|
|
1247
|
+
"kind": "function",
|
|
1248
|
+
"group": "app-shell",
|
|
1249
|
+
"props": [
|
|
1250
|
+
{
|
|
1251
|
+
"name": "props",
|
|
1252
|
+
"type": "McpAppViewProps",
|
|
1253
|
+
"required": true,
|
|
1254
|
+
"description": "Same props as McpToolkitApp (widgets, refreshToolName?, builderEnabled?, labels?)."
|
|
1255
|
+
}
|
|
1256
|
+
],
|
|
1257
|
+
"whenToUse": "The bundle entry point since mcp-use 2.x: mounts McpToolkitApp via bootstrapView (ext-apps handshake, error boundary, auto-resize). Call it once in main.tsx instead of createRoot().render()."
|
|
1204
1258
|
},
|
|
1205
1259
|
{
|
|
1206
1260
|
"name": "WidgetFixtureHost",
|
|
@@ -1243,7 +1297,7 @@
|
|
|
1243
1297
|
"name": "onModelContext",
|
|
1244
1298
|
"type": "(text: string) => void",
|
|
1245
1299
|
"required": false,
|
|
1246
|
-
"description": "Receives the serialized <ModelContext> the widget reports
|
|
1300
|
+
"description": "Receives the serialized <ModelContext> the widget reports — see what the model would see."
|
|
1247
1301
|
},
|
|
1248
1302
|
{
|
|
1249
1303
|
"name": "onHostAction",
|
|
@@ -1252,7 +1306,7 @@
|
|
|
1252
1306
|
"description": "Receives every host action (tool call, link, follow-up)."
|
|
1253
1307
|
}
|
|
1254
1308
|
],
|
|
1255
|
-
"whenToUse": "Storybook-style harness: render ONE widget with fixture data and a
|
|
1309
|
+
"whenToUse": "Storybook-style harness: render ONE widget with fixture data and a simulated HostBridge (no backend, no real host). This is the prompt → see → iterate loop; add a Story to examples/widget-playground/stories.ts."
|
|
1256
1310
|
},
|
|
1257
1311
|
{
|
|
1258
1312
|
"name": "buildFixtureWidgetProps",
|
|
@@ -1274,7 +1328,7 @@
|
|
|
1274
1328
|
"description": "Seed the single pipeline step under this _dataType for adaptDataWidget components."
|
|
1275
1329
|
}
|
|
1276
1330
|
],
|
|
1277
|
-
"whenToUse": "Build the WidgetProps envelope the fixture host passes to a widget
|
|
1331
|
+
"whenToUse": "Build the WidgetProps envelope the fixture host passes to a widget — exported mainly for unit testing the envelope shape without rendering React."
|
|
1278
1332
|
}
|
|
1279
1333
|
]
|
|
1280
1334
|
}
|