Merge branch 'main' into ochafik/simple-host-example
This commit is contained in:
commit
85816d80ce
2 changed files with 88 additions and 44 deletions
|
|
@ -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]);
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue