From f0fc52cdc9ba2c00b5c488773071af9e95719aa5 Mon Sep 17 00:00:00 2001 From: Adam Jones Date: Mon, 17 Nov 2025 16:06:37 +0000 Subject: [PATCH] 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}. --- src/everything/everything.ts | 43 +++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 1ce15ee9..89da0cb0 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -257,14 +257,51 @@ export const createServer = () => { } }); - // Register resource using modern API with a template pattern + // Register all 100 resources individually so they appear in listings + for (let i = 0; i < ALL_RESOURCES.length; i++) { + const resource = ALL_RESOURCES[i]; + const resourceId = i + 1; + + server.registerResource( + `static-resource-${resourceId}`, + resource.uri, + { + name: resource.name, + description: `Resource ${resourceId}: ${resource.mimeType === "text/plain" ? "plaintext resource" : "binary blob resource"}`, + mimeType: resource.mimeType, + }, + async () => { + // Build the resource contents based on type + if ('text' in resource && resource.text) { + return { + contents: [{ + uri: resource.uri, + mimeType: resource.mimeType, + text: resource.text as string, + }], + }; + } else if ('blob' in resource && resource.blob) { + return { + contents: [{ + uri: resource.uri, + mimeType: resource.mimeType, + blob: resource.blob as string, + }], + }; + } + throw new Error(`Resource ${resource.uri} has neither text nor blob`); + } + ); + } + + // Also register a template for the same pattern to support dynamic access server.registerResource( - 'static-resources', + 'static-resources-template', new ResourceTemplate('test://static/resource/{id}', { list: undefined }), { description: 'A static test resource with a numeric ID', }, - async (uri, variables, extra) => { + async (uri, variables) => { const id = Array.isArray(variables.id) ? variables.id[0] : variables.id; const index = parseInt(id, 10) - 1;