Annotation Interface MetaField


Adds custom metadata fields to the _meta object in MCP definitions.

This annotation can be used on @Tool, @Prompt, @Resource, or @ResourceTemplate methods to add custom metadata that will be included in the _meta field of the definition sent to clients.

Example:

 @MetaField(name = "version", value = "1.0")
 @MetaField(prefix = "myapp.io/", name = "customField", value = "customValue")
 @Tool(name = "myTool", description = "Example tool")
 public String myTool() {
     return "result";
 }
 
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Container annotation for multiple MetaField annotations.
    static enum 
    The type of metadata value.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the metadata field.
    The value of the metadata field as a string.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional prefix for the metadata key.
    The type of the metadata value.
  • Element Details

    • prefix

      String prefix
      Optional prefix for the metadata key.

      Must be a series of labels separated by dots (.), followed by a slash (/). Labels must start with a letter and end with a letter or digit; interior characters can be letters, digits, or hyphens (-).

      Some prefixes are reserved for the MCP spec, e.g. modelcontextprotocol.io/ or tools.mcp.com/.

      Examples: "modelcontextprotocol.io/", "myapp.io/"

      Returns:
      the key prefix
      Default:
      ""
    • name

      String name
      The name of the metadata field.

      Must begin and end with an alphanumeric character ([a-z0-9A-Z]). May contain hyphens (-), underscores (_), dots (.), and alphanumerics in between.

      Returns:
      the field name
    • type

      The type of the metadata value.
      Returns:
      the value type
      Default:
      STRING
    • value

      String value
      The value of the metadata field as a string.

      The value will be converted to the appropriate type based on type().

      Returns:
      the field value