diff --git a/README.md b/README.md index 7348e1541..27d7844b8 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ directory contains demo apps showcasing real-world use cases. | | | |:---:|:---| -| [![Basic](examples/basic-server-react/grid-cell.png "Starter template")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-react) | The same app built with different frameworks — pick your favorite!

[React](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-react) · [Vue](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vue) · [Svelte](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-svelte) · [Preact](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-preact) · [Solid](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-solid) · [Vanilla JS](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vanillajs) | +| [![Basic](examples/basic-server-react/grid-cell.png "Starter template")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-react) | The same app built with different frameworks — pick your favorite!

[Angular](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-angular) · [React](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-react) · [Vue](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vue) · [Svelte](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-svelte) · [Preact](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-preact) · [Solid](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-solid) · [Vanilla JS](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vanillajs) | ### Running the Examples diff --git a/docs/blog/angular-mcp-apps.md b/docs/blog/angular-mcp-apps.md new file mode 100644 index 000000000..c86dcd271 --- /dev/null +++ b/docs/blog/angular-mcp-apps.md @@ -0,0 +1,716 @@ +# Building MCP Apps with Angular + +If you've been building MCP servers, you know the drill: your tool returns JSON, the host renders it as text, and the user squints at a timestamp string. [MCP Apps](https://github.com/modelcontextprotocol/ext-apps) change that — they let your server ship an interactive UI that the host renders in an iframe, right inside the conversation. + +MCP Apps are built on the **Model Context Protocol** — an open standard. They're not tied to Claude or any specific AI provider. Any host that implements the MCP Apps specification (Claude Desktop, custom chat clients, or other AI assistants that adopt MCP) can render your UI. You build it once, and it works everywhere MCP is supported. + +This post walks through building MCP Apps with Angular. We'll start with a single tool, add a second tool with its own UI, and then show how to share code between them without bloating either bundle. + +## How MCP Apps Work (Quick Recap) + +``` +View (Angular App) <--PostMessageTransport--> Host (AppBridge) <--MCP Client--> MCP Server +``` + +- **Server** registers tools and resources. Each tool can point to a resource URI containing the UI. +- **Host** (the chat client) fetches that resource and renders it in a sandboxed iframe. +- **View** is your Angular app running inside that iframe. It uses the `App` class from `@modelcontextprotocol/ext-apps` to communicate with the host. + +The key insight: your UI is bundled into a **single self-contained HTML file** using Vite and `vite-plugin-singlefile`. The host doesn't need to know it's Angular — it just loads HTML. + +## Project Structure + +``` +basic-server-angular/ +├── mcp-app.html # HTML entry point for UI #1 +├── greeting-app.html # HTML entry point for UI #2 +├── src/ +│ ├── main.ts # Angular bootstrap for UI #1 +│ ├── app.component.ts # Get Time component +│ ├── greeting-main.ts # Angular bootstrap for UI #2 +│ ├── greeting.component.ts # Greeting component +│ ├── shared/ +│ │ └── mcp-app-setup.ts # Shared App + theming setup +│ └── global.css # Host-aware CSS variables +├── server.ts # MCP server (registers tools + resources) +├── main.ts # Server entry point (HTTP + stdio) +└── vite.config.ts # Builds each HTML into a single file +``` + +## Step 1: The Server + +Every MCP App starts on the server side. You register a **tool** (what the LLM calls) and a **resource** (the HTML that gets rendered). They're linked by a resource URI. + +```ts +// server.ts +import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { + CallToolResult, + ReadResourceResult, +} from "@modelcontextprotocol/sdk/types.js"; +import fs from "node:fs/promises"; +import path from "node:path"; +import { + registerAppTool, + registerAppResource, + RESOURCE_MIME_TYPE, +} from "@modelcontextprotocol/ext-apps/server"; + +const DIST_DIR = import.meta.filename.endsWith(".ts") + ? path.join(import.meta.dirname, "dist") + : import.meta.dirname; + +export function createServer(): McpServer { + const server = new McpServer({ + name: "Basic MCP App Server (Angular)", + version: "1.0.0", + }); + + const resourceUri = "ui://get-time/mcp-app.html"; + + // Register the tool — this is what the LLM calls + registerAppTool( + server, + "get-time", + { + title: "Get Time", + description: "Returns the current server time as an ISO 8601 string.", + inputSchema: {}, + _meta: { ui: { resourceUri } }, // Links this tool to its UI + }, + async (): Promise => { + const time = new Date().toISOString(); + return { content: [{ type: "text", text: time }] }; + }, + ); + + // Register the resource — the bundled HTML for this tool's UI + registerAppResource( + server, + resourceUri, + resourceUri, + { + mimeType: RESOURCE_MIME_TYPE, + }, + async (): Promise => { + const html = await fs.readFile( + path.join(DIST_DIR, "mcp-app.html"), + "utf-8", + ); + return { + contents: [ + { uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }, + ], + }; + }, + ); + + return server; +} +``` + +The `_meta.ui.resourceUri` is the glue. When the host calls this tool, it reads that field to know which resource to fetch and render. + +## Step 2: The HTML Entry Point + +Each UI needs an HTML file at the project root. This is the Vite entry point that gets bundled into a single self-contained file. + +```html + + + + + + + + Get Time App + + + + + + + +``` + +## Step 3: The Angular App + +The bootstrap is minimal — Angular 19+ with zoneless change detection: + +```ts +// src/main.ts +import "@angular/compiler"; +import { bootstrapApplication } from "@angular/platform-browser"; +import { provideZonelessChangeDetection } from "@angular/core"; +import { AppComponent } from "./app.component"; +import "./global.css"; + +bootstrapApplication(AppComponent, { + providers: [provideZonelessChangeDetection()], +}).catch((err) => console.error(err)); +``` + +Now the component itself. The `App` class from `@modelcontextprotocol/ext-apps` is the bridge between your Angular code and the host: + +```ts +// src/app.component.ts +import { Component, type OnInit, signal } from "@angular/core"; +import { + App, + applyDocumentTheme, + applyHostStyleVariables, + applyHostFonts, + type McpUiHostContext, +} from "@modelcontextprotocol/ext-apps"; +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; + +function extractText(result: CallToolResult): string { + return result.content?.find((c) => c.type === "text")!.text; +} + +@Component({ + selector: "app-root", + template: ` +
+

+ Server Time: {{ serverTime() }} +

