Skip to content

Commit 4ff22d0

Browse files
Fix build errors in examples (#180)
* Update `package.json` * Add TypeScript type checking to example build scripts Add `tsc --noEmit &&` before `vite build` in all example `package.json` files to catch type errors during builds. Previously, type errors in `server.ts` files were not detected because Vite/Bun transpile without type checking. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Make `_meta` optional in `McpUiAppResourceConfig` The `_meta` and `ui` properties were required, causing TypeScript errors when calling `registerAppResource()` without providing metadata. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix Zod type compatibility in `registerAppTool()` Use `ZodRawShapeCompat | AnySchema` from SDK's `zod-compat` module instead of raw `ZodRawShape` to resolve type errors when examples pass `ZodObject` schemas to `registerAppTool()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Remove unused imports in example apps - `basic-server-react`: Remove unused `McpUiResourceTeardownResult` - `customer-segmentation-server`: Remove unused `PostMessageTransport` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix CI git install test for fork PRs Use `github.event.pull_request.head.repo.full_name` to correctly reference the fork repository when testing git installs from PRs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 82ab3c8 commit 4ff22d0

File tree

15 files changed

+41
-21
lines changed

15 files changed

+41
-21
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
mkdir test-project
145145
cd test-project
146146
npm init -y
147-
# Install from the PR branch
148-
npm install "git+https://github.com/${{ github.repository }}#${{ github.head_ref || github.ref_name }}"
147+
# Install from the PR branch (use head repo for fork PRs)
148+
npm install "git+https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}#${{ github.head_ref || github.ref_name }}"
149149
# Verify the package is usable (ESM import)
150150
node --input-type=module -e "import { App } from '@modelcontextprotocol/ext-apps'; console.log('Import successful:', typeof App)"

examples/basic-host/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "1.0.0",
55
"type": "module",
66
"scripts": {
7-
"build": "concurrently \"cross-env INPUT=index.html vite build\" \"cross-env INPUT=sandbox.html vite build\"",
7+
"build": "tsc --noEmit && concurrently \"cross-env INPUT=index.html vite build\" \"cross-env INPUT=sandbox.html vite build\"",
88
"watch": "concurrently \"cross-env INPUT=index.html vite build --watch\" \"cross-env INPUT=sandbox.html vite build --watch\"",
99
"serve": "bun serve.ts",
1010
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "cross-env INPUT=mcp-app.html vite build",
7+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build",
88
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
99
"serve": "bun server.ts",
1010
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-react/src/mcp-app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file App that demonstrates a few features using MCP Apps SDK + React.
33
*/
4-
import type { App, McpUiResourceTeardownResult } from "@modelcontextprotocol/ext-apps";
4+
import type { App } from "@modelcontextprotocol/ext-apps";
55
import { useApp } from "@modelcontextprotocol/ext-apps/react";
66
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
77
import { StrictMode, useCallback, useEffect, useState } from "react";

examples/basic-server-vanillajs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "cross-env INPUT=mcp-app.html vite build",
7+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build",
88
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
99
"serve": "bun server.ts",
1010
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/budget-allocator-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "cross-env INPUT=mcp-app.html vite build",
7+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build",
88
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
99
"serve:http": "bun server.ts",
1010
"serve:stdio": "bun server.ts --stdio",

examples/cohort-heatmap-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "cross-env INPUT=mcp-app.html vite build",
7+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build",
88
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
99
"serve:http": "bun server.ts",
1010
"serve:stdio": "bun server.ts --stdio",

examples/customer-segmentation-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "cross-env INPUT=mcp-app.html vite build",
7+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build",
88
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
99
"serve:http": "bun server.ts",
1010
"serve:stdio": "bun server.ts --stdio",

examples/customer-segmentation-server/src/mcp-app.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
import {
55
App,
6-
PostMessageTransport,
76
applyHostStyleVariables,
87
applyHostFonts,
98
applyDocumentTheme,

examples/scenario-modeler-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "cross-env INPUT=mcp-app.html vite build",
7+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build",
88
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
99
"serve:http": "bun server.ts",
1010
"serve:stdio": "bun server.ts --stdio",

0 commit comments

Comments
 (0)