This feature implements the MCP Resources specification. FrontMCP handles all protocol details automatically.
Why Resources?
In the Model Context Protocol, resources serve a fundamentally different purpose than tools:| Aspect | Resource | Tool |
|---|---|---|
| Purpose | Provide data to read | Execute actions |
| Direction | Model pulls data on demand | Model triggers execution |
| Idempotent | Always (read-only) | Not necessarily |
| Use case | Context loading, data retrieval | Side effects, mutations |
- Configuration — expose app settings, feature flags, environment info
- User data — profiles, preferences, permissions
- Documents — files, templates, knowledge base articles
- API responses — cached or live data from external services
- System state — logs, metrics, status information
Static Resources
Static resources have a fixed URI and return content at that specific address. Use them for singleton data like configuration or global state.Class Style
Function Style
For simpler resources, use the functional builder:Resource Templates
Resource templates use dynamic URIs with parameters following RFC 6570 Level 1 syntax. Parameters are extracted automatically and passed toexecute().
Class Style
URI Template Patterns
Record<string, string> and passed as the second argument to execute().
Registering Resources
Add resources to your app via theresources array:
Return Values
Resources support multiple return formats. The SDK automatically converts your return value to the MCPReadResourceResult format.
Simple Returns
Full MCP Format
For complete control over the response, return the fullReadResourceResult structure:
Multiple Content Items
Return an array to include multiple content blocks:Resource Metadata
Static Resource (@Resource)
Resource Template (@ResourceTemplate)
| Field | Description |
|---|---|
name | Programmatic identifier used internally and in MCP responses |
uri / uriTemplate | The address clients use to request this resource |
title | Human-friendly name for UI display |
description | Helps the model understand when to use this resource |
mimeType | Content type hint; auto-detected for JSON/text if omitted |
icons | Array of icons for visual representation in clients |
Resource Context
Class-based resources have access to a rich execution context viathis:
Using Providers
Inject services via theget() method:
Real-World Examples
Configuration Resource
Database-Backed Template
File System Resource
API Proxy Resource
MCP Protocol Integration
Resources integrate with the MCP protocol via three flows:| Flow | Description |
|---|---|
resources/list | Returns all static resources |
resources/templates/list | Returns all resource templates |
resources/read | Reads content from a specific URI |
resources/read with a URI:
- The SDK matches the URI against registered resources and templates
- For templates, parameters are extracted from the URI
- The
execute()method is called with the URI and parameters - The return value is converted to MCP
ReadResourceResultformat
Capabilities
FrontMCP automatically advertises resource capabilities during MCP initialization:| Capability | Description |
|---|---|
subscribe | When true, clients can subscribe to individual resource changes via resources/subscribe |
listChanged | When true, the server will send notifications/resources/list_changed when resources are added or removed |
listChanged: truewhen you have any resources registeredsubscribe: truewhen subscription support is enabled
Change Notifications
When resources change dynamically (e.g., via adapters or plugins), FrontMCP automatically sendsnotifications/resources/list_changed to connected clients. Clients that support this notification will refresh their resource list.
For subscribed resources, the server sends notifications/resources/updated when the content changes.
Best Practices
Do:- Use descriptive
nameanddescriptionfields to help models understand resource purpose - Return structured data (objects) when possible for better model comprehension
- Use templates for parameterized data instead of creating many static resources
- Keep resources focused—one resource per data concern
- Handle errors gracefully and return meaningful error messages
- Use resources for operations with side effects (use tools instead)
- Return extremely large datasets—paginate or summarize when needed
- Expose sensitive data without proper authentication checks
- Hardcode values that should come from configuration