+ +
+ `, +}) +export class AppComponent implements OnInit { + private app: App | null = null; + hostContext = signal(undefined); + serverTime = signal("Loading..."); + + async ngOnInit() { + const instance = new App({ name: "Get Time App", version: "1.0.0" }); + + // Called when the host sends tool results back to the UI + instance.ontoolresult = (result) => { + this.serverTime.set(extractText(result)); + }; + + // Respond to theme and style changes from the host + instance.onhostcontextchanged = (params) => { + const ctx = { ...this.hostContext(), ...params }; + this.hostContext.set(ctx); + if (ctx.theme) applyDocumentTheme(ctx.theme); + if (ctx.styles?.variables) applyHostStyleVariables(ctx.styles.variables); + if (ctx.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); + }; + + // Connect to the host via PostMessageTransport + await instance.connect(); + this.app = instance; + + // Apply initial host context + const ctx = instance.getHostContext(); + this.hostContext.set(ctx); + if (ctx?.theme) applyDocumentTheme(ctx.theme); + if (ctx?.styles?.variables) applyHostStyleVariables(ctx.styles.variables); + if (ctx?.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); + } + + async handleGetTime() { + if (!this.app) return; + try { + const result = await this.app.callServerTool({ + name: "get-time", + arguments: {}, + }); + this.serverTime.set(extractText(result)); + } catch { + this.serverTime.set("[ERROR]"); + } + } +} +``` + +A few things to note: + +- **`App` class** — this is the SDK's main entry point. You create one, wire up callbacks, and call `connect()`. That's it. +- **`ontoolresult`** — fires when the host sends a tool result. This is how data flows from the server to your UI. +- **`callServerTool()`** — lets the UI call tools on the server. The host proxies this through the MCP client. +- **`onhostcontextchanged`** — the host pushes theme and style updates. The helper functions (`applyDocumentTheme`, etc.) apply them as CSS variables on `document`, so your component styles just work. +- **`safeAreaInsets`** — the host tells you how much padding to leave for its chrome. Use it on your root container. + +## Step 4: Adding a Second UI + +Here's where it gets interesting. Say you want a "Greet" tool with its own UI. Each tool gets its own HTML entry point, its own Angular app, and its own resource registration. + +### Server: Register Both Tools + +```ts +// server.ts — inside createServer() + +// Tool #1: Get Time +const timeResourceUri = "ui://get-time/mcp-app.html"; +registerAppTool( + server, + "get-time", + { + title: "Get Time", + description: "Returns the current server time.", + inputSchema: {}, + _meta: { ui: { resourceUri: timeResourceUri } }, + }, + async (): Promise => { + return { content: [{ type: "text", text: new Date().toISOString() }] }; + }, +); +registerAppResource( + server, + timeResourceUri, + timeResourceUri, + { + mimeType: RESOURCE_MIME_TYPE, + }, + async (): Promise => { + const html = await fs.readFile( + path.join(DIST_DIR, "mcp-app.html"), + "utf-8", + ); + return { + contents: [ + { uri: timeResourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }, + ], + }; + }, +); + +// Tool #2: Greet +const greetResourceUri = "ui://greet/greeting-app.html"; +registerAppTool( + server, + "greet", + { + title: "Greet", + description: "Returns a personalised greeting.", + inputSchema: { + name: z.string().optional().default("World").describe("Name to greet"), + }, + _meta: { ui: { resourceUri: greetResourceUri } }, + }, + async ({ name }: { name?: string }): Promise => { + const greeting = `Hello, ${name || "World"}! Welcome to the MCP Apps SDK.`; + return { content: [{ type: "text", text: greeting }] }; + }, +); +registerAppResource( + server, + greetResourceUri, + greetResourceUri, + { + mimeType: RESOURCE_MIME_TYPE, + }, + async (): Promise => { + const html = await fs.readFile( + path.join(DIST_DIR, "greeting-app.html"), + "utf-8", + ); + return { + contents: [ + { uri: greetResourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }, + ], + }; + }, +); +``` + +### Greeting Component + +The greeting UI is a completely separate Angular app: + +```html + + + + + + + + Greeting App + + + + + + + +``` + +```ts +// src/greeting-main.ts +import "@angular/compiler"; +import { bootstrapApplication } from "@angular/platform-browser"; +import { provideZonelessChangeDetection } from "@angular/core"; +import { GreetingComponent } from "./greeting.component"; +import "./global.css"; + +bootstrapApplication(GreetingComponent, { + providers: [provideZonelessChangeDetection()], +}).catch((err) => console.error(err)); +``` + +```ts +// src/greeting.component.ts +import { Component, type OnInit, signal } from "@angular/core"; +import { FormsModule } from "@angular/forms"; +import { + App, + applyDocumentTheme, + applyHostStyleVariables, + applyHostFonts, + type McpUiHostContext, +} from "@modelcontextprotocol/ext-apps"; +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; + +function extractText(result: CallToolResult): string { + return result.content?.find((c) => c.type === "text")!.text; +} + +@Component({ + selector: "greeting-root", + imports: [FormsModule], + template: ` +
+
+ + + +
+ + @if (greeting()) { +
{{ greeting() }}
+ } +
+ `, +}) +export class GreetingComponent implements OnInit { + private app: App | null = null; + hostContext = signal(undefined); + greeting = signal(""); + nameText = ""; + + async ngOnInit() { + const instance = new App({ name: "Greeting App", version: "1.0.0" }); + + instance.ontoolresult = (result) => { + this.greeting.set(extractText(result)); + }; + + instance.onhostcontextchanged = (params) => { + const ctx = { ...this.hostContext(), ...params }; + this.hostContext.set(ctx); + if (ctx.theme) applyDocumentTheme(ctx.theme); + if (ctx.styles?.variables) applyHostStyleVariables(ctx.styles.variables); + if (ctx.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); + }; + + await instance.connect(); + this.app = instance; + + const ctx = instance.getHostContext(); + this.hostContext.set(ctx); + if (ctx?.theme) applyDocumentTheme(ctx.theme); + if (ctx?.styles?.variables) applyHostStyleVariables(ctx.styles.variables); + if (ctx?.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); + } + + async handleGreet() { + if (!this.app) return; + try { + const name = this.nameText.trim() || "World"; + const result = await this.app.callServerTool({ + name: "greet", + arguments: { name }, + }); + this.greeting.set(extractText(result)); + } catch { + this.greeting.set("[ERROR]"); + } + } +} +``` + +## Step 5: Sharing Code Between UIs + +You probably noticed that both components have identical `App` setup and theming boilerplate. That's a great candidate for extraction — and since each HTML is a separate Vite entry point, **Vite's tree-shaking ensures each bundle only includes what it actually imports**. + +Create a shared setup module: + +```ts +// src/shared/mcp-app-setup.ts +import { + App, + applyDocumentTheme, + applyHostStyleVariables, + applyHostFonts, + type McpUiHostContext, +} from "@modelcontextprotocol/ext-apps"; +import type { WritableSignal } from "@angular/core"; +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; + +/** + * Extract text content from a tool result. + */ +export function extractText(result: CallToolResult): string { + return result.content?.find((c) => c.type === "text")!.text; +} + +/** + * Apply host context (theme, styles, fonts) to the document. + */ +function applyContext(ctx: McpUiHostContext): void { + if (ctx.theme) applyDocumentTheme(ctx.theme); + if (ctx.styles?.variables) applyHostStyleVariables(ctx.styles.variables); + if (ctx.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); +} + +/** + * Create and connect an MCP App instance with standard host-context + * handling wired up. Both UIs call this instead of duplicating setup. + */ +export async function createMcpApp( + name: string, + hostContext: WritableSignal, + onToolResult?: (result: CallToolResult) => void, +): Promise { + const app = new App({ name, version: "1.0.0" }); + + app.ontoolinput = (params) => console.info("Received tool input:", params); + app.ontoolcancelled = (params) => + console.info("Tool cancelled:", params.reason); + app.onerror = console.error; + + if (onToolResult) { + app.ontoolresult = onToolResult; + } + + app.onhostcontextchanged = (params) => { + const ctx = { ...hostContext(), ...params } as McpUiHostContext; + hostContext.set(ctx); + applyContext(ctx); + }; + + await app.connect(); + + const ctx = app.getHostContext(); + hostContext.set(ctx); + if (ctx) applyContext(ctx); + + return app; +} +``` + +Now both components become much simpler: + +```ts +// src/app.component.ts — simplified +import { Component, type OnInit, signal } from "@angular/core"; +import type { McpUiHostContext } from "@modelcontextprotocol/ext-apps"; +import type { App } from "@modelcontextprotocol/ext-apps"; +import { createMcpApp, extractText } from "./shared/mcp-app-setup"; + +@Component({ + selector: "app-root", + template: ` +
+

+ Server Time: {{ serverTime() }} +

