Skip to content
Open
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 docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import cors from "cors";
import express from "express";
import fs from "node:fs/promises";
import path from "node:path";
import { z } from "zod";
import * as z from "zod";

const server = new McpServer({
name: "My MCP App Server",
Expand Down
3 changes: 1 addition & 2 deletions examples/basic-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"@modelcontextprotocol/ext-apps": "../..",
"@modelcontextprotocol/sdk": "^1.22.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"zod": "^3.25.0"
"react-dom": "^19.2.0"
},
"devDependencies": {
"@types/express": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-server-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@modelcontextprotocol/sdk": "^1.22.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"zod": "^3.25.0"
"zod": "^4.1.13"
},
"devDependencies": {
"@types/cors": "^2.8.19",
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-server-vanillajs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@modelcontextprotocol/ext-apps": "../..",
"@modelcontextprotocol/sdk": "^1.22.0",
"zod": "^3.25.0"
"zod": "^4.1.13"
},
"devDependencies": {
"@types/cors": "^2.8.19",
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-server-vanillajs/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cors from "cors";
import express, { type Request, type Response } from "express";
import fs from "node:fs/promises";
import path from "node:path";
import { z } from "zod";
import * as z from "zod";
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";

const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
Expand Down
25 changes: 14 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@
"nodemon": "^3.1.0",
"prettier": "^3.6.2",
"typedoc": "^0.28.14",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"zod": "^4.1.13"
},
"peerDependencies": {
"zod": "^3.25.0 || ^4.0.0"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.23.0",
"bun": "^1.3.2",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"zod": "^3.25"
"react-dom": "^19.2.0"
},
"optionalDependencies": {
"@rollup/rollup-darwin-arm64": "^4.53.3",
Expand Down
10 changes: 5 additions & 5 deletions src/app-bridge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { ZodLiteral, ZodObject } from "zod/v4";
import * as z from "zod/v4/core";

import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
import {
Expand Down Expand Up @@ -773,10 +773,10 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
}

private forwardRequest<
Req extends ZodObject<{
method: ZodLiteral<string>;
Req extends z.$ZodObject<{
method: z.$ZodLiteral<string>;
}>,
Res extends ZodObject<{}>,
Res extends z.$ZodObject<{}>,
>(requestSchema: Req, resultSchema: Res) {
this.setRequestHandler(requestSchema, async (request, extra) => {
console.log(`Forwarding request ${request.method} from MCP UI client`);
Expand All @@ -786,7 +786,7 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
});
}
private forwardNotification<
N extends ZodObject<{ method: ZodLiteral<string> }>,
N extends z.$ZodObject<{ method: z.$ZodLiteral<string> }>,
>(notificationSchema: N) {
this.setNotificationHandler(notificationSchema, async (notification) => {
console.log(
Expand Down
11 changes: 8 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
Tool,
ToolSchema,
} from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod/v4";
import type * as z3 from "zod/v3";
import type * as z4 from "zod/v4/core";
import * as z from "zod";

/**
* Type-level assertion that validates a Zod schema produces the expected interface.
Expand All @@ -28,7 +30,10 @@ import { z } from "zod/v4";
*
* @internal
*/
type VerifySchemaMatches<TSchema extends z.ZodTypeAny, TInterface> =
type VerifySchemaMatches<
TSchema extends z3.ZodTypeAny | z4.$ZodType,
TInterface,
> =
z.infer<TSchema> extends TInterface
? TInterface extends z.infer<TSchema>
? true
Expand Down Expand Up @@ -66,7 +71,7 @@ export interface McpUiOpenLinkRequest {
export const McpUiOpenLinkRequestSchema = RequestSchema.extend({
method: z.literal("ui/open-link"),
params: z.object({
url: z.string().url(),
url: z.url(),
}),
});

Expand Down