* Coalesce an arbitrary bridge result into the `string` required by the * `CallToolResult` text content block. `JSON.stringify` is typed to return * `string` but actually returns `undefined` for inputs like `undefined` or a * function, so we narrow explicitly to avoid `text: undefined`.
(result: unknown)
| 29 | * function, so we narrow explicitly to avoid `text: undefined`. |
| 30 | */ |
| 31 | function resultToText(result: unknown): string { |
| 32 | if (typeof result === 'string') return result |
| 33 | // `JSON.stringify`'s lib signature claims `string`, but it returns |
| 34 | // `undefined` for `undefined`/function inputs; type the call honestly. |
| 35 | const stringify: (value: unknown) => string | undefined = JSON.stringify |
| 36 | return stringify(result) ?? 'null' |
| 37 | } |
| 38 | |
| 39 | export function MCPAppResource(props: MCPAppResourceProps): JSX.Element { |
| 40 | const { bridge } = props |