diff --git a/examples/basic-host/src/index.tsx b/examples/basic-host/src/index.tsx
index 00c0d52b2..78621860b 100644
--- a/examples/basic-host/src/index.tsx
+++ b/examples/basic-host/src/index.tsx
@@ -4,6 +4,7 @@ import { Component, type ErrorInfo, type ReactNode, StrictMode, Suspense, use, u
import { createRoot } from "react-dom/client";
import { callTool, connectToServer, hasAppHtml, initializeApp, loadSandboxProxy, log, newAppBridge, type ServerInfo, type ToolCallInfo, type ModelContext, type AppMessage } from "./implementation";
import { getTheme, toggleTheme, onThemeChange, type Theme } from "./theme";
+import { getToolDisplayName } from "./tool-display-name";
import styles from "./index.module.css";
/**
@@ -341,7 +342,7 @@ function ToolCallInfoPanel({ toolCallInfo, isDestroying, onRequestClose, onClose
>
{/* Row 1: Header with server:tool name and close button */}
- {toolCallInfo.serverInfo.name}:{toolCallInfo.tool.name}
+ {toolCallInfo.serverInfo.name}:{getToolDisplayName(toolCallInfo.tool)}
{onRequestClose && !isDestroying && (
+
+import { describe, expect, test } from "bun:test";
+import type { Tool } from "@modelcontextprotocol/client";
+import { getToolDisplayName } from "./tool-display-name";
+
+const tool = (overrides: Partial = {}): Tool => ({
+ name: "list_design_systems",
+ inputSchema: { type: "object" },
+ ...overrides,
+});
+
+describe("getToolDisplayName", () => {
+ test("prefers title over annotations.title and name", () => {
+ expect(getToolDisplayName(tool({
+ title: "Listing design systems",
+ annotations: { title: "Annotated title" },
+ }))).toBe("Listing design systems");
+ });
+
+ test("falls back to annotations.title", () => {
+ expect(getToolDisplayName(tool({
+ annotations: { title: "Annotated title" },
+ }))).toBe("Annotated title");
+ });
+
+ test("falls back to name", () => {
+ expect(getToolDisplayName(tool())).toBe("list_design_systems");
+ });
+});
diff --git a/examples/basic-host/src/tool-display-name.ts b/examples/basic-host/src/tool-display-name.ts
new file mode 100644
index 000000000..19e0727c1
--- /dev/null
+++ b/examples/basic-host/src/tool-display-name.ts
@@ -0,0 +1,5 @@
+import type { Tool } from "@modelcontextprotocol/client";
+
+export function getToolDisplayName(tool: Tool): string {
+ return tool.title ?? tool.annotations?.title ?? tool.name;
+}