@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/README.md
CHANGED
|
@@ -9,19 +9,19 @@ Published to the public npm registry under the `@miragon` scope — no `.npmrc`
|
|
|
9
9
|
or token needed.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
pnpm add @miragon/mcp-toolkit-ui @miragon/mcp-toolkit-core mcp-use@1.
|
|
12
|
+
pnpm add @miragon/mcp-toolkit-ui @miragon/mcp-toolkit-core mcp-use@2.1.0 react@19.2.8 react-dom@19.2.8 tailwindcss@4.3.3
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Peer versions are pinned exactly — install the versions above.
|
|
16
16
|
|
|
17
17
|
## Import paths
|
|
18
18
|
|
|
19
|
-
| Subpath | Key exports | Constraint
|
|
20
|
-
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
21
|
-
| `@miragon/mcp-toolkit-ui` | Primitives (`Card`, `Table`, `Button`, …), composed components (`KpiGrid`, `WidgetHeader`, `FilterBar`), `useToolQuery`, `createTheme` / `ThemeProvider`, `cn`, `parseViewToolResult` | Free of `mcp-use/react` value imports (
|
|
22
|
-
| `…-ui/app` | `McpToolkitApp`, `McpAppView`, `WidgetRenderer`, `useHostBridge`, `adaptDataWidget`, `WidgetFixtureHost`
|
|
23
|
-
| `…-ui/hooks` | `useViewToolQuery`, `useViewData`, `useToolQuery`, `useToolMutation` | View-tool hooks.
|
|
24
|
-
| `…-ui/globals.css` | Tailwind v4 theme + design tokens | Import once in the app entry.
|
|
19
|
+
| Subpath | Key exports | Constraint |
|
|
20
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
21
|
+
| `@miragon/mcp-toolkit-ui` | Primitives (`Card`, `Table`, `Button`, …), composed components (`KpiGrid`, `WidgetHeader`, `FilterBar`), `useToolQuery`, `createTheme` / `ThemeProvider`, `cn`, `parseViewToolResult` | Free of `mcp-use/react` value imports (the view runtime + its ext-apps transitive) — safe for apps that never mount the shell. |
|
|
22
|
+
| `…-ui/app` | `mountMcpToolkitApp`, `McpToolkitApp`, `McpAppView`, `WidgetRenderer`, `useHostBridge`, `adaptDataWidget`, `WidgetFixtureHost` | The MCP app shell + host bridge — imports `mcp-use/react`. Never re-exported from the root barrel. |
|
|
23
|
+
| `…-ui/hooks` | `useViewToolQuery`, `useViewData`, `useToolQuery`, `useToolMutation` | View-tool hooks. |
|
|
24
|
+
| `…-ui/globals.css` | Tailwind v4 theme + design tokens | Import once in the app entry. |
|
|
25
25
|
|
|
26
26
|
## Component catalog
|
|
27
27
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
2
|
import type { WidgetComponent } from "./widget-renderer.js";
|
|
3
3
|
/**
|
|
4
4
|
* Builds the model-context line for an adapted widget. Receives the resolved
|
|
@@ -7,6 +7,27 @@ import type { WidgetComponent } from "./widget-renderer.js";
|
|
|
7
7
|
* `period` / `engine` on dashboard widgets) can be reported too.
|
|
8
8
|
*/
|
|
9
9
|
export type DescribeForModel<T> = (data: NonNullable<T>, props: Readonly<Record<string, unknown>>) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Model-context reporting that works on every host — the host-portable
|
|
12
|
+
* replacement for rendering `mcp-use/react`'s `ModelContext` directly.
|
|
13
|
+
*
|
|
14
|
+
* mcp-use 2.x's `ModelContext` registers with the view runtime and THROWS
|
|
15
|
+
* outside a `bootstrapView` mount, so it is only rendered inside an mcp-use
|
|
16
|
+
* view (where it aggregates nested nodes into one tree). Everywhere else —
|
|
17
|
+
* ChatGPT via `createChatGptHostBridge`, the `WidgetFixtureHost` harness,
|
|
18
|
+
* standalone apps — the description flows through the bridge's
|
|
19
|
+
* `setModelContext` instead (last-writer-wins; fine for the single-widget
|
|
20
|
+
* mounts those hosts render).
|
|
21
|
+
*
|
|
22
|
+
* Widgets that self-fetch and report their own context (cockpit views like
|
|
23
|
+
* `TasksBoard`) must use this instead of importing `ModelContext` from
|
|
24
|
+
* `mcp-use/react` — the direct import crashes the widget in every non-view
|
|
25
|
+
* mount, starting with the widget playground.
|
|
26
|
+
*/
|
|
27
|
+
export declare function HostModelContext({ content, children, }: {
|
|
28
|
+
content: string;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): ReactNode;
|
|
10
31
|
/**
|
|
11
32
|
* Wraps a "single-data" widget component (signature `({ data }: { data: T | null })`)
|
|
12
33
|
* so it can be registered as a framework {@link WidgetComponent} (which receives
|
|
@@ -21,11 +42,11 @@ export type DescribeForModel<T> = (data: NonNullable<T>, props: Readonly<Record<
|
|
|
21
42
|
* times in one view with different scoping (e.g. one tab per process key).
|
|
22
43
|
*
|
|
23
44
|
* When `describeForModel` is provided the adapter wraps the widget in a
|
|
24
|
-
* `
|
|
25
|
-
* active filters, headline numbers) without per-widget boilerplate.
|
|
26
|
-
* description is only rendered once the step data is present; widgets that
|
|
45
|
+
* `HostModelContext` so the model knows what the user is looking at (view
|
|
46
|
+
* identity, active filters, headline numbers) without per-widget boilerplate.
|
|
47
|
+
* The description is only rendered once the step data is present; widgets that
|
|
27
48
|
* self-fetch when the adapter has no data (cockpit views) must render their own
|
|
28
|
-
* `<
|
|
49
|
+
* `<HostModelContext>` instead.
|
|
29
50
|
*/
|
|
30
51
|
export declare function adaptDataWidget<T>(Widget: ComponentType<{
|
|
31
52
|
data: T | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapt-data-widget.d.ts","sourceRoot":"","sources":["../../src/app/adapt-data-widget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"adapt-data-widget.d.ts","sourceRoot":"","sources":["../../src/app/adapt-data-widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAKrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAChC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACrC,MAAM,CAAA;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,SAAS,CAAA;CACpB,GAAG,SAAS,CAIZ;AAWD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,MAAM,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,QAAQ,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACrC,eAAe,CAcjB"}
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
2
3
|
import { ModelContext } from "mcp-use/react";
|
|
4
|
+
import { useHostBridgeOrNull } from "./host-bridge.js";
|
|
5
|
+
import { useIsInsideMcpUseView } from "./mcp-use-host-bridge.js";
|
|
6
|
+
/**
|
|
7
|
+
* Model-context reporting that works on every host — the host-portable
|
|
8
|
+
* replacement for rendering `mcp-use/react`'s `ModelContext` directly.
|
|
9
|
+
*
|
|
10
|
+
* mcp-use 2.x's `ModelContext` registers with the view runtime and THROWS
|
|
11
|
+
* outside a `bootstrapView` mount, so it is only rendered inside an mcp-use
|
|
12
|
+
* view (where it aggregates nested nodes into one tree). Everywhere else —
|
|
13
|
+
* ChatGPT via `createChatGptHostBridge`, the `WidgetFixtureHost` harness,
|
|
14
|
+
* standalone apps — the description flows through the bridge's
|
|
15
|
+
* `setModelContext` instead (last-writer-wins; fine for the single-widget
|
|
16
|
+
* mounts those hosts render).
|
|
17
|
+
*
|
|
18
|
+
* Widgets that self-fetch and report their own context (cockpit views like
|
|
19
|
+
* `TasksBoard`) must use this instead of importing `ModelContext` from
|
|
20
|
+
* `mcp-use/react` — the direct import crashes the widget in every non-view
|
|
21
|
+
* mount, starting with the widget playground.
|
|
22
|
+
*/
|
|
23
|
+
export function HostModelContext({ content, children, }) {
|
|
24
|
+
const insideView = useIsInsideMcpUseView();
|
|
25
|
+
if (insideView)
|
|
26
|
+
return _jsx(ModelContext, { content: content, children: children });
|
|
27
|
+
return _jsx(BridgeModelContext, { content: content, children: children });
|
|
28
|
+
}
|
|
29
|
+
function BridgeModelContext({ content, children }) {
|
|
30
|
+
const bridge = useHostBridgeOrNull();
|
|
31
|
+
const setModelContext = bridge?.setModelContext;
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setModelContext?.(content);
|
|
34
|
+
}, [setModelContext, content]);
|
|
35
|
+
return children;
|
|
36
|
+
}
|
|
3
37
|
/**
|
|
4
38
|
* Wraps a "single-data" widget component (signature `({ data }: { data: T | null })`)
|
|
5
39
|
* so it can be registered as a framework {@link WidgetComponent} (which receives
|
|
@@ -14,11 +48,11 @@ import { ModelContext } from "mcp-use/react";
|
|
|
14
48
|
* times in one view with different scoping (e.g. one tab per process key).
|
|
15
49
|
*
|
|
16
50
|
* When `describeForModel` is provided the adapter wraps the widget in a
|
|
17
|
-
* `
|
|
18
|
-
* active filters, headline numbers) without per-widget boilerplate.
|
|
19
|
-
* description is only rendered once the step data is present; widgets that
|
|
51
|
+
* `HostModelContext` so the model knows what the user is looking at (view
|
|
52
|
+
* identity, active filters, headline numbers) without per-widget boilerplate.
|
|
53
|
+
* The description is only rendered once the step data is present; widgets that
|
|
20
54
|
* self-fetch when the adapter has no data (cockpit views) must render their own
|
|
21
|
-
* `<
|
|
55
|
+
* `<HostModelContext>` instead.
|
|
22
56
|
*/
|
|
23
57
|
export function adaptDataWidget(Widget, dataType, describeForModel) {
|
|
24
58
|
function AdaptedWidget({ context, widgetProps }) {
|
|
@@ -27,7 +61,7 @@ export function adaptDataWidget(Widget, dataType, describeForModel) {
|
|
|
27
61
|
const widget = _jsx(Widget, { ...(widgetProps ?? {}), data: data });
|
|
28
62
|
if (data == null || !describeForModel)
|
|
29
63
|
return widget;
|
|
30
|
-
return _jsx(
|
|
64
|
+
return (_jsx(HostModelContext, { content: describeForModel(data, widgetProps ?? {}), children: widget }));
|
|
31
65
|
}
|
|
32
66
|
AdaptedWidget.displayName = `Adapted(${Widget.displayName ?? Widget.name ?? "Widget"})`;
|
|
33
67
|
return AdaptedWidget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapt-data-widget.js","sourceRoot":"","sources":["../../src/app/adapt-data-widget.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"adapt-data-widget.js","sourceRoot":"","sources":["../../src/app/adapt-data-widget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAchE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,G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jE,MAAM,GACU,CACpB,CAAA;IACH,CAAC;IACD,aAAa,CAAC,WAAW,GAAG,WAAW,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,IAAI,QAAQ,GAAG,CAAA;IACvF,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { type ReactNode } from "react";
|
|
|
4
4
|
* host runtime. A `HostBridge` is the single seam a portable widget talks to:
|
|
5
5
|
* write the widget against {@link useHostBridge} and it runs unchanged in our
|
|
6
6
|
* own `mcp-use` host, inside ChatGPT (OpenAI Apps SDK), or as a standalone web
|
|
7
|
-
* app driven directly by a `@modelcontextprotocol/
|
|
7
|
+
* app driven directly by a `@modelcontextprotocol/client` client — only the
|
|
8
8
|
* surrounding adapter changes.
|
|
9
9
|
*
|
|
10
10
|
* This is deliberately the *minimum* a deterministic UI needs, not a mirror of
|
|
@@ -18,43 +18,40 @@ export interface HostBridge {
|
|
|
18
18
|
* with `parseToolResult`. Rejects if the call fails so a widget's own error
|
|
19
19
|
* state (TanStack Query, try/catch) can surface it.
|
|
20
20
|
*/
|
|
21
|
-
callTool(name: string, args: Record<string, unknown>)
|
|
21
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
22
22
|
/**
|
|
23
23
|
* Hand a natural-language prompt back to the conversation to drive a new model
|
|
24
24
|
* turn (navigate to another widget, ask the agent to analyse something). In
|
|
25
25
|
* hosts without a conversation (standalone web app) this is a no-op unless an
|
|
26
26
|
* `onFollowup` handler is supplied.
|
|
27
27
|
*/
|
|
28
|
-
sendFollowup(prompt: string)
|
|
28
|
+
sendFollowup: (prompt: string) => void;
|
|
29
29
|
/**
|
|
30
30
|
* Ask the host to open a URL outside the (often sandboxed) widget frame.
|
|
31
31
|
* Falls back to `window.open` only where no host bridge mediates links.
|
|
32
32
|
*/
|
|
33
|
-
openExternal(url: string)
|
|
33
|
+
openExternal: (url: string) => void;
|
|
34
34
|
/**
|
|
35
35
|
* The structured data this widget was rendered with, if the host pushed any
|
|
36
36
|
* (the tool result's `structuredContent` / `toolOutput`). Returns `null` when
|
|
37
37
|
* the host delivers data another way (e.g. props) or has none.
|
|
38
38
|
*/
|
|
39
|
-
getWidgetData<T>()
|
|
39
|
+
getWidgetData: <T>() => T | null;
|
|
40
40
|
/**
|
|
41
41
|
* Persist a short text the model should see on the next turn (selection,
|
|
42
42
|
* filter, current view). Optional: not every host exposes model context, and
|
|
43
43
|
* a standalone web app has no model at all — callers must guard its absence.
|
|
44
44
|
*/
|
|
45
|
-
setModelContext
|
|
45
|
+
setModelContext?: (text: string) => void;
|
|
46
46
|
/** The host's colour-scheme preference, when it reports one. */
|
|
47
47
|
theme?: "light" | "dark";
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Provide an explicit {@link HostBridge} to a subtree. Wrap a portable widget in
|
|
51
51
|
* the adapter for the host it is running in — {@link createChatGptHostBridge},
|
|
52
|
-
* {@link createStandaloneHostBridge}, or
|
|
53
|
-
* every `useHostBridge()` below
|
|
54
|
-
*
|
|
55
|
-
* Omitting the provider is supported: {@link useHostBridge} (and, for backward
|
|
56
|
-
* compatibility, `useHostActions`) then fall back to the `mcp-use`/react default
|
|
57
|
-
* bridge so existing widgets keep working without any wrapping.
|
|
52
|
+
* {@link createStandaloneHostBridge}, or (inside the toolkit's own mcp-use
|
|
53
|
+
* view) the `McpUseHostBridgeProvider` — and every `useHostBridge()` below
|
|
54
|
+
* resolves to it.
|
|
58
55
|
*/
|
|
59
56
|
export declare function HostBridgeProvider({ bridge, children, }: {
|
|
60
57
|
bridge: HostBridge;
|
|
@@ -68,47 +65,56 @@ export declare function HostBridgeProvider({ bridge, children, }: {
|
|
|
68
65
|
*/
|
|
69
66
|
export declare function useHostBridgeOrNull(): HostBridge | null;
|
|
70
67
|
/**
|
|
71
|
-
* The {@link HostBridge} for the current subtree
|
|
68
|
+
* The {@link HostBridge} for the current subtree — the nearest
|
|
69
|
+
* {@link HostBridgeProvider}'s bridge.
|
|
72
70
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
71
|
+
* A provider is always present in the supported mounts: the toolkit shell
|
|
72
|
+
* (`McpToolkitApp` via `McpUseHostBridgeProvider`) installs the `mcp-use`
|
|
73
|
+
* bridge for every widget it renders, the `WidgetFixtureHost` harness installs
|
|
74
|
+
* a standalone bridge, and ChatGPT / standalone apps wrap their root in
|
|
75
|
+
* {@link createChatGptHostBridge} / {@link createStandaloneHostBridge}.
|
|
76
76
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* instead.
|
|
81
|
-
* bridge exists.
|
|
77
|
+
* Since mcp-use 2.x there is no provider-less fallback: the `mcp-use` hooks
|
|
78
|
+
* only work inside a `bootstrapView`-mounted view, so a bare render without a
|
|
79
|
+
* provider cannot silently degrade — this hook throws with a pointer to the
|
|
80
|
+
* adapters instead.
|
|
82
81
|
*/
|
|
83
82
|
export declare function useHostBridge(): HostBridge;
|
|
84
83
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* `toolOutput`, `theme`) and `useCallTool` so it preserves exactly the behaviour
|
|
88
|
-
* widgets had before the bridge abstraction:
|
|
84
|
+
* Exactly the slice of `mcp-use`'s widget surface {@link toHostBridge} reads —
|
|
85
|
+
* declared structurally rather than imported from `mcp-use/react`.
|
|
89
86
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
87
|
+
* That indirection is the point: the mapping below is the behaviour widgets
|
|
88
|
+
* depend on, and pinning it against a local interface keeps it testable without
|
|
89
|
+
* a host, a DOM, or a React renderer. It also localises upstream churn — when
|
|
90
|
+
* the shape moves, this interface and the `McpUseHostBridgeProvider` (which
|
|
91
|
+
* composes the mcp-use 2.x view hooks into this surface) are what change, and
|
|
92
|
+
* {@link toHostBridge}'s tests still prove the bridge contract widgets see is
|
|
93
|
+
* unchanged. The 1.x `useWidget()` satisfied it directly; the 2.x composition
|
|
94
|
+
* lives in `mcp-use-host-bridge.tsx`.
|
|
98
95
|
*/
|
|
99
|
-
export
|
|
96
|
+
export interface McpUseWidgetSurface {
|
|
97
|
+
/** Invoke a tool on the connected server. */
|
|
98
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
99
|
+
/** Hand a prompt back to the conversation. Rejects are swallowed by the mapping. */
|
|
100
|
+
sendFollowUpMessage: (prompt: string) => Promise<unknown>;
|
|
101
|
+
/** Open a URL outside the widget frame. Throws when no host mediates links. */
|
|
102
|
+
openExternal: (url: string) => void;
|
|
103
|
+
/** The tool output the host rendered this widget with, when it pushed one. */
|
|
104
|
+
output?: unknown;
|
|
105
|
+
/** The host's reported colour scheme, in whatever spelling it uses. */
|
|
106
|
+
theme?: unknown;
|
|
107
|
+
/** Persist widget state; the model-context write rides on this. */
|
|
108
|
+
setState: (state: Record<string, unknown>) => Promise<unknown>;
|
|
109
|
+
}
|
|
100
110
|
/**
|
|
101
|
-
*
|
|
102
|
-
* adapters. Because the `mcp-use` bridge is hook-driven (it reads live host
|
|
103
|
-
* context), the "factory" is really the hook itself — call it from a component.
|
|
111
|
+
* Map `mcp-use`'s widget surface onto the host-agnostic {@link HostBridge}.
|
|
104
112
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* // …or rely on useHostBridge()'s default and skip the provider entirely.
|
|
109
|
-
* }
|
|
113
|
+
* Pure and separately exported so the fail-soft behaviour is pinned by tests:
|
|
114
|
+
* every verb here has a documented failure mode that widgets rely on, and none
|
|
115
|
+
* of them may start throwing into widget render paths.
|
|
110
116
|
*/
|
|
111
|
-
export declare
|
|
117
|
+
export declare function toHostBridge(widget: McpUseWidgetSurface): HostBridge;
|
|
112
118
|
/**
|
|
113
119
|
* Minimal structural view of the OpenAI Apps SDK `window.openai` object this
|
|
114
120
|
* adapter reads. Every field is optional: the real SDK shape varies across
|
|
@@ -158,7 +164,7 @@ export declare function createChatGptHostBridge(sdk?: OpenAiAppsSdk | null): Hos
|
|
|
158
164
|
export interface StandaloneHostBridgeOptions {
|
|
159
165
|
/**
|
|
160
166
|
* The only required capability: how to call a tool on the server. In a
|
|
161
|
-
* standalone web app this typically wraps a `@modelcontextprotocol/
|
|
167
|
+
* standalone web app this typically wraps a `@modelcontextprotocol/client`
|
|
162
168
|
* `Client.callTool({ name, arguments })`, but any function with this shape
|
|
163
169
|
* works — that injection is the whole point: hand-built widgets render
|
|
164
170
|
* against *any* existing MCP server without the toolkit's host runtime.
|
|
@@ -191,7 +197,7 @@ export interface StandaloneHostBridgeOptions {
|
|
|
191
197
|
/**
|
|
192
198
|
* Build a {@link HostBridge} for a standalone web app driven against an existing
|
|
193
199
|
* MCP server — no toolkit host, no `createFrameworkApp`. You inject `callTool`
|
|
194
|
-
* (usually a thin wrapper over a `@modelcontextprotocol/
|
|
200
|
+
* (usually a thin wrapper over a `@modelcontextprotocol/client` client); the
|
|
195
201
|
* conversation-shaped verbs (`sendFollowup`, `setModelContext`) are no-ops
|
|
196
202
|
* unless you wire handlers, and `openExternal` defaults to `window.open`.
|
|
197
203
|
*
|
|
@@ -201,7 +207,7 @@ export interface StandaloneHostBridgeOptions {
|
|
|
201
207
|
* harness also builds on this factory so host simulation has a single source.
|
|
202
208
|
*
|
|
203
209
|
* @example
|
|
204
|
-
* const client = new Client(…) // @modelcontextprotocol/
|
|
210
|
+
* const client = new Client(…) // @modelcontextprotocol/client
|
|
205
211
|
* const bridge = createStandaloneHostBridge({
|
|
206
212
|
* callTool: (name, args) => client.callTool({ name, arguments: args }),
|
|
207
213
|
* getData: () => currentRecord,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-bridge.d.ts","sourceRoot":"","sources":["../../src/app/host-bridge.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"host-bridge.d.ts","sourceRoot":"","sources":["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,IAAI,GAAG,UAAU,CAiE9E;AAED,sDAAsD;AACtD,MAAM,WAAW,2BAA2B;IAC1C;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,gEAAgE;IAChE,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,yCAAyC;IACzC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,UAAU,CAiC3F"}
|
package/dist/app/host-bridge.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext
|
|
3
|
-
import { useWidget } from "mcp-use/react";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
4
3
|
const HostBridgeContext = createContext(null);
|
|
5
4
|
/**
|
|
6
5
|
* Provide an explicit {@link HostBridge} to a subtree. Wrap a portable widget in
|
|
7
6
|
* the adapter for the host it is running in — {@link createChatGptHostBridge},
|
|
8
|
-
* {@link createStandaloneHostBridge}, or
|
|
9
|
-
* every `useHostBridge()` below
|
|
10
|
-
*
|
|
11
|
-
* Omitting the provider is supported: {@link useHostBridge} (and, for backward
|
|
12
|
-
* compatibility, `useHostActions`) then fall back to the `mcp-use`/react default
|
|
13
|
-
* bridge so existing widgets keep working without any wrapping.
|
|
7
|
+
* {@link createStandaloneHostBridge}, or (inside the toolkit's own mcp-use
|
|
8
|
+
* view) the `McpUseHostBridgeProvider` — and every `useHostBridge()` below
|
|
9
|
+
* resolves to it.
|
|
14
10
|
*/
|
|
15
11
|
export function HostBridgeProvider({ bridge, children, }) {
|
|
16
12
|
return _jsx(HostBridgeContext.Provider, { value: bridge, children: children });
|
|
@@ -25,45 +21,39 @@ export function useHostBridgeOrNull() {
|
|
|
25
21
|
return useContext(HostBridgeContext);
|
|
26
22
|
}
|
|
27
23
|
/**
|
|
28
|
-
* The {@link HostBridge} for the current subtree
|
|
24
|
+
* The {@link HostBridge} for the current subtree — the nearest
|
|
25
|
+
* {@link HostBridgeProvider}'s bridge.
|
|
29
26
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
27
|
+
* A provider is always present in the supported mounts: the toolkit shell
|
|
28
|
+
* (`McpToolkitApp` via `McpUseHostBridgeProvider`) installs the `mcp-use`
|
|
29
|
+
* bridge for every widget it renders, the `WidgetFixtureHost` harness installs
|
|
30
|
+
* a standalone bridge, and ChatGPT / standalone apps wrap their root in
|
|
31
|
+
* {@link createChatGptHostBridge} / {@link createStandaloneHostBridge}.
|
|
33
32
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* instead.
|
|
38
|
-
* bridge exists.
|
|
33
|
+
* Since mcp-use 2.x there is no provider-less fallback: the `mcp-use` hooks
|
|
34
|
+
* only work inside a `bootstrapView`-mounted view, so a bare render without a
|
|
35
|
+
* provider cannot silently degrade — this hook throws with a pointer to the
|
|
36
|
+
* adapters instead.
|
|
39
37
|
*/
|
|
40
38
|
export function useHostBridge() {
|
|
41
39
|
const explicit = useContext(HostBridgeContext);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
if (!explicit) {
|
|
41
|
+
throw new Error("[host-bridge] useHostBridge() found no HostBridgeProvider. Wrap the widget in " +
|
|
42
|
+
"McpToolkitApp / McpUseHostBridgeProvider (toolkit host), WidgetFixtureHost (dev), " +
|
|
43
|
+
"or a HostBridgeProvider with createChatGptHostBridge / createStandaloneHostBridge.");
|
|
44
|
+
}
|
|
45
|
+
return explicit;
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
|
-
*
|
|
50
|
-
* running in the toolkit's own host. Wraps `useWidget()` (host actions,
|
|
51
|
-
* `toolOutput`, `theme`) and `useCallTool` so it preserves exactly the behaviour
|
|
52
|
-
* widgets had before the bridge abstraction:
|
|
53
|
-
*
|
|
54
|
-
* - `openExternal` routes through the host's `openExternal` and falls back to
|
|
55
|
-
* `window.open` when no host bridge is wired (local dev preview) — mirroring
|
|
56
|
-
* the original `useHostActions.openLink`.
|
|
57
|
-
* - `sendFollowup` routes through `sendFollowUpMessage` and swallows rejections
|
|
58
|
-
* with a `console.warn`, as `useHostActions` did.
|
|
48
|
+
* Map `mcp-use`'s widget surface onto the host-agnostic {@link HostBridge}.
|
|
59
49
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
50
|
+
* Pure and separately exported so the fail-soft behaviour is pinned by tests:
|
|
51
|
+
* every verb here has a documented failure mode that widgets rely on, and none
|
|
52
|
+
* of them may start throwing into widget render paths.
|
|
62
53
|
*/
|
|
63
|
-
export function
|
|
64
|
-
const widget = useWidget();
|
|
54
|
+
export function toHostBridge(widget) {
|
|
65
55
|
const { callTool, sendFollowUpMessage, openExternal, output, theme, setState } = widget;
|
|
66
|
-
return
|
|
56
|
+
return {
|
|
67
57
|
callTool: (name, args) => callTool(name, args),
|
|
68
58
|
sendFollowup: (prompt) => {
|
|
69
59
|
void sendFollowUpMessage(prompt).catch((err) => {
|
|
@@ -87,20 +77,8 @@ export function useMcpUseHostBridge() {
|
|
|
87
77
|
});
|
|
88
78
|
},
|
|
89
79
|
theme: theme === "dark" ? "dark" : "light",
|
|
90
|
-
}
|
|
80
|
+
};
|
|
91
81
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Factory form of {@link useMcpUseHostBridge} for symmetry with the other
|
|
94
|
-
* adapters. Because the `mcp-use` bridge is hook-driven (it reads live host
|
|
95
|
-
* context), the "factory" is really the hook itself — call it from a component.
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* function MyWidget() {
|
|
99
|
-
* const bridge = createMcpUseHostBridge() // === useMcpUseHostBridge()
|
|
100
|
-
* // …or rely on useHostBridge()'s default and skip the provider entirely.
|
|
101
|
-
* }
|
|
102
|
-
*/
|
|
103
|
-
export const createMcpUseHostBridge = useMcpUseHostBridge;
|
|
104
82
|
/**
|
|
105
83
|
* Resolve the `window.openai` object, or `null` outside a browser / when the SDK
|
|
106
84
|
* is absent. Pulled out so the no-SDK fallback path is unit-testable by passing
|
|
@@ -195,7 +173,7 @@ export function createChatGptHostBridge(sdk) {
|
|
|
195
173
|
/**
|
|
196
174
|
* Build a {@link HostBridge} for a standalone web app driven against an existing
|
|
197
175
|
* MCP server — no toolkit host, no `createFrameworkApp`. You inject `callTool`
|
|
198
|
-
* (usually a thin wrapper over a `@modelcontextprotocol/
|
|
176
|
+
* (usually a thin wrapper over a `@modelcontextprotocol/client` client); the
|
|
199
177
|
* conversation-shaped verbs (`sendFollowup`, `setModelContext`) are no-ops
|
|
200
178
|
* unless you wire handlers, and `openExternal` defaults to `window.open`.
|
|
201
179
|
*
|
|
@@ -205,7 +183,7 @@ export function createChatGptHostBridge(sdk) {
|
|
|
205
183
|
* harness also builds on this factory so host simulation has a single source.
|
|
206
184
|
*
|
|
207
185
|
* @example
|
|
208
|
-
* const client = new Client(…) // @modelcontextprotocol/
|
|
186
|
+
* const client = new Client(…) // @modelcontextprotocol/client
|
|
209
187
|
* const bridge = createStandaloneHostBridge({
|
|
210
188
|
* callTool: (name, args) => client.callTool({ name, arguments: args }),
|
|
211
189
|
* getData: () => currentRecord,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-bridge.js","sourceRoot":"","sources":["../../src/app/host-bridge.tsx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,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IACxF,OAAO;QACL,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QAC9C,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;YACvB,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,CAAC,MAAM,CAAC,CAAA;gBAClB,OAAM;YACR,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAA;QAC5F,CAAC;QACD,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE;YACpB,IAAI,cAAc,EAAE,CAAC;gBACnB,cAAc,CAAC,GAAG,CAAC,CAAA;gBACnB,OAAM;YACR,CAAC;YACD,IAAI,OAAO,MAAM,KAAK,WAAW;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;QAC3E,CAAC;QACD,aAAa,EAAE,GAAO,EAAE;YACtB,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAE,OAAyB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;YACnF,OAAQ,IAAiB,IAAI,IAAI,CAAA;QACnC,CAAC;QACD,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,cAAc,EAAE,CAAC;gBACnB,cAAc,CAAC,IAAI,CAAC,CAAA;gBACpB,OAAM;YACR,CAAC;YACD,OAAO,CAAC,IAAI,CACV,iFAAiF,CAClF,CAAA;QACH,CAAC;QACD,KAAK;KACN,CAAA;AACH,CAAC"}
|
package/dist/app/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export { McpAppView } from "./mcp-app-view.js";
|
|
2
2
|
export type { McpAppViewProps, McpAppViewLabels } from "./mcp-app-view.js";
|
|
3
|
-
export { McpToolkitApp } from "./mcp-toolkit-app.js";
|
|
3
|
+
export { McpToolkitApp, mountMcpToolkitApp } from "./mcp-toolkit-app.js";
|
|
4
4
|
export { WidgetRenderer, WidgetErrorBoundary, RenderedWidget, contextHasNoData, } from "./widget-renderer.js";
|
|
5
5
|
export type { WidgetRendererProps, WidgetComponent } from "./widget-renderer.js";
|
|
6
6
|
export { LayoutBuilder } from "./layout-builder.js";
|
|
7
7
|
export type { LayoutBuilderProps, LayoutBuilderLabels } from "./layout-builder.js";
|
|
8
|
-
export { adaptDataWidget } from "./adapt-data-widget.js";
|
|
8
|
+
export { adaptDataWidget, HostModelContext } from "./adapt-data-widget.js";
|
|
9
9
|
export type { DescribeForModel } from "./adapt-data-widget.js";
|
|
10
10
|
export { useHostActions, buildShowWidgetIntent } from "./use-host-actions.js";
|
|
11
11
|
export type { HostActions } from "./use-host-actions.js";
|
|
12
|
-
export { HostBridgeProvider, useHostBridge, useHostBridgeOrNull,
|
|
13
|
-
export type { HostBridge, OpenAiAppsSdk, StandaloneHostBridgeOptions } from "./host-bridge.js";
|
|
12
|
+
export { HostBridgeProvider, useHostBridge, useHostBridgeOrNull, toHostBridge, createChatGptHostBridge, createStandaloneHostBridge, } from "./host-bridge.js";
|
|
13
|
+
export type { HostBridge, McpUseWidgetSurface, OpenAiAppsSdk, StandaloneHostBridgeOptions, } from "./host-bridge.js";
|
|
14
|
+
export { McpUseHostBridgeProvider, useIsInsideMcpUseView } from "./mcp-use-host-bridge.js";
|
|
14
15
|
export { WidgetFixtureHost, FixtureCallToolRegistry, buildFixtureWidgetProps, useFixtureHost, } from "./widget-fixture.js";
|
|
15
16
|
export type { WidgetFixtureHostProps, FixtureWidget, FixtureToolEntry, FixtureToolResult, HostActionLog, } from "./widget-fixture.js";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/app/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"A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iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,GACf,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,GACd,MAAM,qBAAqB,CAAA"}
|
package/dist/app/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
export { McpAppView } from "./mcp-app-view.js";
|
|
2
|
-
export { McpToolkitApp } from "./mcp-toolkit-app.js";
|
|
2
|
+
export { McpToolkitApp, mountMcpToolkitApp } from "./mcp-toolkit-app.js";
|
|
3
3
|
export { WidgetRenderer, WidgetErrorBoundary, RenderedWidget, contextHasNoData, } from "./widget-renderer.js";
|
|
4
4
|
export { LayoutBuilder } from "./layout-builder.js";
|
|
5
|
-
// App-level value modules that import `mcp-use/react` (ModelContext,
|
|
6
|
-
// — exported from this subpath only, never the root barrel.
|
|
7
|
-
export { adaptDataWidget } from "./adapt-data-widget.js";
|
|
5
|
+
// App-level value modules that import `mcp-use/react` (ModelContext, the 2.x
|
|
6
|
+
// view hooks) — exported from this subpath only, never the root barrel.
|
|
7
|
+
export { adaptDataWidget, HostModelContext } from "./adapt-data-widget.js";
|
|
8
8
|
export { useHostActions, buildShowWidgetIntent } from "./use-host-actions.js";
|
|
9
9
|
// Host-portability bridge: the seam that lets the same hand-built widget run in
|
|
10
10
|
// our mcp-use host, ChatGPT (Apps SDK), or a standalone web app against an
|
|
11
|
-
// existing MCP server. Lives under ./app because the
|
|
11
|
+
// existing MCP server. Lives under ./app because the mcp-use adapter imports
|
|
12
12
|
// `mcp-use/react` — never the root barrel.
|
|
13
|
-
export { HostBridgeProvider, useHostBridge, useHostBridgeOrNull,
|
|
13
|
+
export { HostBridgeProvider, useHostBridge, useHostBridgeOrNull, toHostBridge, createChatGptHostBridge, createStandaloneHostBridge, } from "./host-bridge.js";
|
|
14
|
+
export { McpUseHostBridgeProvider, useIsInsideMcpUseView } from "./mcp-use-host-bridge.js";
|
|
14
15
|
// Storybook-style harness for developing widgets in isolation with fixture
|
|
15
|
-
// data and a
|
|
16
|
-
//
|
|
16
|
+
// data and a simulated HostBridge. Lives under ./app to keep every host-facing
|
|
17
|
+
// surface on one subpath — never the root barrel.
|
|
17
18
|
export { WidgetFixtureHost, FixtureCallToolRegistry, buildFixtureWidgetProps, useFixtureHost, } from "./widget-fixture.js";
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/app/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,6EAA6E;AAC7E,wEAAwE;AACxE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE1E,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAG7E,gFAAgF;AAChF,2EAA2E;AAC3E,6EAA6E;AAC7E,2CAA2C;AAC3C,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAOzB,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAE1F,2EAA2E;AAC3E,+EAA+E;AAC/E,kDAAkD;AAClD,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,GACf,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app-view.d.ts","sourceRoot":"","sources":["../../src/app/mcp-app-view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-app-view.d.ts","sourceRoot":"","sources":["../../src/app/mcp-app-view.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3E,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAkDD,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACxC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAC1B;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,eAAgC,EAChC,cAAc,EACd,MAAM,GACP,EAAE,eAAe,+BA4QjB"}
|