+ +
+ `, +}) +export class AppComponent implements OnInit { + private app: App | null = null; + hostContext = signal(undefined); + serverTime = signal("Loading..."); + + async ngOnInit() { + this.app = await createMcpApp("Get Time App", this.hostContext, (result) => + this.serverTime.set(extractText(result)), + ); + } + + async handleGetTime() { + if (!this.app) return; + try { + const result = await this.app.callServerTool({ + name: "get-time", + arguments: {}, + }); + this.serverTime.set(extractText(result)); + } catch { + this.serverTime.set("[ERROR]"); + } + } +} +``` + +```ts +// src/greeting.component.ts — simplified +import { Component, type OnInit, signal } from "@angular/core"; +import { FormsModule } from "@angular/forms"; +import type { McpUiHostContext } from "@modelcontextprotocol/ext-apps"; +import type { App } from "@modelcontextprotocol/ext-apps"; +import { createMcpApp, extractText } from "./shared/mcp-app-setup"; + +@Component({ + selector: "greeting-root", + imports: [FormsModule], + template: ` +
+ + + + @if (greeting()) { +
{{ greeting() }}
+ } +
+ `, +}) +export class GreetingComponent implements OnInit { + private app: App | null = null; + hostContext = signal(undefined); + greeting = signal(""); + nameText = ""; + + async ngOnInit() { + this.app = await createMcpApp("Greeting App", this.hostContext, (result) => + this.greeting.set(extractText(result)), + ); + } + + async handleGreet() { + if (!this.app) return; + try { + const name = this.nameText.trim() || "World"; + const result = await this.app.callServerTool({ + name: "greet", + arguments: { name }, + }); + this.greeting.set(extractText(result)); + } catch { + this.greeting.set("[ERROR]"); + } + } +} +``` + +Both components import `createMcpApp` and `extractText` from the shared module. Since they're in separate Vite builds, tree-shaking still applies — if you add more shared utilities later, each bundle only pulls in what it calls. + +### Sharing Models and Types + +The same principle works for shared data models. If both UIs work with common types — say a user profile that comes from the server: + +```ts +// src/shared/models.ts +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; + +export interface UserProfile { + name: string; + email: string; + role: "admin" | "viewer"; +} + +export function parseUserProfile(result: CallToolResult): UserProfile { + const text = result.content?.find((c) => c.type === "text")!.text; + return JSON.parse(text) as UserProfile; +} +``` + +Both components can `import { UserProfile, parseUserProfile } from "./shared/models"` — the types are erased at build time (zero cost), and the parser function is only included in bundles that call it. This is a natural place to put validation logic, formatters, or any domain code that multiple UIs need. + +## Step 6: The Build + +The Vite config uses an `INPUT` environment variable to select which HTML file to build: + +```ts +// vite.config.ts +import { defineConfig } from "vite"; +import { viteSingleFile } from "vite-plugin-singlefile"; + +const INPUT = process.env.INPUT; +if (!INPUT) throw new Error("INPUT environment variable is not set"); + +export default defineConfig({ + plugins: [viteSingleFile()], + build: { + rollupOptions: { input: INPUT }, + outDir: "dist", + emptyOutDir: false, // Key: don't wipe previous builds + }, +}); +``` + +The `emptyOutDir: false` is important — it lets you run Vite multiple times, once per HTML file, into the same `dist/` directory. + +The build script chains them: + +```json +{ + "scripts": { + "build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && cross-env INPUT=greeting-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node" + } +} +``` + +Each HTML file produces a fully self-contained output (all JS, CSS, and Angular runtime inlined). The two bundles are completely independent. + +## Theming: Looking Native in Any Host + +MCP Apps can look native in any host (Claude Desktop, a custom chat client, etc.) by using CSS variables that the host provides. The `global.css` file defines sensible fallbacks: + +```css +:root { + color-scheme: light dark; + + --color-text-primary: light-dark(#1f2937, #f3f4f6); + --color-background-primary: light-dark(#ffffff, #1a1a1a); + --color-accent: #2563eb; + --color-text-on-accent: #ffffff; + --border-radius-md: 6px; + + --spacing-unit: var(--font-text-md-size); + --spacing-sm: calc(var(--spacing-unit) * 0.5); + --spacing-md: var(--spacing-unit); + --spacing-lg: calc(var(--spacing-unit) * 1.5); + + /* ... more variables */ +} +``` + +When the host sends style updates via `onhostcontextchanged`, the helper functions overwrite these variables on the document root. Your Angular component styles reference the variables (`var(--color-accent)`, `var(--spacing-md)`), so they adapt automatically — no theme prop drilling needed. + +## Recap + +The pattern for building Angular MCP Apps: + +1. **Server**: register a tool + resource pair per UI, linked by a resource URI +2. **HTML**: one entry point per UI, each bootstrapping its own Angular app +3. **Component**: create an `App` instance, wire up callbacks, call `connect()` +4. **Shared code**: extract common setup into a shared module — Vite tree-shakes per entry point +5. **Build**: run Vite once per HTML file into the same `dist/` directory +6. **Theming**: use host CSS variables with fallbacks, apply updates via `onhostcontextchanged` + +Each UI is a self-contained Angular application. They share a server, they can share code, but their bundles are independent. Add a third tool? Same pattern — new HTML, new component, new registration, one more `vite build` in the chain. + +The full source is available in the [ext-apps examples](https://github.com/anthropics/ext-apps/tree/main/examples/basic-server-angular). diff --git a/examples/basic-server-angular/README.md b/examples/basic-server-angular/README.md new file mode 100644 index 000000000..467ab85b9 --- /dev/null +++ b/examples/basic-server-angular/README.md @@ -0,0 +1,73 @@ +# Example: Basic Server (Angular) + +An MCP App example with an Angular UI using standalone components and signals. + +> [!TIP] +> Looking for a vanilla JavaScript example? See [`basic-server-vanillajs`](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vanillajs)! + +## MCP Client Configuration + +Add to your MCP client configuration (stdio transport): + +```json +{ + "mcpServers": { + "basic-angular": { + "command": "npx", + "args": [ + "-y", + "--silent", + "--registry=https://registry.npmjs.org/", + "@modelcontextprotocol/server-basic-angular", + "--stdio" + ] + } + } +} +``` + +### Local Development + +To test local modifications, use this configuration (replace `~/code/ext-apps` with your clone path): + +```json +{ + "mcpServers": { + "basic-angular": { + "command": "bash", + "args": [ + "-c", + "cd ~/code/ext-apps/examples/basic-server-angular && npm run build >&2 && node dist/index.js --stdio" + ] + } + } +} +``` + +## Overview + +- Tool registration with a linked UI resource +- Angular UI using the [`App`](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html) class +- App communication APIs: [`callServerTool`](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html#callservertool), [`sendMessage`](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html#sendmessage), [`sendLog`](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html#sendlog), [`openLink`](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html#openlink) + +## Key Files + +- [`server.ts`](server.ts) - MCP server with tool and resource registration +- [`mcp-app.html`](mcp-app.html) / [`src/app.component.ts`](src/app.component.ts) - Angular UI using `App` class + +## Getting Started + +```bash +npm install +npm run dev +``` + +## How It Works + +1. The server registers a `get-time` tool with metadata linking it to a UI HTML resource (`ui://get-time/mcp-app.html`). +2. When the tool is invoked, the Host renders the UI from the resource. +3. The UI uses the MCP App SDK API to communicate with the host and call server tools. + +## Build System + +This example bundles into a single HTML file using Vite with `vite-plugin-singlefile` — see [`vite.config.ts`](vite.config.ts). This allows all UI content to be served as a single MCP resource. Alternatively, MCP apps can load external resources by defining [`_meta.ui.csp.resourceDomains`](https://apps.extensions.modelcontextprotocol.io/api/interfaces/app.McpUiResourceCsp.html#resourcedomains) in the UI resource metadata. diff --git a/examples/basic-server-angular/greeting-app.html b/examples/basic-server-angular/greeting-app.html new file mode 100644 index 000000000..44607bdf0 --- /dev/null +++ b/examples/basic-server-angular/greeting-app.html @@ -0,0 +1,14 @@ + + + + + + + Greeting App + + + + + + + diff --git a/examples/basic-server-angular/main.ts b/examples/basic-server-angular/main.ts new file mode 100644 index 000000000..6aafcb2ac --- /dev/null +++ b/examples/basic-server-angular/main.ts @@ -0,0 +1,93 @@ +/** + * Entry point for running the MCP server. + * Run with: npx mcp-server-basic-angular + * 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 cors from "cors"; +import type { Request, Response } from "express"; +import { createServer } from "./server.js"; + +/** + * Starts an MCP server with Streamable HTTP transport in stateless mode. + * + * @param createServer - Factory function that creates a new McpServer instance per request. + */ +export async function startStreamableHTTPServer( + createServer: () => McpServer, +): Promise { + const port = parseInt(process.env.PORT ?? "3001", 10); + + const app = createMcpExpressApp({ host: "0.0.0.0" }); + app.use(cors()); + + app.all("/mcp", async (req: Request, res: Response) => { + const server = createServer(); + const transport = new StreamableHTTPServerTransport({ + sessionIdGenerator: undefined, + }); + + res.on("close", () => { + transport.close().catch(() => {}); + server.close().catch(() => {}); + }); + + try { + await server.connect(transport); + await transport.handleRequest(req, res, req.body); + } catch (error) { + console.error("MCP error:", error); + if (!res.headersSent) { + res.status(500).json({ + jsonrpc: "2.0", + error: { code: -32603, message: "Internal server error" }, + id: null, + }); + } + } + }); + + const httpServer = app.listen(port, (err) => { + if (err) { + console.error("Failed to start server:", err); + process.exit(1); + } + console.log(`MCP server listening on http://localhost:${port}/mcp`); + }); + + const shutdown = () => { + console.log("\nShutting down..."); + httpServer.close(() => process.exit(0)); + }; + + process.on("SIGINT", shutdown); + process.on("SIGTERM", shutdown); +} + +/** + * Starts an MCP server with stdio transport. + * + * @param createServer - Factory function that creates a new McpServer instance. + */ +export async function startStdioServer( + createServer: () => McpServer, +): Promise { + await createServer().connect(new StdioServerTransport()); +} + +async function main() { + if (process.argv.includes("--stdio")) { + await startStdioServer(createServer); + } else { + await startStreamableHTTPServer(createServer); + } +} + +main().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/examples/basic-server-angular/mcp-app.html b/examples/basic-server-angular/mcp-app.html new file mode 100644 index 000000000..12628deb6 --- /dev/null +++ b/examples/basic-server-angular/mcp-app.html @@ -0,0 +1,14 @@ + + + + + + + Get Time App + + + + + + + diff --git a/examples/basic-server-angular/package.json b/examples/basic-server-angular/package.json new file mode 100644 index 000000000..da8908e7d --- /dev/null +++ b/examples/basic-server-angular/package.json @@ -0,0 +1,60 @@ +{ + "name": "@modelcontextprotocol/server-basic-angular", + "version": "1.7.0", + "type": "module", + "description": "Basic MCP App Server example using Angular", + "repository": { + "type": "git", + "url": "https://github.com/modelcontextprotocol/ext-apps", + "directory": "examples/basic-server-angular" + }, + "license": "MIT", + "main": "dist/server.js", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && cross-env INPUT=greeting-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"", + "watch": "cross-env INPUT=mcp-app.html vite build --watch", + "serve": "bun --watch main.ts", + "serve:stdio": "bun main.ts --stdio", + "start": "cross-env NODE_ENV=development npm run build && npm run serve", + "start:stdio": "cross-env NODE_ENV=development npm run build 1>&2 && npm run serve:stdio", + "dev": "cross-env NODE_ENV=development concurrently \"npm run watch\" \"npm run serve\"", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "@angular/common": "^21.0.0", + "@angular/compiler": "^21.0.0", + "@angular/core": "^21.0.0", + "@angular/forms": "^21.0.0", + "@angular/platform-browser": "^21.0.0", + "@angular/platform-browser-dynamic": "^21.0.0", + "@modelcontextprotocol/ext-apps": "^1.0.0", + "@modelcontextprotocol/sdk": "^1.29.0", + "cors": "^2.8.5", + "express": "^5.1.0", + "rxjs": "^7.8.0", + "zod": "^4.1.13" + }, + "devDependencies": { + "@types/cors": "^2.8.19", + "@types/express": "^5.0.0", + "@types/node": "22.10.0", + "concurrently": "^9.2.1", + "cross-env": "^10.1.0", + "typescript": "^5.9.3", + "vite": "^6.0.0", + "vite-plugin-singlefile": "^2.3.0" + }, + "types": "dist/server.d.ts", + "exports": { + ".": { + "types": "./dist/server.d.ts", + "default": "./dist/server.js" + } + }, + "bin": { + "mcp-server-basic-angular": "dist/index.js" + } +} diff --git a/examples/basic-server-angular/server.ts b/examples/basic-server-angular/server.ts new file mode 100644 index 000000000..bcf3aecba --- /dev/null +++ b/examples/basic-server-angular/server.ts @@ -0,0 +1,86 @@ +import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { CallToolResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js"; +import fs from "node:fs/promises"; +import path from "node:path"; +import { z } from "zod"; +import { registerAppTool, registerAppResource, RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/server"; +// Works both from source (server.ts) and compiled (dist/server.js) +const DIST_DIR = import.meta.filename.endsWith(".ts") + ? path.join(import.meta.dirname, "dist") + : import.meta.dirname; + +/** + * Creates a new MCP server instance with tools and resources registered. + */ +export function createServer(): McpServer { + const server = new McpServer({ + name: "Basic MCP App Server (Angular)", + version: "1.0.0", + }); + + // ── Get Time ────────────────────────────────────────────────────────── + const timeResourceUri = "ui://get-time/mcp-app.html"; + + registerAppTool(server, + "get-time", + { + title: "Get Time", + description: "Returns the current server time as an ISO 8601 string.", + inputSchema: {}, + _meta: { ui: { resourceUri: timeResourceUri } }, + }, + async (): Promise => { + const time = new Date().toISOString(); + return { content: [{ type: "text", text: time }] }; + }, + ); + + registerAppResource(server, + timeResourceUri, + timeResourceUri, + { mimeType: RESOURCE_MIME_TYPE }, + async (): Promise => { + const html = await fs.readFile(path.join(DIST_DIR, "mcp-app.html"), "utf-8"); + return { + contents: [ + { uri: timeResourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }, + ], + }; + }, + ); + + // ── Greet ─────────────────────────────────────────────────────────── + const greetResourceUri = "ui://greet/greeting-app.html"; + + registerAppTool(server, + "greet", + { + title: "Greet", + description: "Returns a personalised greeting for the given name.", + inputSchema: { + name: z.string().optional().default("World").describe("Name to greet"), + }, + _meta: { ui: { resourceUri: greetResourceUri } }, + }, + async ({ name }: { name?: string }): Promise => { + const greeting = `Hello, ${name || "World"}! Welcome to the MCP Apps SDK.`; + return { content: [{ type: "text", text: greeting }] }; + }, + ); + + registerAppResource(server, + greetResourceUri, + greetResourceUri, + { mimeType: RESOURCE_MIME_TYPE }, + async (): Promise => { + const html = await fs.readFile(path.join(DIST_DIR, "greeting-app.html"), "utf-8"); + return { + contents: [ + { uri: greetResourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }, + ], + }; + }, + ); + + return server; +} diff --git a/examples/basic-server-angular/src/app.component.ts b/examples/basic-server-angular/src/app.component.ts new file mode 100644 index 000000000..8404f8d30 --- /dev/null +++ b/examples/basic-server-angular/src/app.component.ts @@ -0,0 +1,230 @@ +import { Component, type OnInit, signal } from "@angular/core"; +import { FormsModule } from "@angular/forms"; +import { + App, + applyDocumentTheme, + applyHostFonts, + applyHostStyleVariables, + type McpUiHostContext, +} from "@modelcontextprotocol/ext-apps"; +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; + +function extractTime(result: CallToolResult): string { + const { text } = result.content?.find((c) => c.type === "text")!; + return text; +} + +@Component({ + selector: "app-root", + imports: [FormsModule], + styles: ` + .main { + width: 100%; + max-width: 425px; + box-sizing: border-box; + + > * { + margin-top: 0; + margin-bottom: 0; + } + + > * + * { + margin-top: var(--spacing-lg); + } + } + + .action { + > * { + margin-top: 0; + margin-bottom: 0; + width: 100%; + } + + > * + * { + margin-top: var(--spacing-sm); + } + + /* Server time row: flex layout for consistent mask width in E2E tests */ + > p { + display: flex; + align-items: baseline; + gap: var(--spacing-xs); + } + + textarea, + input { + display: block; + font-family: inherit; + font-size: inherit; + } + + button { + padding: var(--spacing-sm) var(--spacing-md); + border: none; + border-radius: var(--border-radius-md); + color: var(--color-text-on-accent); + font-weight: var(--font-weight-bold); + background-color: var(--color-accent); + cursor: pointer; + + &:hover { + background-color: color-mix(in srgb, var(--color-accent) 85%, var(--color-background-inverse)); + } + + &:focus-visible { + outline: calc(var(--border-width-regular) * 2) solid var(--color-ring-primary); + outline-offset: var(--border-width-regular); + } + } + } + + .notice { + padding: var(--spacing-sm) var(--spacing-md); + color: var(--color-text-info); + text-align: center; + font-style: italic; + background-color: var(--color-background-info); + + &::before { + content: "ℹ️ "; + font-style: normal; + } + } + + /* Server time fills remaining width for consistent E2E screenshot masking */ + .server-time { + flex: 1; + min-width: 0; + } + `, + template: ` +
+

Watch activity in the DevTools console!

+ +
+

Server Time: {{ serverTime() }}

+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ `, +}) +export class AppComponent implements OnInit { + private app: App | null = null; + + hostContext = signal(undefined); + serverTime = signal("Loading..."); + messageText = "This is message text."; + logText = "This is log text."; + linkUrl = "https://modelcontextprotocol.io/"; + + async ngOnInit() { + const instance = new App({ name: "Get Time App", version: "1.0.0" }); + + instance.ontoolinput = (params) => { + console.info("Received tool call input:", params); + }; + + instance.ontoolresult = (result) => { + console.info("Received tool call result:", result); + this.serverTime.set(extractTime(result)); + }; + + instance.ontoolcancelled = (params) => { + console.info("Tool call cancelled:", params.reason); + }; + + instance.onerror = console.error; + + instance.onhostcontextchanged = (params) => { + const ctx = { ...this.hostContext(), ...params }; + this.hostContext.set(ctx); + + if (ctx.theme) { + applyDocumentTheme(ctx.theme); + } + if (ctx.styles?.variables) { + applyHostStyleVariables(ctx.styles.variables); + } + if (ctx.styles?.css?.fonts) { + applyHostFonts(ctx.styles.css.fonts); + } + }; + + await instance.connect(); + this.app = instance; + + const ctx = instance.getHostContext(); + this.hostContext.set(ctx); + if (ctx?.theme) { + applyDocumentTheme(ctx.theme); + } + if (ctx?.styles?.variables) { + applyHostStyleVariables(ctx.styles.variables); + } + if (ctx?.styles?.css?.fonts) { + applyHostFonts(ctx.styles.css.fonts); + } + } + + async handleGetTime() { + if (!this.app) return; + try { + console.info("Calling get-time tool..."); + const result = await this.app.callServerTool({ name: "get-time", arguments: {} }); + console.info("get-time result:", result); + this.serverTime.set(extractTime(result)); + } catch (e) { + console.error(e); + this.serverTime.set("[ERROR]"); + } + } + + async handleSendMessage() { + if (!this.app) return; + const signal = AbortSignal.timeout(5000); + try { + console.info("Sending message text to Host:", this.messageText); + const { isError } = await this.app.sendMessage( + { role: "user", content: [{ type: "text", text: this.messageText }] }, + { signal }, + ); + console.info("Message", isError ? "rejected" : "accepted"); + } catch (e) { + console.error("Message send error:", signal.aborted ? "timed out" : e); + } + } + + async handleSendLog() { + if (!this.app) return; + console.info("Sending log text to Host:", this.logText); + await this.app.sendLog({ level: "info", data: this.logText }); + } + + async handleOpenLink() { + if (!this.app) return; + console.info("Sending open link request to Host:", this.linkUrl); + const { isError } = await this.app.openLink({ url: this.linkUrl }); + console.info("Open link request", isError ? "rejected" : "accepted"); + } +} diff --git a/examples/basic-server-angular/src/global.css b/examples/basic-server-angular/src/global.css new file mode 100644 index 000000000..801291f46 --- /dev/null +++ b/examples/basic-server-angular/src/global.css @@ -0,0 +1,92 @@ +:root { + color-scheme: light dark; + + /* + * Fallbacks for host style variables used by this app. + * The host may provide these (and many more) via the host context. + */ + --color-text-primary: light-dark(#1f2937, #f3f4f6); + --color-text-inverse: light-dark(#f3f4f6, #1f2937); + --color-text-info: light-dark(#1d4ed8, #60a5fa); + --color-background-primary: light-dark(#ffffff, #1a1a1a); + --color-background-inverse: light-dark(#1a1a1a, #ffffff); + --color-background-info: light-dark(#eff6ff, #1e3a5f); + --color-ring-primary: light-dark(#3b82f6, #60a5fa); + --border-radius-md: 6px; + --border-width-regular: 1px; + --font-sans: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; + --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; + --font-weight-normal: 400; + --font-weight-bold: 700; + --font-text-md-size: 1rem; + --font-text-md-line-height: 1.5; + --font-heading-3xl-size: 2.25rem; + --font-heading-3xl-line-height: 1.1; + --font-heading-2xl-size: 1.875rem; + --font-heading-2xl-line-height: 1.2; + --font-heading-xl-size: 1.5rem; + --font-heading-xl-line-height: 1.25; + --font-heading-lg-size: 1.25rem; + --font-heading-lg-line-height: 1.3; + --font-heading-md-size: 1rem; + --font-heading-md-line-height: 1.4; + --font-heading-sm-size: 0.875rem; + --font-heading-sm-line-height: 1.4; + + /* Spacing derived from host typography */ + --spacing-unit: var(--font-text-md-size); + --spacing-xs: calc(var(--spacing-unit) * 0.25); + --spacing-sm: calc(var(--spacing-unit) * 0.5); + --spacing-md: var(--spacing-unit); + --spacing-lg: calc(var(--spacing-unit) * 1.5); + + /* App accent color (customize for your brand) */ + --color-accent: #2563eb; + --color-text-on-accent: #ffffff; +} + +* { + box-sizing: border-box; +} + +html, body { + font-family: var(--font-sans); + font-size: var(--font-text-md-size); + font-weight: var(--font-weight-normal); + line-height: var(--font-text-md-line-height); + color: var(--color-text-primary); +} + +h1 { + font-size: var(--font-heading-3xl-size); + line-height: var(--font-heading-3xl-line-height); +} +h2 { + font-size: var(--font-heading-2xl-size); + line-height: var(--font-heading-2xl-line-height); +} +h3 { + font-size: var(--font-heading-xl-size); + line-height: var(--font-heading-xl-line-height); +} +h4 { + font-size: var(--font-heading-lg-size); + line-height: var(--font-heading-lg-line-height); +} +h5 { + font-size: var(--font-heading-md-size); + line-height: var(--font-heading-md-line-height); +} +h6 { + font-size: var(--font-heading-sm-size); + line-height: var(--font-heading-sm-line-height); +} + +code, pre, kbd { + font-family: var(--font-mono); + font-size: 1em; +} + +b, strong { + font-weight: var(--font-weight-bold); +} diff --git a/examples/basic-server-angular/src/greeting-main.ts b/examples/basic-server-angular/src/greeting-main.ts new file mode 100644 index 000000000..748ebba37 --- /dev/null +++ b/examples/basic-server-angular/src/greeting-main.ts @@ -0,0 +1,9 @@ +import "@angular/compiler"; +import { bootstrapApplication } from "@angular/platform-browser"; +import { provideZonelessChangeDetection } from "@angular/core"; +import { GreetingComponent } from "./greeting.component"; +import "./global.css"; + +bootstrapApplication(GreetingComponent, { + providers: [provideZonelessChangeDetection()], +}).catch((err) => console.error(err)); diff --git a/examples/basic-server-angular/src/greeting.component.ts b/examples/basic-server-angular/src/greeting.component.ts new file mode 100644 index 000000000..f040231be --- /dev/null +++ b/examples/basic-server-angular/src/greeting.component.ts @@ -0,0 +1,180 @@ +import { Component, type OnInit, signal } from "@angular/core"; +import { FormsModule } from "@angular/forms"; +import { + App, + applyDocumentTheme, + applyHostFonts, + applyHostStyleVariables, + type McpUiHostContext, +} from "@modelcontextprotocol/ext-apps"; +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; + +function extractGreeting(result: CallToolResult): string { + const { text } = result.content?.find((c) => c.type === "text")!; + return text; +} + +@Component({ + selector: "greeting-root", + imports: [FormsModule], + styles: ` + .main { + width: 100%; + max-width: 425px; + box-sizing: border-box; + + > * { + margin-top: 0; + margin-bottom: 0; + } + + > * + * { + margin-top: var(--spacing-lg); + } + } + + .action { + > * { + margin-top: 0; + margin-bottom: 0; + width: 100%; + } + + > * + * { + margin-top: var(--spacing-sm); + } + + input { + display: block; + font-family: inherit; + font-size: inherit; + padding: var(--spacing-sm); + border: var(--border-width-regular) solid color-mix(in srgb, var(--color-text-primary) 30%, transparent); + border-radius: var(--border-radius-md); + background: var(--color-background-primary); + color: var(--color-text-primary); + } + + button { + padding: var(--spacing-sm) var(--spacing-md); + border: none; + border-radius: var(--border-radius-md); + color: var(--color-text-on-accent); + font-weight: var(--font-weight-bold); + background-color: var(--color-accent); + cursor: pointer; + + &:hover { + background-color: color-mix(in srgb, var(--color-accent) 85%, var(--color-background-inverse)); + } + + &:focus-visible { + outline: calc(var(--border-width-regular) * 2) solid var(--color-ring-primary); + outline-offset: var(--border-width-regular); + } + } + } + + .greeting-display { + padding: var(--spacing-md); + border-radius: var(--border-radius-md); + background-color: var(--color-background-info); + color: var(--color-text-info); + text-align: center; + font-size: var(--font-heading-lg-size); + line-height: var(--font-heading-lg-line-height); + } + `, + template: ` +
+
+ + + +
+ + @if (greeting()) { +
{{ greeting() }}
+ } +
+ `, +}) +export class GreetingComponent implements OnInit { + private app: App | null = null; + + hostContext = signal(undefined); + greeting = signal(""); + nameText = ""; + + async ngOnInit() { + const instance = new App({ name: "Greeting App", version: "1.0.0" }); + + instance.ontoolinput = (params) => { + console.info("Received tool call input:", params); + }; + + instance.ontoolresult = (result) => { + console.info("Received tool call result:", result); + this.greeting.set(extractGreeting(result)); + }; + + instance.ontoolcancelled = (params) => { + console.info("Tool call cancelled:", params.reason); + }; + + instance.onerror = console.error; + + instance.onhostcontextchanged = (params) => { + const ctx = { ...this.hostContext(), ...params }; + this.hostContext.set(ctx); + + if (ctx.theme) { + applyDocumentTheme(ctx.theme); + } + if (ctx.styles?.variables) { + applyHostStyleVariables(ctx.styles.variables); + } + if (ctx.styles?.css?.fonts) { + applyHostFonts(ctx.styles.css.fonts); + } + }; + + await instance.connect(); + this.app = instance; + + const ctx = instance.getHostContext(); + this.hostContext.set(ctx); + if (ctx?.theme) { + applyDocumentTheme(ctx.theme); + } + if (ctx?.styles?.variables) { + applyHostStyleVariables(ctx.styles.variables); + } + if (ctx?.styles?.css?.fonts) { + applyHostFonts(ctx.styles.css.fonts); + } + } + + async handleGreet() { + if (!this.app) return; + try { + const name = this.nameText.trim() || "World"; + console.info("Calling greet tool with name:", name); + const result = await this.app.callServerTool({ + name: "greet", + arguments: { name }, + }); + console.info("greet result:", result); + this.greeting.set(extractGreeting(result)); + } catch (e) { + console.error(e); + this.greeting.set("[ERROR]"); + } + } +} diff --git a/examples/basic-server-angular/src/main.ts b/examples/basic-server-angular/src/main.ts new file mode 100644 index 000000000..33ee1fa7e --- /dev/null +++ b/examples/basic-server-angular/src/main.ts @@ -0,0 +1,9 @@ +import "@angular/compiler"; +import { bootstrapApplication } from "@angular/platform-browser"; +import { provideZonelessChangeDetection } from "@angular/core"; +import { AppComponent } from "./app.component"; +import "./global.css"; + +bootstrapApplication(AppComponent, { + providers: [provideZonelessChangeDetection()], +}).catch((err) => console.error(err)); diff --git a/examples/basic-server-angular/tsconfig.json b/examples/basic-server-angular/tsconfig.json new file mode 100644 index 000000000..63e4773e6 --- /dev/null +++ b/examples/basic-server-angular/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ESNext", + "lib": ["ESNext", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "verbatimModuleSyntax": true, + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "experimentalDecorators": true, + "useDefineForClassFields": false + }, + "include": ["src", "server.ts", "*.d.ts"] +} diff --git a/examples/basic-server-angular/tsconfig.server.json b/examples/basic-server-angular/tsconfig.server.json new file mode 100644 index 000000000..05ddd8ec4 --- /dev/null +++ b/examples/basic-server-angular/tsconfig.server.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "./dist", + "rootDir": ".", + "strict": true, + "skipLibCheck": true, + "esModuleInterop": true, + "resolveJsonModule": true + }, + "include": ["server.ts"] +} diff --git a/examples/basic-server-angular/vite.config.ts b/examples/basic-server-angular/vite.config.ts new file mode 100644 index 000000000..93d261e81 --- /dev/null +++ b/examples/basic-server-angular/vite.config.ts @@ -0,0 +1,32 @@ +import { defineConfig } from "vite"; +import { viteSingleFile } from "vite-plugin-singlefile"; + +const INPUT = process.env.INPUT; +if (!INPUT) { + throw new Error("INPUT environment variable is not set"); +} + +const isDevelopment = process.env.NODE_ENV === "development"; + +export default defineConfig({ + plugins: [viteSingleFile()], + esbuild: { + // Enable decorator metadata for Angular + tsconfigRaw: { + compilerOptions: { + experimentalDecorators: true, + }, + }, + }, + build: { + sourcemap: isDevelopment ? "inline" : undefined, + cssMinify: !isDevelopment, + minify: !isDevelopment, + + rollupOptions: { + input: INPUT, + }, + outDir: "dist", + emptyOutDir: false, + }, +}); diff --git a/package-lock.json b/package-lock.json index c0c0c47d9..cd6143a9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,6 +107,148 @@ "dev": true, "license": "MIT" }, + "examples/basic-server-angular": { + "name": "@modelcontextprotocol/server-basic-angular", + "version": "1.7.0", + "license": "MIT", + "dependencies": { + "@angular/common": "^21.0.0", + "@angular/compiler": "^21.0.0", + "@angular/core": "^21.0.0", + "@angular/forms": "^21.0.0", + "@angular/platform-browser": "^21.0.0", + "@angular/platform-browser-dynamic": "^21.0.0", + "@modelcontextprotocol/ext-apps": "^1.0.0", + "@modelcontextprotocol/sdk": "^1.29.0", + "cors": "^2.8.5", + "express": "^5.1.0", + "rxjs": "^7.8.0", + "zod": "^4.1.13" + }, + "bin": { + "mcp-server-basic-angular": "dist/index.js" + }, + "devDependencies": { + "@types/cors": "^2.8.19", + "@types/express": "^5.0.0", + "@types/node": "22.10.0", + "concurrently": "^9.2.1", + "cross-env": "^10.1.0", + "typescript": "^5.9.3", + "vite": "^6.0.0", + "vite-plugin-singlefile": "^2.3.0" + } + }, + "examples/basic-server-angular/node_modules/@angular/common": { + "version": "20.3.19", + "resolved": "https://registry.npmjs.org/@angular/common/-/common-20.3.19.tgz", + "integrity": "sha512-hcB1eUEN8LGcKGc4DlRJ+abS6AYfbEHDZKg8LnXNugkbwI6Ebyh2AUYTDhzZL2S4aH+C8biHKgSYHFCqieCRhA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/core": "20.3.19", + "rxjs": "^6.5.3 || ^7.4.0" + } + }, + "examples/basic-server-angular/node_modules/@angular/compiler": { + "version": "20.3.19", + "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-20.3.19.tgz", + "integrity": "sha512-ETkgDKm0l2PuaBubgPJe0ccy8kE75DFu6/zKcz7TUuk3KrKF2OZAopbbjftsUSZGeCNvCdqHzjmcL6hQ6oAOwA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "examples/basic-server-angular/node_modules/@angular/core": { + "version": "20.3.19", + "resolved": "https://registry.npmjs.org/@angular/core/-/core-20.3.19.tgz", + "integrity": "sha512-SYnwW+q51bQoPtGFoGovm1P5GK9fMEXsG0lGaEAUapjskblAYyX7hLlM/jgueSojv2SjhqNF8aXR+gjHLhZVNA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/compiler": "20.3.19", + "rxjs": "^6.5.3 || ^7.4.0", + "zone.js": "~0.15.0" + }, + "peerDependenciesMeta": { + "@angular/compiler": { + "optional": true + }, + "zone.js": { + "optional": true + } + } + }, + "examples/basic-server-angular/node_modules/@angular/forms": { + "version": "20.3.19", + "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-20.3.19.tgz", + "integrity": "sha512-WJotd+Lhl4FG2b0K+aQNyQDHhR515zKCuphjiUqEW7sifWrOQxANLKzPBngGrH75ayANFgPaDf7U3ZRIoblcQA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/common": "20.3.19", + "@angular/core": "20.3.19", + "@angular/platform-browser": "20.3.19", + "rxjs": "^6.5.3 || ^7.4.0" + } + }, + "examples/basic-server-angular/node_modules/@angular/platform-browser": { + "version": "20.3.19", + "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-20.3.19.tgz", + "integrity": "sha512-TRZfatH1B/kreDwFRwtpLEurJQ6044qh6DWpvxzTbugaG5otLQJKTk+1z81/KsJwQqc1+24v+yuywc1LM7aq7w==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/animations": "20.3.19", + "@angular/common": "20.3.19", + "@angular/core": "20.3.19" + }, + "peerDependenciesMeta": { + "@angular/animations": { + "optional": true + } + } + }, + "examples/basic-server-angular/node_modules/@types/node": { + "version": "22.10.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.0.tgz", + "integrity": "sha512-XC70cRZVElFHfIUB40FgZOBbgJYFKKMa5nb9lxcwYstFG/Mi+/Y0bGS+rs6Dmhmkpq4pnNiLiuZAbc02YCOnmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } + }, + "examples/basic-server-angular/node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + }, "examples/basic-server-preact": { "name": "@modelcontextprotocol/server-basic-preact", "version": "1.7.0", @@ -1107,6 +1249,103 @@ "dev": true, "license": "MIT" }, + "node_modules/@angular/common": { + "version": "21.2.9", + "resolved": "https://registry.npmjs.org/@angular/common/-/common-21.2.9.tgz", + "integrity": "sha512-7spQcF3hPN/fjTx6Pwa32KRRdO0NcixnRuPV4lo50ejtXesjiLVR+fkaX38sawAyGoq89IuuYvUDrbLwCMypmQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/core": "21.2.9", + "rxjs": "^6.5.3 || ^7.4.0" + } + }, + "node_modules/@angular/compiler": { + "version": "21.2.9", + "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-21.2.9.tgz", + "integrity": "sha512-clsK1EsSPtAuqlRl4CciA/gsvsW7xe0eWcvHxtrMW6DYaUJ6X4AAuDxEEJ5cf/3Mpw4s8KssjIUPPtbrUIGLSQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@angular/core": { + "version": "21.2.9", + "resolved": "https://registry.npmjs.org/@angular/core/-/core-21.2.9.tgz", + "integrity": "sha512-uZLq2aedJ+0uEZxyf6a1Nc7y1aZ7akAW7K1Kon8JUDZOvI2IDbk0i00MzkELt8q9uSmSSqg9zNKuhjspFf0Pyw==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/compiler": "21.2.9", + "rxjs": "^6.5.3 || ^7.4.0", + "zone.js": "~0.15.0 || ~0.16.0" + }, + "peerDependenciesMeta": { + "@angular/compiler": { + "optional": true + }, + "zone.js": { + "optional": true + } + } + }, + "node_modules/@angular/platform-browser": { + "version": "21.2.9", + "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-21.2.9.tgz", + "integrity": "sha512-MjEtFvoFtsjsAeu2yzauqGgwwEHV4ml25c9vGFmw4OmSoNme4yp41f2DegwOkn1TTHL3OF3GE65ng2U2feJU4Q==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/animations": "21.2.9", + "@angular/common": "21.2.9", + "@angular/core": "21.2.9" + }, + "peerDependenciesMeta": { + "@angular/animations": { + "optional": true + } + } + }, + "node_modules/@angular/platform-browser-dynamic": { + "version": "21.2.9", + "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-21.2.9.tgz", + "integrity": "sha512-Z+2vefW4GUSuTC4BOKNiyftqecLSjxOKwe1ZNljBsjesLzywIXi+v+tyEm8ODHHlf7bz/0HwXvc9OYZmfjt95A==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/common": "21.2.9", + "@angular/compiler": "21.2.9", + "@angular/core": "21.2.9", + "@angular/platform-browser": "21.2.9" + } + }, "node_modules/@babel/code-frame": { "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz", @@ -2637,6 +2876,10 @@ } } }, + "node_modules/@modelcontextprotocol/server-basic-angular": { + "resolved": "examples/basic-server-angular", + "link": true + }, "node_modules/@modelcontextprotocol/server-basic-preact": { "resolved": "examples/basic-server-preact", "link": true @@ -3188,6 +3431,354 @@ "win32" ] }, + "node_modules/@parcel/watcher": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", + "integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "detect-libc": "^2.0.3", + "is-glob": "^4.0.3", + "node-addon-api": "^7.0.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.5.6", + "@parcel/watcher-darwin-arm64": "2.5.6", + "@parcel/watcher-darwin-x64": "2.5.6", + "@parcel/watcher-freebsd-x64": "2.5.6", + "@parcel/watcher-linux-arm-glibc": "2.5.6", + "@parcel/watcher-linux-arm-musl": "2.5.6", + "@parcel/watcher-linux-arm64-glibc": "2.5.6", + "@parcel/watcher-linux-arm64-musl": "2.5.6", + "@parcel/watcher-linux-x64-glibc": "2.5.6", + "@parcel/watcher-linux-x64-musl": "2.5.6", + "@parcel/watcher-win32-arm64": "2.5.6", + "@parcel/watcher-win32-ia32": "2.5.6", + "@parcel/watcher-win32-x64": "2.5.6" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.6.tgz", + "integrity": "sha512-YQxSS34tPF/6ZG7r/Ih9xy+kP/WwediEUsqmtf0cuCV5TPPKw/PQHRhueUo6JdeFJaqV3pyjm0GdYjZotbRt/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.6.tgz", + "integrity": "sha512-Z2ZdrnwyXvvvdtRHLmM4knydIdU9adO3D4n/0cVipF3rRiwP+3/sfzpAwA/qKFL6i1ModaabkU7IbpeMBgiVEA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.6.tgz", + "integrity": "sha512-HgvOf3W9dhithcwOWX9uDZyn1lW9R+7tPZ4sug+NGrGIo4Rk1hAXLEbcH1TQSqxts0NYXXlOWqVpvS1SFS4fRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.6.tgz", + "integrity": "sha512-vJVi8yd/qzJxEKHkeemh7w3YAn6RJCtYlE4HPMoVnCpIXEzSrxErBW5SJBgKLbXU3WdIpkjBTeUNtyBVn8TRng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.6.tgz", + "integrity": "sha512-9JiYfB6h6BgV50CCfasfLf/uvOcJskMSwcdH1PHH9rvS1IrNy8zad6IUVPVUfmXr+u+Km9IxcfMLzgdOudz9EQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.6.tgz", + "integrity": "sha512-Ve3gUCG57nuUUSyjBq/MAM0CzArtuIOxsBdQ+ftz6ho8n7s1i9E1Nmk/xmP323r2YL0SONs1EuwqBp2u1k5fxg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.6.tgz", + "integrity": "sha512-f2g/DT3NhGPdBmMWYoxixqYr3v/UXcmLOYy16Bx0TM20Tchduwr4EaCbmxh1321TABqPGDpS8D/ggOTaljijOA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.6.tgz", + "integrity": "sha512-qb6naMDGlbCwdhLj6hgoVKJl2odL34z2sqkC7Z6kzir8b5W65WYDpLB6R06KabvZdgoHI/zxke4b3zR0wAbDTA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.6.tgz", + "integrity": "sha512-kbT5wvNQlx7NaGjzPFu8nVIW1rWqV780O7ZtkjuWaPUgpv2NMFpjYERVi0UYj1msZNyCzGlaCWEtzc+exjMGbQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.6.tgz", + "integrity": "sha512-1JRFeC+h7RdXwldHzTsmdtYR/Ku8SylLgTU/reMuqdVD7CtLwf0VR1FqeprZ0eHQkO0vqsbvFLXUmYm/uNKJBg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.6.tgz", + "integrity": "sha512-3ukyebjc6eGlw9yRt678DxVF7rjXatWiHvTXqphZLvo7aC5NdEgFufVwjFfY51ijYEWpXbqF5jtrK275z52D4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.6.tgz", + "integrity": "sha512-k35yLp1ZMwwee3Ez/pxBi5cf4AoBKYXj00CZ80jUz5h8prpiaQsiRPKQMxoLstNuqe2vR4RNPEAEcjEFzhEz/g==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.6.tgz", + "integrity": "sha512-hbQlYcCq5dlAX9Qx+kFb0FHue6vbjlf0FrNzSKdYK2APUf7tGfGxQCk2ihEREmbR6ZMc0MVAD5RIX/41gpUzTw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher/node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true + }, + "node_modules/@parcel/watcher/node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@pdf-lib/standard-fonts": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz", @@ -6431,6 +7022,15 @@ "dev": true, "license": "ISC" }, + "node_modules/immutable": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.5.tgz", + "integrity": "sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true + }, "node_modules/indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", @@ -7783,7 +8383,6 @@ "version": "7.8.2", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", - "dev": true, "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" @@ -7795,6 +8394,63 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, + "node_modules/sass": { + "version": "1.90.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.90.0.tgz", + "integrity": "sha512-9GUyuksjw70uNpb1MTYWsH9MQHOHY6kwfnkafC24+7aOMZn9+rVMBxRbLvw756mrBFbIsFg6Xw9IkR2Fnn3k+Q==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "chokidar": "^4.0.0", + "immutable": "^5.0.2", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + }, + "optionalDependencies": { + "@parcel/watcher": "^2.4.1" + } + }, + "node_modules/sass/node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/sass/node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", @@ -8751,7 +9407,6 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, "license": "0BSD" }, "node_modules/tsutils": { @@ -9986,6 +10641,14 @@ "peerDependencies": { "zod": "^3.25 || ^4" } + }, + "node_modules/zone.js": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.15.1.tgz", + "integrity": "sha512-XE96n56IQpJM7NAoXswY3XRLcWFW83xe0BiAOeMD7K5k5xecOeul3Qcpx6GqEeeHNkW5DWL5zOyTbEfB4eti8w==", + "license": "MIT", + "optional": true, + "peer": true } } } diff --git a/tests/e2e/servers.spec.ts b/tests/e2e/servers.spec.ts index a3c30d8a8..bd7f774ac 100644 --- a/tests/e2e/servers.spec.ts +++ b/tests/e2e/servers.spec.ts @@ -8,6 +8,7 @@ import { test, expect, type Page, type ConsoleMessage } from "@playwright/test"; // Note: map-server uses SLOW_SERVERS timeout instead of masking to wait for tiles const DYNAMIC_MASKS: Record = { integration: ['[class*="serverTime"]'], // Server time display [CSS module] + "basic-angular": [".server-time"], // Server time display (component-scoped) "basic-preact": ['[class*="serverTime"]'], // Server time display [CSS module] "basic-react": ['[class*="serverTime"]'], // Server time display [CSS module] "basic-solid": ['[class*="serverTime"]'], // Server time display [CSS module] @@ -45,6 +46,7 @@ const HOST_MASKS: Record = { // Servers with dynamic timestamps in Tool Result (get-time response) // Mask entire collapsible panels to avoid font rendering differences integration: ['[class*="collapsiblePanel"]'], + "basic-angular": ['[class*="collapsiblePanel"]'], "basic-preact": ['[class*="collapsiblePanel"]'], "basic-react": ['[class*="collapsiblePanel"]'], "basic-solid": ['[class*="collapsiblePanel"]'], @@ -71,6 +73,11 @@ const ALL_SERVERS = [ name: "Integration Test Server", dir: "integration-server", }, + { + key: "basic-angular", + name: "Basic MCP App Server (Angular)", + dir: "basic-server-angular", + }, { key: "basic-preact", name: "Basic MCP App Server (Preact)", diff --git a/tests/e2e/servers.spec.ts-snapshots/basic-angular.png b/tests/e2e/servers.spec.ts-snapshots/basic-angular.png new file mode 100644 index 000000000..6c603c2cc Binary files /dev/null and b/tests/e2e/servers.spec.ts-snapshots/basic-angular.png differ