Migrate to MCP SDK 2.0 with official Protocol and isolated role peers (#720)
App and AppBridge extend the public Protocol from @modelcontextprotocol/client; the iframe wire protocol (ui/initialize only) is unchanged. Peers move to the split SDK 2.0 packages with client and server as optional role peers. Fixups (lockfile, peer ranges, restored handler guards, docs, wire-compat tests) follow in a separate PR. Co-authored-by: Andrew Khadder <andrew@manufact.com> Co-authored-by: Felix Weinberger <fweinberger@anthropic.com> Closes #702
This commit is contained in:
commit
1a713173cc
4 changed files with 2415 additions and 1867 deletions
|
|
@ -4,10 +4,10 @@
|
|||
* Or: node dist/index.js [--stdio]
|
||||
*/
|
||||
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import { createMcpExpressApp } from "@modelcontextprotocol/sdk/server/express.js";
|
||||
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
||||
import { createMcpExpressApp } from "@modelcontextprotocol/express";
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
import { NodeStreamableHTTPServerTransport } from "@modelcontextprotocol/node";
|
||||
import cors from "cors";
|
||||
import type { Request, Response } from "express";
|
||||
import { createServer } from "./server.js";
|
||||
|
|
@ -27,7 +27,7 @@ export async function startStreamableHTTPServer(
|
|||
|
||||
app.all("/mcp", async (req: Request, res: Response) => {
|
||||
const server = createServer();
|
||||
const transport = new StreamableHTTPServerTransport({
|
||||
const transport = new NodeStreamableHTTPServerTransport({
|
||||
sessionIdGenerator: undefined,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,11 @@
|
|||
"serve": "bun --watch main.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/client": "2.0.0",
|
||||
"@modelcontextprotocol/ext-apps": "^1.7.0",
|
||||
"@modelcontextprotocol/sdk": "^1.29.0",
|
||||
"@modelcontextprotocol/express": "2.0.0",
|
||||
"@modelcontextprotocol/node": "2.0.0",
|
||||
"@modelcontextprotocol/server": "2.0.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^5.1.0",
|
||||
"react": "^19.2.0",
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import {
|
|||
registerAppResource,
|
||||
registerAppTool,
|
||||
} from "@modelcontextprotocol/ext-apps/server";
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import type { ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
|
||||
import {
|
||||
McpServer,
|
||||
type ReadResourceResult,
|
||||
} from "@modelcontextprotocol/server";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
|
|
@ -161,7 +163,7 @@ export function createServer(): McpServer {
|
|||
title: "Show Three.js Scene",
|
||||
description:
|
||||
"Render an interactive 3D scene with custom Three.js code. Supports transparent backgrounds (alpha: true) for seamless host UI integration. Available globals: THREE, OrbitControls, EffectComposer, RenderPass, UnrealBloomPass, canvas, width, height.",
|
||||
inputSchema: {
|
||||
inputSchema: z.object({
|
||||
code: z
|
||||
.string()
|
||||
.default(DEFAULT_THREEJS_CODE)
|
||||
|
|
@ -172,7 +174,7 @@ export function createServer(): McpServer {
|
|||
.positive()
|
||||
.default(400)
|
||||
.describe("Height in pixels"),
|
||||
},
|
||||
}),
|
||||
outputSchema: z.object({
|
||||
success: z.boolean(),
|
||||
}),
|
||||
|
|
@ -192,7 +194,7 @@ export function createServer(): McpServer {
|
|||
{
|
||||
title: "Learn Three.js",
|
||||
description: "Get documentation and examples for using the Three.js View",
|
||||
inputSchema: {},
|
||||
inputSchema: z.object({}),
|
||||
},
|
||||
async () => {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
import type { App, McpUiHostContext } from "@modelcontextprotocol/ext-apps";
|
||||
import { useApp } from "@modelcontextprotocol/ext-apps/react";
|
||||
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
||||
import type { CallToolResult } from "@modelcontextprotocol/client";
|
||||
import { StrictMode, useState, useCallback, useEffect, useRef } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { z } from "zod";
|
||||
|
|
|
|||
Loading…
Reference in a new issue