Class AbstractMcpServerFactory<Spec,S,T,C,P,R>

java.lang.Object
io.micronaut.mcp.server.AbstractMcpServerFactory<Spec,S,T,C,P,R>
Type Parameters:
Spec - the type representing the MCP server specification.
S - the type representing the server transport.
T - the type representing tool specifications.
C - the type representing completion specifications.
P - the type representing prompt specifications.
R - the type representing resource specifications.

@Internal public abstract class AbstractMcpServerFactory<Spec,S,T,C,P,R> extends Object
An abstract factory class responsible for creating MCP server specifications. This class provides a framework for deriving specific implementations of MCP server factories.
  • Constructor Details

    • AbstractMcpServerFactory

      public AbstractMcpServerFactory()
  • Method Details

    • getTools

      protected abstract List<T> getTools(ToolRegistry toolRegistry)
      Retrieves a list of tools from the provided ToolRegistry.
      Parameters:
      toolRegistry - the registry of tools from which to retrieve the tools
      Returns:
      a list of tools retrieved from the provided tool registry
    • getPrompts

      protected abstract List<P> getPrompts(PromptRegistry promptRegistry)
      Retrieves a list of prompts from the provided PromptRegistry.
      Parameters:
      promptRegistry - the registry of prompts from which to retrieve the prompts
      Returns:
      a list of prompts retrieved from the provided prompt registry
    • getResources

      protected abstract List<R> getResources(ResourceRegistry resourceRegistry)
      Retrieves a list of resources from the provided ResourceRegistry.
      Parameters:
      resourceRegistry - the registry of resources from which to retrieve the resources
      Returns:
      a list of resources retrieved from the provided resource registry
    • createMcpServerSpec

      protected abstract Spec createMcpServerSpec(S transport, @Nullable @Nullable McpServerInfoConfiguration configuration, io.modelcontextprotocol.spec.McpSchema.ServerCapabilities capabilities, List<T> tools, List<C> completions, List<P> prompts, List<io.modelcontextprotocol.spec.McpSchema.ResourceTemplate> resourceTemplates, List<R> resources)
      Creates an MCP server specification based on the provided parameters.
      Parameters:
      transport - The transport protocol used by the MCP server.
      configuration - The configuration for the MCP server, or null if not provided.
      capabilities - The server capabilities to be used for the MCP server.
      tools - A list of tools to be included in the MCP server specification.
      completions - A list of completion configurations for the MCP server.
      prompts - A list of prompt configurations for the MCP server.
      resourceTemplates - A list of resource templates for the MCP server.
      resources - A list of server resources to be defined in the specification.
      Returns:
      The constructed server specification.