Package io.modelcontextprotocol.util
Interface McpUriTemplateManager
- All Known Implementing Classes:
DefaultMcpUriTemplateManager
public interface McpUriTemplateManager
Interface for working with URI templates.
This interface provides methods for extracting variables from URI templates and matching them against actual URIs.
- Author:
- Christian Tzolov
-
Method Summary
Modifier and TypeMethodDescriptionExtract URI variable values from the actual request URI.Extract URI variable names from this URI template.booleanisUriTemplate(String uri) Check if the given URI is a URI template.booleanIndicate whether the given URI matches this template.
-
Method Details
-
getVariableNames
Extract URI variable names from this URI template.- Returns:
- A list of variable names extracted from the template
- Throws:
IllegalArgumentException- if duplicate variable names are found
-
extractVariableValues
Extract URI variable values from the actual request URI.This method converts the URI template into a regex pattern, then uses that pattern to extract variable values from the request URI.
- Parameters:
uri- The actual URI from the request- Returns:
- A map of variable names to their values
- Throws:
IllegalArgumentException- if the URI template is invalid or the request URI doesn't match the template pattern
-
matches
Indicate whether the given URI matches this template.- Parameters:
uri- the URI to match to- Returns:
trueif it matches;falseotherwise
-
isUriTemplate
Check if the given URI is a URI template.- Returns:
- Returns true if the URI contains variables in the format {variableName}
-