Skip to content

Commit 87fee34

Browse files
fix: re-export EXTENSION_ID/getUiCapability; getHostContext() undefined pre-connect (v1 parity)
1 parent 953a5d8 commit 87fee34

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class App extends EventDispatcher<AppEventMap> {
172172
/** SEP-2133 extension handle for `ui/*` methods. */
173173
readonly ui: ExtensionHandle<McpUiAppCapabilities, McpUiHostCapabilities, ClientContext>;
174174

175-
private _hostContext: McpUiHostContext = {};
175+
private _hostContext?: McpUiHostContext;
176176
private _hostInfo?: Implementation;
177177
private _resizeObserver?: ResizeObserver;
178178

src/server/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getUiCapability,
88
EXTENSION_ID,
99
} from "./index";
10-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10+
import type { McpServer } from "@modelcontextprotocol/server";
1111

1212
describe("registerAppTool", () => {
1313
it("should pass through config to server.registerTool", () => {
@@ -31,7 +31,7 @@ describe("registerAppTool", () => {
3131
});
3232

3333
registerAppTool(
34-
mockServer as unknown as Pick<McpServer, "registerTool">,
34+
mockServer as unknown as McpServer,
3535
"my-tool",
3636
{
3737
title: "My Tool",
@@ -72,7 +72,7 @@ describe("registerAppTool", () => {
7272
};
7373

7474
registerAppTool(
75-
mockServer as unknown as Pick<McpServer, "registerTool">,
75+
mockServer as unknown as McpServer,
7676
"my-tool",
7777
{
7878
_meta: {
@@ -107,7 +107,7 @@ describe("registerAppTool", () => {
107107
};
108108

109109
registerAppTool(
110-
mockServer as unknown as Pick<McpServer, "registerTool">,
110+
mockServer as unknown as McpServer,
111111
"my-tool",
112112
{
113113
_meta: {
@@ -142,7 +142,7 @@ describe("registerAppTool", () => {
142142
};
143143

144144
registerAppTool(
145-
mockServer as unknown as Pick<McpServer, "registerTool">,
145+
mockServer as unknown as McpServer,
146146
"my-tool",
147147
{
148148
_meta: {
@@ -176,7 +176,7 @@ describe("registerAppTool", () => {
176176
};
177177

178178
registerAppTool(
179-
mockServer as unknown as Pick<McpServer, "registerTool">,
179+
mockServer as unknown as McpServer,
180180
"my-tool",
181181
{
182182
_meta: {

src/server/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,18 @@ export function clientSupportsMcpApps(
196196
}
197197

198198
export type { McpUiResourceCsp, McpUiResourceMeta, McpUiToolMeta };
199+
200+
/** SEP-2133 extension identifier for MCP Apps. Same value as MCP_APPS_EXTENSION_ID. */
201+
export const EXTENSION_ID = "io.modelcontextprotocol/ui";
202+
203+
/**
204+
* Returns the MCP Apps capability blob from ClientCapabilities.extensions, or
205+
* undefined if the client does not declare MCP Apps support.
206+
*/
207+
export function getUiCapability(
208+
clientCapabilities: ClientCapabilities | undefined | null,
209+
): McpUiClientCapabilities | undefined {
210+
return clientCapabilities?.extensions?.[EXTENSION_ID] as
211+
| McpUiClientCapabilities
212+
| undefined;
213+
}

0 commit comments

Comments
 (0)