UUID based resources
Fixes #475
Also see #2570
@claude please summarise the changes made in this PR. Read the discussion in #2570 for more context too.
Claude finished @domdomegg's task —— View job
Summary
This PR replaces the problematic array index-based resource system with UUID-based semantic paths, resolving issue #475 and implementing the solution proposed in issue #2570.
Changes Made
Core Implementation Changes (everything.ts)
Resource Generation (Lines 260-279):
- Generates 50 UUIDs each for text and blob resources using
randomUUID() - Text resources use URI pattern:
test://static/resource/text/{uuid} - Blob resources use URI pattern:
test://static/resource/blob/{uuid} - Maintains same 100 total resources (50 text, 50 blob) but with unique identifiers
Resource Templates (Lines 318-329):
- Updated templates to reflect new URI patterns with UUID placeholders
- Clear separation between text and blob resource types in paths
Resource Lookups:
- All resource lookups now use
find()with URI matching instead of array indexing - Eliminates confusion between 0-based arrays and 1-based display numbers
Documentation Updates (README.md)
Resource Section (Lines 92-115):
- Updated all examples to show UUID-based URI patterns
- Added clear explanation of semantic paths (
/text/vs/blob/) - Emphasized benefits: "UUID-based identifiers eliminate index/URI confusion"
- Updated tool and prompt argument descriptions to use
resourceUri
Benefits of This Approach
- Eliminates Index Confusion: No more mismatch between 0-based array indices and 1-based resource names
- Semantic Clarity: Resource paths now clearly indicate type (text vs blob)
- Real-world Patterns: UUIDs better represent actual resource identification systems
- Type Safety: Path structure makes resource type explicit before lookup
Context from Issue #2570
The discussion in #2570 shows this was @domdomegg's suggested solution to avoid the "even/odd" indexing weirdness and provide more intuitive resource identification. @cliffhall agreed it was an excellent approach that "removes any assumptions about array index being meaningful" and "delivers the point that URIs can carry meaning."
Tasks:
- [x] Read changed files to understand implementation
- [x] Read issue #2570 discussion for context
- [x] Provide summary of changes
This is a well-thought-out improvement that makes the everything server's resource system much more intuitive and eliminates a common source of confusion for MCP client developers.
@claude could you update this PR to interleave the resource types as suggested in the previous comment?
Claude finished @olaservo's task —— View job
Summary
✅ Successfully updated the PR to interleave resource types as requested. The resources now alternate between text and blob (Text, Blob, Text, Blob, etc.) instead of generating all text resources followed by all blob resources.
Changes Made
Implementation Details
Resource Generation Logic (everything.ts:260-281)
- Replaced separate UUID array generation with interleaved generation loop
- Resources now alternate: Text Resource 1, Blob Resource 1, Text Resource 2, Blob Resource 2, etc.
- Maintains same total count: 100 resources (50 text + 50 blob)
- Each resource gets its own unique UUID generated when needed
Before:
Text Resource 1, Text Resource 2, ..., Text Resource 50,
Blob Resource 1, Blob Resource 2, ..., Blob Resource 50
After:
Text Resource 1, Blob Resource 1, Text Resource 2, Blob Resource 2,
Text Resource 3, Blob Resource 3, ... (alternating pattern)
Benefits Restored
- Better Variety: Tools like
getResourceLinksnow get a diverse mix of resource types - Consistent Patterns: Restores the interleaving behavior that was useful in the original implementation
- UUID Benefits Maintained: Still uses UUID-based semantic paths as implemented in the original PR
Verification
- ✅ Code compiles successfully with TypeScript
- ✅ Server starts without errors
- ✅ All existing functionality preserved
- ✅ Changes committed and pushed to branch
Todo List
- [x] Read repository setup instructions (CLAUDE.md) - No CLAUDE.md found
- [x] Read current implementation in everything.ts
- [x] Understand the resource generation logic
- [x] Modify code to interleave text and blob resources
- [x] Test the changes (build + server start)
- [x] Commit and push changes
The PR now has the requested interleaving pattern while maintaining all the benefits of UUID-based resource identification!
@cliffhall is this more what you were thinking?
(This is a screenshot from pulling the latest from this PR and then building it locally, and testing in latest Inspector.)
@cliffhall is this more what you were thinking?
@olaservo Yeah, but the new naming makes it fugly. It really would be better if the resource names were what they once were (Resource 1 ... Resource 100). Only when you selected a resource or listed it with the getResources or getResourceLinks tools did you really see the further detail about types.