Understanding Resources in WASImancer
π§ work in progress
What are Resources in WASImancer?
Resources in WASImancer are predefined information elements that can be accessed by MCP clients. They provide a way to store and deliver static data, contextual information, or configuration details that AI models or applications can query and utilize.
Resources serve as a central repository of information that can be referenced consistently across different interactions, making them ideal for:
- System instructions for large language models
- Reference information for tools
- Context data for AI applications
- Configuration settings for clients
Resource Configuration
Resources in WASImancer are defined in the resources.yml
file, which follows a specific structure to organize both static and (in future versions) dynamic resources.
Basic Structure
The basic structure of the resources.yml
file is:
Key Components
- Name: A unique identifier for the resource within WASImancer
- URI: A URI-style identifier that follows the format
scheme://identifier
- Contents: An array of content items, each with at least a
text
field and optionally additional key-value pairs
URI Schemes
WASImancer supports various URI schemes to identify different types of resources:
config://
: Configuration settingsinfo://
: Informational contentllm://
: Large Language Model specific content (like system instructions)data://
: Data referencesdoc://
: Documentation
These schemes help organize resources and make their purpose clear to both developers and clients.
Example Resources
System Instructions for LLMs
Server Information
User Profile Information
Multiple Content Items
Resources can have multiple content items, each potentially with different attributes:
How Resources Work in WASImancer
When WASImancer starts, it reads the resources.yml
file and registers all defined resources with the MCP server. The server then makes these resources available to clients through the MCP protocol.
Resource Registration
Inside WASImancer, resources are registered using code similar to:
This makes each resource accessible via its URI.
Client Access
MCP clients can access resources in two steps:
- List Resources: Clients can request a list of all available resources
- Read Resource: Clients can request the contents of a specific resource by URI
This two-step process allows clients to discover available resources and then access those they need.
Using Resources with MCP Clients
Listing Available Resources
In a JavaScript MCP client, you can list available resources:
The response will include all resource names and URIs.
Reading a Specific Resource
To read the contents of a specific resource:
Example: Using a Resource with an LLM
Best Practices for Resources
Organizing Resources
- Use Consistent Naming: Follow a clear naming convention for resources
- Group Related Resources: Use URI schemes to group related resources
- Keep Content Focused: Each resource should have a specific purpose
- Use Multiple Content Items: When appropriate, break complex information into multiple content items
Structure and Format
- Include Descriptive Text: Always provide a clear
text
field for each content item - Use Appropriate Metadata: Add relevant key-value pairs to provide context and structure
- Consider Format Needs: Structure content based on how it will be used by clients
Security and Privacy
- Avoid Sensitive Data: Do not store sensitive data in resources unless necessary
- Use Vague References: When referring to internal details, be general rather than specific
- Consider Validation: Implement validation for resource contents in critical applications
Use Cases for Resources
AI System Instructions
Resources are ideal for storing system instructions for language models:
Configuration Settings
Store configuration information that clients may need:
Context Data
Provide contextual information for specialized tools:
Client Documentation
Offer reference documentation for client applications:
Future Directions: Dynamic Resources
While currently WASImancer focuses on static resources, future versions will introduce dynamic resources that can:
- Generate Content: Create content on-demand based on parameters
- Access External Data: Fetch information from databases or APIs
- Personalize Content: Adapt resource content based on client or user information
This will make resources even more powerful for delivering contextual information to AI applications.
Conclusion
Resources in WASImancer provide a flexible and standardized way to deliver contextual information to MCP clients. By properly configuring and utilizing resources, you can enhance your AI applications with consistent reference information, configuration settings, and contextual data.
The structured nature of resources makes them ideal for storing system instructions for large language models, providing reference information for tools, and configuring client applications in a centralized and consistent manner.