Skip to content

Conversation

@domdomegg
Copy link
Member

Fixes #475

Also see #2570

claude bot and others added 3 commits August 17, 2025 17:28
Fixes issue where array indices (0-based) didn't match URI numbers (1-based),
causing confusion where:
- Resource at index 0 was accessed via 'test://static/resource/1'
- Even indices (text resources) mapped to odd URI numbers

Changes:
- Resource URIs now use 0-based numbering to match array indices
- Resource 0 is now accessed via 'test://static/resource/0'
- Even indices now map to even URI numbers (more intuitive)

Resolves #475

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
…c paths

Implements @domdomegg's proposal to use UUIDs for resource identification instead of array indices:

- Generate UUIDs for all 100 resources (50 text, 50 blob)
- Use semantic paths: test://static/resource/text/{uuid} and test://static/resource/blob/{uuid}
- Remove dependency on array indices for URI construction
- Update resource templates to reflect new URI patterns
- Modify getResourceReference tool to accept resourceUri instead of resourceId
- Update resource_prompt argument from resourceId to resourceUri
- Improve resource link descriptions to mention UUID-based identification
- Update README documentation to reflect UUID-based system

This eliminates the confusion between array indices (0-based) and URI numbers (1-based)
while providing more intuitive resource categorization through semantic paths.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: adam jones <domdomegg@users.noreply.github.com>
@domdomegg
Copy link
Member Author

@claude please summarise the changes made in this PR. Read the discussion in #2570 for more context too.

@claude
Copy link
Contributor

claude bot commented Aug 22, 2025

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

  1. Eliminates Index Confusion: No more mismatch between 0-based array indices and 1-based resource names
  2. Semantic Clarity: Resource paths now clearly indicate type (text vs blob)
  3. Real-world Patterns: UUIDs better represent actual resource identification systems
  4. 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:

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.

@domdomegg domdomegg requested a review from olaservo August 22, 2025 02:47
Copy link
Member

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but what we've lost is the interleaving of the resources types.

Screenshot 2025-08-22 at 9 33 49 AM

Previously, we had Text, Blob, Text, Blob, etc. This interleaving was useful for variety in the getResourceLinks tool:
Screenshot 2025-08-22 at 9 35 21 AM

Could you add interleaving?

@olaservo
Copy link
Member

@claude could you update this PR to interleave the resource types as suggested in the previous comment?

@claude
Copy link
Contributor

claude bot commented Aug 23, 2025

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 getResourceLinks now 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

  • Read repository setup instructions (CLAUDE.md) - No CLAUDE.md found
  • Read current implementation in everything.ts
  • Understand the resource generation logic
  • Modify code to interleave text and blob resources
  • Test the changes (build + server start)
  • Commit and push changes

The PR now has the requested interleaving pattern while maintaining all the benefits of UUID-based resource identification!


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>
@olaservo
Copy link
Member

@cliffhall is this more what you were thinking?
image

(This is a screenshot from pulling the latest from this PR and then building it locally, and testing in latest Inspector.)

@cliffhall
Copy link
Member

cliffhall commented Aug 25, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[everything] Unintuitive / misleading resource indexing

4 participants