Skip to content

UUID based resources #2596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

UUID based resources #2596

wants to merge 3 commits into from

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.

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?

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
2 participants