Annotation Interface CompleteResourceTemplate


@Target(METHOD) @Retention(RUNTIME) @Documented public @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 one String parameter representing the partial value that needs to be completed. In most cases it must be annotated with CompleteArg with the name attribute set, unless the code was compiled with the -parameters option. The name must match the name of one of the arguments of the related resource template.
  • CompletionContext - to access values already chosen for other arguments
  • McpRequest - to access information about the request
  • Cancellation - to allow processing to be stopped if the client cancels the tool call
  • Progress - 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 value
  • List<String> - multiple completion values
  • CompletionResult - 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
    Modifier and Type
    Required Element
    Description
    The name of the resource template this completion method is for.
  • Element Details

    • value

      String value
      The name of the resource template this completion method is for.

      This must reference an existing @ResourceTemplate annotation's name.

      Returns:
      the resource template name