These resources are live and ready! The WebMCP polyfill is included with this documentation site. Install the MCP-B browser extension to enable AI agents (like Claude) to discover and read these resources directly.
Resource Registration
Understanding resource registration
Live Tools
Interactive tool demonstrations
Live Prompts
Interactive prompt demonstrations
WebMCP Status
Check if the WebMCP polyfill is loaded and ready:What are Resources?
Resources in MCP are data endpoints that AI agents can read. Unlike tools (which execute actions) or prompts (which generate messages), resources provide access to dynamic or static content like configuration, files, or API data.| Feature | Description |
|---|---|
| Purpose | Expose readable data to AI agents |
| URI | Unique identifier (static or template) |
| MIME Type | Content type hint (application/json, text/plain, etc.) |
| Output | Array of content objects with text or binary data |
App Settings Resource
Demonstrates: Static resource with fixed URI This resource shows the fundamentals ofregisterResource() - a static resource with a fixed URI that returns configuration data. The resource content updates dynamically based on the current settings.
File Reader Resource
Demonstrates: Resource template with URI parameters This resource shows advanced usage with URI templates - the{path} placeholder allows AI agents to read different files by specifying the path parameter. Templates enable flexible, parameterized data access.
Resource API Reference
registerResource(descriptor)
Registers a new resource with the browser.
listResources()
Returns all registered static resources.
listResourceTemplates()
Returns all registered resource templates.
The
readResource() method is called by AI agents through the MCP protocol, not directly from your application code. When an AI agent calls readResource('config://app-settings'), your registered read() handler is invoked and the result is returned to the agent.Static vs Template Resources
- Static Resources
- Template Resources
Static resources have fixed URIs and provide single data endpoints.Use cases:
- Application configuration
- User preferences
- System status
- Single data endpoints
Best Practices
Choose meaningful URIs
Choose meaningful URIs
Use descriptive URI schemes that indicate the data type:
config://, file://, user://, api://. This helps AI agents understand what they’re accessing.Specify MIME types
Specify MIME types
Always provide
mimeType to help AI agents parse content correctly. Use standard MIME types like application/json or text/plain.Handle errors gracefully
Handle errors gracefully
Return helpful error messages in the content when resources can’t be read. Include context about what went wrong.
Use templates for collections
Use templates for collections
When exposing multiple similar items (files, users, records), use URI templates instead of registering each item separately.
Keep content focused
Keep content focused
Return only the relevant data. Avoid dumping entire databases - let AI agents request specific resources as needed.
URI Scheme Examples
| Scheme | Example | Use Case |
|---|---|---|
config:// | config://app-settings | Application configuration |
file:// | file://{path} | Virtual filesystem |
user:// | user://{id}/profile | User data |
api:// | api://weather/{city} | External API data |
db:// | db://products/{sku} | Database records |
session:// | session://current | Session state |
