Resource Template
Resource Templates allow MCP servers to expose dynamic content that follows a specific URI pattern, rather than a static list of URIs.
Structure
Templates use a syntax similar to URI Templates (RFC 6570), allowing variables to be embedded in the path or query components.
Example Template
A server might define a template for accessing GitHub issues:
github://{owner}/{repo}/issues/{issue_number}
Client Usage
- Discovery: The client sees the template in the
resources/templates/listresponse. - Interaction: The AI model identifies that it needs a specific issue and fills the variables.
- Reading: The client calls
resources/readwith the resolved URI, e.g.,github://hasmcp/hasmcp-landing/issues/1.
- Discovery: Helps agents understand the structure of the data a server can provide.
Dynamic Resource Mapping with HasMCP
HasMCP leverages Resource Templates to provide a highly flexible mapping between LLMs and complex API structures. By defining parameterized templates, developers can expose entire hierarchies of data through HasMCP without manual configuration for every individual resource. This is particularly powerful when combined with Automated OpenAPI Mapping, where HasMCP can dynamically generate resource templates based on the path parameters of an existing API, allowing an AI agent to "browse" through resources with semantic precision.
Questions & Answers
What is an "MCP Resource Template"?
A resource template is a parameterized URI definition used to dynamicially generate unique identifiers for resources. It allows a server to expose an entire hierarchy of data following a specific pattern, rather than listing every URI individually.
How do resource templates benefit AI agents during task execution?
Templates help agents understand the underlying structure of a server's data. By identifying the variables in a template (e.g., {owner} or {repo}), an AI model can intelligently construct the exact URI it needs to fetch specific information.
How does HasMCP use templates to simplify data access?
HasMCP uses templates to provide flexible mapping between LLMs and complex APIs. it can automatically generate templates based on OpenAPI path parameters, allowing AI agents to browse and access deeply nested enterprise resources without manual setup.