Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@mcp-apps-kit/ui-react-builder": "workspace:*",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"zod": "^4.0.0"
"zod": "^4.3.5"
},
"devDependencies": {
"@mcp-apps-kit/testing": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion examples/restaurant-finder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@mcp-apps-kit/ui-react": "workspace:*",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"zod": "^4.0.0"
"zod": "^4.3.5"
},
"devDependencies": {
"@types/node": "^25.0.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/weather-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@mcp-apps-kit/ui-react": "workspace:*",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"zod": "^4.0.0"
"zod": "^4.3.5"
},
"devDependencies": {
"@mcp-apps-kit/testing": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion examples/weather-app/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const app = createApp({
version: "0.1.0",

config: {
protocol: "openai",
protocol: "mcp",
},

tools: {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@
"directory": "packages/core"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.25.1",
"@modelcontextprotocol/sdk": "^1.25.2",
"express": "^5.1.0",
"jsonwebtoken": "^9.0.3",
"jwks-rsa": "^3.2.0",
"zod": "^4.0.0"
"zod": "^4.3.5"
},
"devDependencies": {
"@types/express": "^5.0.0",
"@types/jsonwebtoken": "^9.0.7"
},
"peerDependencies": {
"zod": "^4.0.0"
"zod": "^4.3.5"
},
"engines": {
"node": ">=18.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"directory": "packages/testing"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.25.1",
"@modelcontextprotocol/sdk": "^1.25.2",
"debug": "^4.0.0",
"zod": "^4.0.0"
"zod": "^4.3.5"
},
"peerDependencies": {
"@anthropic-ai/sdk": ">=0.30.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/ui-react-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
"url": "git+https://github.com/AndurilCode/mcp-apps-kit.git",
"directory": "packages/ui-react-builder"
},
"dependencies": {
"@typescript-eslint/typescript-estree": "^8.0.0",
"esbuild": "^0.25.0"
},
"peerDependencies": {
"@mcp-apps-kit/core": "^0.4.0",
"@mcp-apps-kit/ui-react": "^0.4.0",
Expand All @@ -70,12 +66,16 @@
"optional": true
}
},
"dependencies": {
"@typescript-eslint/types": "^8.53.0",
"@typescript-eslint/typescript-estree": "^8.53.0",
"esbuild": "^0.27.2"
},
"devDependencies": {
"@mcp-apps-kit/core": "workspace:*",
"@mcp-apps-kit/ui-react": "workspace:*",
"@types/react": "^19.2.8",
"@types/react-dom": "^19.2.3",
"@typescript-eslint/types": "^8.53.0",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"vite": "^7.3.1"
Expand Down
7 changes: 7 additions & 0 deletions packages/ui-react-builder/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ export default defineConfig({
clean: true,
treeshake: true,
minify: true,
// External dependencies - these must be listed in package.json dependencies (not devDependencies)
// because they're needed at runtime:
// - @typescript-eslint/* packages: Used by ast-parser.ts to parse user TypeScript code at build time
// - esbuild: Used to bundle React components into standalone HTML files
// - vite: Peer dependency, used when plugin is loaded by Vite config
external: [
"react",
"react-dom",
"@mcp-apps-kit/core",
"@mcp-apps-kit/ui-react",
"esbuild",
"vite",
"@typescript-eslint/typescript-estree",
"@typescript-eslint/types",
],
esbuildOptions(options) {
options.jsx = "automatic";
Expand Down
57 changes: 57 additions & 0 deletions packages/ui-react/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
ModalResult,
HostCapabilities,
HostVersion,
UpdateModelContextParams,
} from "@mcp-apps-kit/ui";
import { clientDebugLogger, type ClientDebugLogger } from "@mcp-apps-kit/ui";
import { useAppsContext } from "./context";
Expand Down Expand Up @@ -250,6 +251,62 @@ export function useWidgetState<S>(defaultValue: S): [S, (newState: S | ((prev: S
return [state, setState];
}

// =============================================================================
// MODEL CONTEXT HOOKS
// =============================================================================

/**
* Hook to update the host's model context
*
* Unlike sendMessage which triggers follow-up actions, context updates
* inform the model about app state without triggering responses.
*
* Platform implementation details:
* - MCP Apps: Uses native protocol feature for pure context updates
* - ChatGPT: Uses setState/setWidgetState internally (exposes to AI + persists)
*
* On ChatGPT, both setState() and updateModelContext() expose state to the
* AI model. Use setState() for persistence-focused use cases, and
* updateModelContext() for context-focused use cases.
*
* @returns Function to update model context
*
* @example
* ```tsx
* function ShoppingCart({ items }) {
* const updateContext = useUpdateModelContext();
*
* // Keep the model informed about cart state
* useEffect(() => {
* updateContext({
* structuredContent: {
* itemCount: items.length,
* total: calculateTotal(items),
* currency: "USD"
* }
* });
* }, [items, updateContext]);
*
* return <CartUI items={items} />;
* }
* ```
*/
export function useUpdateModelContext(): (params: UpdateModelContextParams) => Promise<void> {
const { client } = useAppsContext();

return useCallback(
async (params: UpdateModelContextParams) => {
if (!client) {
// eslint-disable-next-line no-console
console.warn("[useUpdateModelContext] Client not available");
return;
}
await client.updateModelContext(params);
},
[client]
);
}

// =============================================================================
// UTILITY HOOKS
// =============================================================================
Expand Down
6 changes: 6 additions & 0 deletions packages/ui-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export type {
AppToolDefinition,
CallToolHandler,
ListToolsHandler,
// Model context types (ext-apps v0.4.0+)
ContainerDimensions,
ContentBlock,
UpdateModelContextParams,
} from "@mcp-apps-kit/ui";

// Context
Expand Down Expand Up @@ -51,6 +55,8 @@ export {
useHostCapabilities,
useHostVersion,
useSizeChangedNotifications,
// Model context (ext-apps v0.4.0+)
useUpdateModelContext,
} from "./hooks";

// File operation types
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"directory": "packages/ui"
},
"dependencies": {
"@modelcontextprotocol/ext-apps": "^0.2.2"
"@modelcontextprotocol/ext-apps": "^0.4.0"
},
"engines": {
"node": ">=18.0.0"
Expand Down
Loading