MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / extractResourceText

Function extractResourceText

src/snapshot-tests/resource-harness.ts:51–72  ·  view source on GitHub ↗
(result: unknown)

Source from the content-addressed store, hash-verified

49}
50
51function extractResourceText(result: unknown): string {
52 const contents = (result as { contents?: unknown }).contents;
53 if (!Array.isArray(contents)) {
54 throw new Error('MCP resource snapshot result did not include a contents array.');
55 }
56
57 const contentBlocks: string[] = [];
58 for (const entry of contents) {
59 if (!entry || typeof entry !== 'object') {
60 throw new Error('MCP resource snapshot result contained an invalid content block.');
61 }
62
63 const typedEntry = entry as { text?: unknown };
64 if (typeof typedEntry.text !== 'string') {
65 throw new Error('MCP resource snapshot result contained a non-text content block.');
66 }
67
68 contentBlocks.push(typedEntry.text);
69 }
70
71 return `${contentBlocks.join('\n')}\n`;
72}
73
74export async function invokeResource(resourceId: string): Promise<ResourceSnapshotResult> {
75 const manifest = resolveResourceManifest(resourceId);

Callers 1

invokeResourceFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected