Package org.mcpjava.server.completion
Annotation Interface CompleteResourceTemplate
Marks a method as providing completion suggestions for a resource template URI expression.
The annotated method returns completion values for URI template variables.
Parameters
Resource template completion methods may have parameters of the following types:
String- the method must have exactly oneStringparameter representing the partial value that needs to be completed. In most cases it must be annotated withCompleteArgwith thenameattribute set, unless the code was compiled with the-parametersoption. The name must match the name of one of the arguments of the related resource template.CompletionContext- to access values already chosen for other argumentsMcpRequest- to access information about the requestCancellation- to allow processing to be stopped if the client cancels the tool callProgress- to send progress reports back to the client- Implementations may define additional types that can be used as parameters
Return Type Handling
Return types can be:
String- single completion valueList<String>- multiple completion valuesCompletionResult- full completion response with metadata- Other types - Encoded according to framework-specific rules
Example:
@CompleteResourceTemplate("fileTemplate")
public List<String> completeFilePath(@CompleteArg(name = "path") String partialPath) {
// Return matching file paths
return findMatchingPaths(partialPath);
}
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueThe name of the resource template this completion method is for.This must reference an existing
@ResourceTemplateannotation's name.- Returns:
- the resource template name
-