feat: interleave text and blob resources for better variety

Previously resources were generated as 50 text resources followed by 50 blob resources.
Now they alternate: Text, Blob, Text, Blob, etc. This provides better variety
when using tools like getResourceLinks and maintains the useful interleaving
pattern that was present before the UUID-based refactor.

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
This commit is contained in:
claude[bot]
2025-08-23 03:48:34 +00:00
parent 9d1a63cd42
commit 7d88d4e932

View File

@@ -257,26 +257,28 @@ export const createServer = () => {
return await server.request(request, z.any()); return await server.request(request, z.any());
}; };
// Generate UUIDs for resources (50 text, 50 blob) // Generate resources with alternating types (50 text, 50 blob, interleaved)
const TEXT_RESOURCE_UUIDS = Array.from({ length: 50 }, () => randomUUID()); const ALL_RESOURCES: Resource[] = [];
const BLOB_RESOURCE_UUIDS = Array.from({ length: 50 }, () => randomUUID());
const ALL_RESOURCES: Resource[] = [ for (let i = 0; i < 50; i++) {
// Text resources // Add text resource
...TEXT_RESOURCE_UUIDS.map((uuid, i) => ({ const textUuid = randomUUID();
uri: `test://static/resource/text/${uuid}`, ALL_RESOURCES.push({
uri: `test://static/resource/text/${textUuid}`,
name: `Text Resource ${i + 1}`, name: `Text Resource ${i + 1}`,
mimeType: "text/plain", mimeType: "text/plain",
text: `Text Resource ${i + 1}: This is a plaintext resource with UUID ${uuid}`, text: `Text Resource ${i + 1}: This is a plaintext resource with UUID ${textUuid}`,
} as Resource)), } as Resource);
// Blob resources
...BLOB_RESOURCE_UUIDS.map((uuid, i) => ({ // Add blob resource
uri: `test://static/resource/blob/${uuid}`, const blobUuid = randomUUID();
ALL_RESOURCES.push({
uri: `test://static/resource/blob/${blobUuid}`,
name: `Blob Resource ${i + 1}`, name: `Blob Resource ${i + 1}`,
mimeType: "application/octet-stream", mimeType: "application/octet-stream",
blob: Buffer.from(`Blob Resource ${i + 1}: This is a base64 blob with UUID ${uuid}`).toString("base64"), blob: Buffer.from(`Blob Resource ${i + 1}: This is a base64 blob with UUID ${blobUuid}`).toString("base64"),
} as Resource)), } as Resource);
]; }
const PAGE_SIZE = 10; const PAGE_SIZE = 10;