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

Function registerResources

src/core/resources.ts:77–110  ·  view source on GitHub ↗
(
  server: McpServer,
  ctx: PredicateContext,
)

Source from the content-addressed store, hash-verified

75 * @returns true if resources were registered
76 */
77export async function registerResources(
78 server: McpServer,
79 ctx: PredicateContext,
80): Promise<boolean> {
81 const resources = await loadResources(ctx);
82
83 for (const [uri, resource] of resources) {
84 const readCallback = async (resourceUri: URL): Promise<ReadResourceResult> => {
85 const result = await resource.handler(resourceUri);
86 return {
87 contents: result.contents.map((content) => ({
88 uri: resourceUri.toString(),
89 text: content.text,
90 mimeType: resource.mimeType,
91 })),
92 };
93 };
94
95 server.resource(
96 resource.name,
97 uri,
98 {
99 mimeType: resource.mimeType,
100 title: resource.description,
101 },
102 readCallback,
103 );
104
105 log('info', `Registered resource: ${resource.name} at ${uri}`);
106 }
107
108 log('info', `Registered ${resources.size} resources`);
109 return true;
110}
111
112/**
113 * Get all available resource URIs for the given context.

Callers 2

resources.test.tsFile · 0.90
bootstrapServerFunction · 0.90

Calls 2

logFunction · 0.90
loadResourcesFunction · 0.85

Tested by

no test coverage detected