URI Templates

URI Templates allow an MCP server to define patterns for resources rather than listing every possible URI individually. This is useful for servers that expose large or dynamic datasets (e.g., file:///logs/{date}.log).

How they work

  1. Definition: The server provides a template string with placeholders in curly braces.
  2. Expansion: The client (or model) fills in the placeholders with specific values to create a valid URI.
  3. Fetching: The client then requests the generated URI from the server.

URI Templates provide a scalable way to navigate complex resource structures in an AI-friendly manner.

Questions & Answers

What are "URI Templates" in an MCP server?

URI templates are standardized patterns that allow a server to define addressable resources using placeholders (e.g., file:///logs/{date}.log) rather than listing every individual URI. This is essential for managing large or dynamic datasets.

How does an AI client interact with a URI template?

First, the client discovers the template from the server. Then, based on its current task, the model fills in the placeholders with specific values to expand the template into a valid, unique URI that it can then request.

Why are templates considered "AI-friendly" for resource navigation?

Templates provide a structured and predictable way for AI models to browse through complex data hierarchies. By understanding the template parameters, the model can intelligently construct the exact address it needs to fetch specific information.

Back to Glossary