MCPcopy Create free account
hub / github.com/TanStack/ai / MCPAppResource

Function MCPAppResource

packages/ai-react/src/mcp-app-resource.tsx:39–88  ·  view source on GitHub ↗
(props: MCPAppResourceProps)

Source from the content-addressed store, hash-verified

37}
38
39export function MCPAppResource(props: MCPAppResourceProps): JSX.Element {
40 const { bridge } = props
41 return (
42 <AppRenderer
43 toolName={props.part.toolName}
44 sandbox={props.sandbox}
45 html={props.part.resource.text}
46 toolResourceUri={props.part.resource.uri}
47 toolInput={props.toolInput}
48 onCallTool={
49 bridge
50 ? async ({ name, arguments: args }) => {
51 const result = await bridge.callTool({
52 serverId: props.part.serverId,
53 toolName: name,
54 args,
55 })
56 const structuredContent = isRecord(result) ? result : undefined
57 return {
58 content: [
59 {
60 type: 'text' as const,
61 text: resultToText(result),
62 },
63 ],
64 structuredContent,
65 }
66 }
67 : undefined
68 }
69 onMessage={
70 bridge
71 ? async ({ content }) => {
72 const text = content
73 .filter(
74 (c): c is { type: 'text'; text: string } => c.type === 'text',
75 )
76 .map((c) => c.text)
77 .join('')
78 if (text) await bridge.sendPrompt(text)
79 return {}
80 }
81 : undefined
82 }
83 onOpenLink={
84 bridge ? ({ url }) => Promise.resolve(bridge.openLink(url)) : undefined
85 }
86 />
87 )
88}

Callers

nothing calls this directly

Calls 4

callToolMethod · 0.80
resolveMethod · 0.80
isRecordFunction · 0.70
resultToTextFunction · 0.70

Tested by

no test coverage detected