mcp-app-studio 0.3.2
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 +152 -0
- package/bin/mcp-app-studio.js +5 -0
- package/dist/bridge-BOSEqpaS.d.ts +66 -0
- package/dist/chunk-4LAH4JH6.js +47 -0
- package/dist/chunk-KRCGOYZ5.js +16 -0
- package/dist/chunk-L2RRNF7V.js +140 -0
- package/dist/chunk-QO43ZGJI.js +174 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +579 -0
- package/dist/core/index.d.ts +445 -0
- package/dist/core/index.js +16 -0
- package/dist/index.d.ts +508 -0
- package/dist/index.js +358 -0
- package/dist/platforms/chatgpt/index.d.ts +158 -0
- package/dist/platforms/chatgpt/index.js +149 -0
- package/dist/platforms/mcp/index.d.ts +37 -0
- package/dist/platforms/mcp/index.js +159 -0
- package/package.json +124 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MCPBridge
|
|
3
|
+
} from "../../chunk-QO43ZGJI.js";
|
|
4
|
+
import "../../chunk-4LAH4JH6.js";
|
|
5
|
+
|
|
6
|
+
// src/platforms/mcp/hooks.tsx
|
|
7
|
+
import {
|
|
8
|
+
createContext,
|
|
9
|
+
useContext,
|
|
10
|
+
useEffect,
|
|
11
|
+
useState,
|
|
12
|
+
useCallback
|
|
13
|
+
} from "react";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var MCPContext = createContext(null);
|
|
16
|
+
function MCPProvider({
|
|
17
|
+
children,
|
|
18
|
+
appInfo,
|
|
19
|
+
appCapabilities
|
|
20
|
+
}) {
|
|
21
|
+
const [bridge] = useState(() => new MCPBridge(appInfo, appCapabilities));
|
|
22
|
+
const [ready, setReady] = useState(false);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
bridge.connect().then(() => setReady(true));
|
|
25
|
+
}, [bridge]);
|
|
26
|
+
if (!ready) return null;
|
|
27
|
+
return /* @__PURE__ */ jsx(MCPContext.Provider, { value: bridge, children });
|
|
28
|
+
}
|
|
29
|
+
function useMCPBridge() {
|
|
30
|
+
const bridge = useContext(MCPContext);
|
|
31
|
+
if (!bridge) {
|
|
32
|
+
throw new Error("useMCP* hooks must be used within MCPProvider");
|
|
33
|
+
}
|
|
34
|
+
return bridge;
|
|
35
|
+
}
|
|
36
|
+
function useHostContext() {
|
|
37
|
+
const bridge = useMCPBridge();
|
|
38
|
+
const [context, setContext] = useState(
|
|
39
|
+
bridge.getHostContext()
|
|
40
|
+
);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
return bridge.onHostContextChanged((ctx) => {
|
|
43
|
+
setContext(
|
|
44
|
+
(prev) => prev ? { ...prev, ...ctx } : ctx
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
}, [bridge]);
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
function useTheme() {
|
|
51
|
+
const context = useHostContext();
|
|
52
|
+
return context?.theme ?? "light";
|
|
53
|
+
}
|
|
54
|
+
function useToolInput() {
|
|
55
|
+
const bridge = useMCPBridge();
|
|
56
|
+
const [input, setInput] = useState(null);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
return bridge.onToolInput((args) => setInput(args));
|
|
59
|
+
}, [bridge]);
|
|
60
|
+
return input;
|
|
61
|
+
}
|
|
62
|
+
function useToolInputPartial() {
|
|
63
|
+
const bridge = useMCPBridge();
|
|
64
|
+
const [input, setInput] = useState(null);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
return bridge.onToolInputPartial((args) => setInput(args));
|
|
67
|
+
}, [bridge]);
|
|
68
|
+
return input;
|
|
69
|
+
}
|
|
70
|
+
function useToolResult() {
|
|
71
|
+
const bridge = useMCPBridge();
|
|
72
|
+
const [result, setResult] = useState(null);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
return bridge.onToolResult(setResult);
|
|
75
|
+
}, [bridge]);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
function useToolCancellation(callback) {
|
|
79
|
+
const bridge = useMCPBridge();
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
return bridge.onToolCancelled(callback);
|
|
82
|
+
}, [bridge, callback]);
|
|
83
|
+
}
|
|
84
|
+
function useTeardown(callback) {
|
|
85
|
+
const bridge = useMCPBridge();
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
return bridge.onTeardown(callback);
|
|
88
|
+
}, [bridge, callback]);
|
|
89
|
+
}
|
|
90
|
+
function useDisplayMode() {
|
|
91
|
+
const bridge = useMCPBridge();
|
|
92
|
+
const context = useHostContext();
|
|
93
|
+
const mode = context?.displayMode ?? "inline";
|
|
94
|
+
const setMode = useCallback(
|
|
95
|
+
async (newMode) => {
|
|
96
|
+
const available = context?.availableDisplayModes ?? [];
|
|
97
|
+
if (available.length > 0 && !available.includes(newMode)) {
|
|
98
|
+
console.warn(
|
|
99
|
+
`Display mode "${newMode}" not available. Available: ${available.join(", ")}`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
await bridge.requestDisplayMode(newMode);
|
|
103
|
+
},
|
|
104
|
+
[bridge, context?.availableDisplayModes]
|
|
105
|
+
);
|
|
106
|
+
return [mode, setMode];
|
|
107
|
+
}
|
|
108
|
+
function useCallTool() {
|
|
109
|
+
const bridge = useMCPBridge();
|
|
110
|
+
return useCallback(
|
|
111
|
+
(name, args) => bridge.callTool(name, args),
|
|
112
|
+
[bridge]
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function useOpenLink() {
|
|
116
|
+
const bridge = useMCPBridge();
|
|
117
|
+
return useCallback((url) => bridge.openLink(url), [bridge]);
|
|
118
|
+
}
|
|
119
|
+
function useSendMessage() {
|
|
120
|
+
const bridge = useMCPBridge();
|
|
121
|
+
return useCallback(
|
|
122
|
+
(text) => bridge.sendMessage({
|
|
123
|
+
role: "user",
|
|
124
|
+
content: [{ type: "text", text }]
|
|
125
|
+
}),
|
|
126
|
+
[bridge]
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function useUpdateModelContext() {
|
|
130
|
+
const bridge = useMCPBridge();
|
|
131
|
+
return useCallback(
|
|
132
|
+
(ctx) => bridge.updateModelContext(ctx),
|
|
133
|
+
[bridge]
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
function useLog() {
|
|
137
|
+
const bridge = useMCPBridge();
|
|
138
|
+
return useCallback(
|
|
139
|
+
(level, data) => bridge.sendLog(level, data),
|
|
140
|
+
[bridge]
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
MCPBridge,
|
|
145
|
+
MCPProvider,
|
|
146
|
+
useCallTool,
|
|
147
|
+
useDisplayMode,
|
|
148
|
+
useHostContext,
|
|
149
|
+
useLog,
|
|
150
|
+
useOpenLink,
|
|
151
|
+
useSendMessage,
|
|
152
|
+
useTeardown,
|
|
153
|
+
useTheme,
|
|
154
|
+
useToolCancellation,
|
|
155
|
+
useToolInput,
|
|
156
|
+
useToolInputPartial,
|
|
157
|
+
useToolResult,
|
|
158
|
+
useUpdateModelContext
|
|
159
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-app-studio",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "Build interactive apps for AI assistants (ChatGPT, Claude, MCP hosts)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"chatgpt",
|
|
7
|
+
"openai",
|
|
8
|
+
"claude",
|
|
9
|
+
"anthropic",
|
|
10
|
+
"mcp",
|
|
11
|
+
"widget",
|
|
12
|
+
"app",
|
|
13
|
+
"create",
|
|
14
|
+
"scaffold",
|
|
15
|
+
"studio"
|
|
16
|
+
],
|
|
17
|
+
"author": "AgentbaseAI Inc.",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"bin": {
|
|
21
|
+
"mcp-app-studio": "./bin/mcp-app-studio.js"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./cli": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/cli/index.d.ts",
|
|
36
|
+
"default": "./dist/cli/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"./core": {
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./dist/core/index.d.ts",
|
|
42
|
+
"default": "./dist/core/index.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"./chatgpt": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/platforms/chatgpt/index.d.ts",
|
|
48
|
+
"default": "./dist/platforms/chatgpt/index.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"./mcp": {
|
|
52
|
+
"import": {
|
|
53
|
+
"types": "./dist/platforms/mcp/index.d.ts",
|
|
54
|
+
"default": "./dist/platforms/mcp/index.js"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"bin",
|
|
60
|
+
"dist",
|
|
61
|
+
"README.md"
|
|
62
|
+
],
|
|
63
|
+
"sideEffects": false,
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsup",
|
|
66
|
+
"dev": "tsup --watch",
|
|
67
|
+
"preview:sync": "tsx scripts/sync-template.ts",
|
|
68
|
+
"preview:install": "cd .preview && npm install",
|
|
69
|
+
"preview:dev": "cd .preview && npm run dev",
|
|
70
|
+
"preview": "tsx scripts/sync-template.ts && cd .preview && npm run dev",
|
|
71
|
+
"test": "vitest run",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"test:smoke": "vitest run --config vitest.smoke.config.ts",
|
|
74
|
+
"test:coverage": "vitest run --coverage",
|
|
75
|
+
"test:scaffold": "bash scripts/test-scaffold.sh",
|
|
76
|
+
"typecheck": "tsc --noEmit",
|
|
77
|
+
"prepack": "pnpm run build"
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@clack/prompts": "^0.11.0",
|
|
81
|
+
"picocolors": "^1.1.1",
|
|
82
|
+
"tar": "^7.5.4"
|
|
83
|
+
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"@modelcontextprotocol/ext-apps": ">=0.4.0",
|
|
86
|
+
"react": ">=18.0.0"
|
|
87
|
+
},
|
|
88
|
+
"peerDependenciesMeta": {
|
|
89
|
+
"@modelcontextprotocol/ext-apps": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"react": {
|
|
93
|
+
"optional": true
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"devDependencies": {
|
|
97
|
+
"@modelcontextprotocol/ext-apps": "^0.4.0",
|
|
98
|
+
"@assistant-ui/x-buildutils": "workspace:*",
|
|
99
|
+
"@types/node": "^25.0.9",
|
|
100
|
+
"@types/react": "^19.1.6",
|
|
101
|
+
"@types/tar": "^6.1.13",
|
|
102
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
103
|
+
"react": "^19.1.0",
|
|
104
|
+
"tsup": "^8.5.1",
|
|
105
|
+
"tsx": "^4.21.0",
|
|
106
|
+
"typescript": "^5.9.3",
|
|
107
|
+
"vitest": "^4.0.17"
|
|
108
|
+
},
|
|
109
|
+
"publishConfig": {
|
|
110
|
+
"access": "public"
|
|
111
|
+
},
|
|
112
|
+
"homepage": "https://www.assistant-ui.com/",
|
|
113
|
+
"repository": {
|
|
114
|
+
"type": "git",
|
|
115
|
+
"url": "git+https://github.com/assistant-ui/assistant-ui.git",
|
|
116
|
+
"directory": "packages/mcp-app-studio"
|
|
117
|
+
},
|
|
118
|
+
"bugs": {
|
|
119
|
+
"url": "https://github.com/assistant-ui/assistant-ui/issues"
|
|
120
|
+
},
|
|
121
|
+
"engines": {
|
|
122
|
+
"node": ">=20.9.0"
|
|
123
|
+
}
|
|
124
|
+
}
|