Interface McpServerComponent<T>

Type Parameters:
T - the type of component this interface creates (e.g., McpSchema.Resource, McpSchema.Prompt, McpSchema.Tool)
All Known Implementing Classes:
McpServerComponentBase, McpServerPrompt, McpServerResource, McpServerTool

public interface McpServerComponent<T>
Interface representing an MCP server component (resource/prompt/tool) that is responsible for creating instances of a specific type T for a given method.

This interface defines the contract for MCP server components that can create and register different types of server components based on annotated methods. Implementations of this interface handle the creation of specific component types (resources, prompts, tools) from methods annotated with appropriate MCP annotations.

Typical usage involves:

  • Creating a component instance from a method using from(Method)
  • Registering the component with the server using register()
Author:
codeboyzhou
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    from(Method method)
    Creates a component instance of type T from the specified method.
    void
    Registers all components of this type with the MCP server.
  • Method Details

    • from

      T from(Method method)
      Creates a component instance of type T from the specified method.

      This method processes the annotated method and creates an appropriate component instance based on the method's annotations, parameters, and return type. The exact type of component created depends on the implementation of this interface.

      Parameters:
      method - the annotated method to create a component from
      Returns:
      a component instance of type T created from the method
    • register

      void register()
      Registers all components of this type with the MCP server.

      This method scans for methods annotated with the appropriate annotation(s) for this component type and registers them with the server. The exact behavior depends on the implementation, but typically involves reflection to discover annotated methods and registration of created components with the server instance.