mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-22 22:05:28 +02:00
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:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user