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

Function mcpResourceToContentPart

packages/ai-mcp/src/resources.ts:10–23  ·  view source on GitHub ↗
(content: {
  uri?: string
  text?: string
  blob?: string
  [key: string]: unknown
})

Source from the content-addressed store, hash-verified

8 * - otherwise → `{ type: 'text', content: JSON.stringify(content) }`
9 */
10export function mcpResourceToContentPart(content: {
11 uri?: string
12 text?: string
13 blob?: string
14 [key: string]: unknown
15}): ContentPart {
16 if (typeof content.text === 'string') {
17 return { type: 'text', content: content.text }
18 }
19 if (typeof content.blob === 'string') {
20 return { type: 'text', content: `[binary resource ${content.uri ?? ''}]` }
21 }
22 return { type: 'text', content: JSON.stringify(content) }
23}

Callers 2

resources.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected