MCPcopy Create free account
hub / github.com/anus-dev/ANUS / transformResourceBlock

Function transformResourceBlock

packages/core/src/tools/mcp-tool.ts:236–259  ·  view source on GitHub ↗
(
  block: McpResourceBlock,
  toolName: string,
)

Source from the content-addressed store, hash-verified

234}
235
236function transformResourceBlock(
237 block: McpResourceBlock,
238 toolName: string,
239): Part | Part[] | null {
240 const resource = block.resource;
241 if (resource?.text) {
242 return { text: resource.text };
243 }
244 if (resource?.blob) {
245 const mimeType = resource.mimeType || 'application/octet-stream';
246 return [
247 {
248 text: `[Tool '${toolName}' provided the following embedded resource with mime-type: ${mimeType}]`,
249 },
250 {
251 inlineData: {
252 mimeType,
253 data: resource.blob,
254 },
255 },
256 ];
257 }
258 return null;
259}
260
261function transformResourceLinkBlock(block: McpResourceLinkBlock): Part {
262 return {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected