Merge branch 'main' into ochafik/simple-host-example

This commit is contained in:
Olivier Chafik 2025-11-24 16:01:24 +00:00
commit 85816d80ce
No known key found for this signature in database
2 changed files with 88 additions and 44 deletions

View file

@ -26,19 +26,9 @@ export function McpClientApp() {
appInfo: APP_INFO,
capabilities: {},
onAppCreated: (app) => {
app.setNotificationHandler(
McpUiToolResultNotificationSchema,
async (notification) => {
setToolResults((prev) => [...prev, notification.params]);
},
);
app.setNotificationHandler(
McpUiSizeChangeNotificationSchema,
async (notification) => {
document.body.style.width = `${notification.params.width}px`;
document.body.style.height = `${notification.params.height}px`;
},
);
app.ontoolresult = async (params) => {
setToolResults((prev) => [...prev, params]);
};
},
});

View file

@ -36,28 +36,17 @@ window.addEventListener("load", async () => {
version: "1.0.0",
});
app.setNotificationHandler(
McpUiToolInputNotificationSchema,
async ({ params }) => {
appendText(
`Tool call input received: ${JSON.stringify(params.arguments)}`,
);
},
);
app.setNotificationHandler(
McpUiToolResultNotificationSchema,
async ({ params: { content, structuredContent, isError } }) => {
appendText(
`Tool call result received: isError=${isError}, content=${content}, structuredContent=${JSON.stringify(structuredContent)}`,
);
},
);
app.setNotificationHandler(
McpUiHostContextChangedNotificationSchema,
async (params) => {
appendText(`Host context changed: ${JSON.stringify(params)}`);
},
);
app.ontoolinput = (params) => {
appendText(`Tool call input received: ${JSON.stringify(params.arguments)}`);
};
app.ontoolresult = ({ content, structuredContent, isError }) => {
appendText(
`Tool call result received: isError=${isError}, content=${content}, structuredContent=${JSON.stringify(structuredContent)}`,
);
};
app.onhostcontextchanged = (params) => {
appendText(`Host context changed: ${JSON.stringify(params)}`);
};
document.body.addEventListener("resize", () => {
app.sendSizeChange({