Skip to content

Commit 6166bf5

Browse files
committed
improve instructions
1 parent ca95b15 commit 6166bf5

File tree

1 file changed

+7
-1
lines changed
  • exercises/05.advanced/02.problem.render-data/app/utils

1 file changed

+7
-1
lines changed

exercises/05.advanced/02.problem.render-data/app/utils/mcp.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,10 @@ function sendMcpMessage(
9696

9797
export { sendMcpMessage }
9898

99-
// ‼️ review this: https://github.com/idosal/mcp-ui/issues/106
99+
// 🐨 export a waitForRenderData function that works like sendMcpMessage, but for render data
100+
// 🐨 it should create a messageId and send it to the parent frame with the type 'ui-request-render-data'
101+
// 🐨 handleMessage should check the event.data.type is 'ui-message-response' and the messageId is the same as the one sent
102+
// 🐨 if the event.data.payload.error is present, return reject(error)
103+
// 🐨 if the event.data.payload.response is present, return resolve(response)
104+
// 💯 add schema as an optional parameter and parse the response if it is present
105+
// 🦺 if you'd like to make it more typesafe, make waitForRenderData a generic (withForRenderData<RenderData>), pass the generic type to the schema (z.ZodSchema<RenderData>) and set it as the return type (Promise<RenderData>)

0 commit comments

Comments
 (0)