Skip to content

Commit f0fc52c

Browse files
committed
fix: register all resources individually for listings
Resources are now registered individually so they appear in resources/list responses, while also keeping the template for dynamic access via test://static/resource/{id}.
1 parent 07a8809 commit f0fc52c

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

src/everything/everything.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,51 @@ export const createServer = () => {
257257
}
258258
});
259259

260-
// Register resource using modern API with a template pattern
260+
// Register all 100 resources individually so they appear in listings
261+
for (let i = 0; i < ALL_RESOURCES.length; i++) {
262+
const resource = ALL_RESOURCES[i];
263+
const resourceId = i + 1;
264+
265+
server.registerResource(
266+
`static-resource-${resourceId}`,
267+
resource.uri,
268+
{
269+
name: resource.name,
270+
description: `Resource ${resourceId}: ${resource.mimeType === "text/plain" ? "plaintext resource" : "binary blob resource"}`,
271+
mimeType: resource.mimeType,
272+
},
273+
async () => {
274+
// Build the resource contents based on type
275+
if ('text' in resource && resource.text) {
276+
return {
277+
contents: [{
278+
uri: resource.uri,
279+
mimeType: resource.mimeType,
280+
text: resource.text as string,
281+
}],
282+
};
283+
} else if ('blob' in resource && resource.blob) {
284+
return {
285+
contents: [{
286+
uri: resource.uri,
287+
mimeType: resource.mimeType,
288+
blob: resource.blob as string,
289+
}],
290+
};
291+
}
292+
throw new Error(`Resource ${resource.uri} has neither text nor blob`);
293+
}
294+
);
295+
}
296+
297+
// Also register a template for the same pattern to support dynamic access
261298
server.registerResource(
262-
'static-resources',
299+
'static-resources-template',
263300
new ResourceTemplate('test://static/resource/{id}', { list: undefined }),
264301
{
265302
description: 'A static test resource with a numeric ID',
266303
},
267-
async (uri, variables, extra) => {
304+
async (uri, variables) => {
268305
const id = Array.isArray(variables.id) ? variables.id[0] : variables.id;
269306
const index = parseInt(id, 10) - 1;
270307

0 commit comments

Comments
 (0)