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, io.modelcontextprotocol.json.McpJsonMapper jsonMapper, io.modelcontextprotocol.json.schema.JsonSchemaValidator jsonSchemaValidator, @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.
      jsonMapper - MCP JSON Mapper
      jsonSchemaValidator - MCP JSON schema validator
      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 MCP server specification.
    • buildMcpServerSpec

      @Prototype public Spec buildMcpServerSpec(S transport, io.modelcontextprotocol.json.McpJsonMapper jsonMapper, io.modelcontextprotocol.json.schema.JsonSchemaValidator jsonSchemaValidator, @Nullable @Nullable McpServerInfoConfiguration configuration, ToolsConfiguration toolsConfiguration, PromptsConfiguration promptsConfiguration, ResourcesConfiguration resourcesConfiguration, io.modelcontextprotocol.spec.McpSchema.ServerCapabilities.Builder capabilitiesBuilder, jakarta.inject.Provider<io.modelcontextprotocol.spec.McpSchema.ServerCapabilities> capabilitiesProvider, ToolRegistry toolRegistry, PromptRegistry promptRegistry, ResourceRegistry resourceRegistry, List<T> tools, List<C> completions, List<P> prompts, List<io.modelcontextprotocol.spec.McpSchema.ResourceTemplate> resourceTemplates, List<R> resources)
      Parameters:
      transport - Transport
      jsonMapper - MCP JSON Mapper
      jsonSchemaValidator - MCP JSON schema validator
      configuration - MCP Server Info Configuration
      toolsConfiguration - Tools Configuration
      promptsConfiguration - Prompts Configuration
      resourcesConfiguration - Resources Configuration
      capabilitiesBuilder - Capabilities Builder
      capabilitiesProvider - Capabilities Provider
      toolRegistry - Tool Registry
      promptRegistry - Prompt Registry
      resourceRegistry - Resource Registry
      tools - Tools
      completions - Completions
      prompts - Prompts
      resourceTemplates - Resource Templates
      resources - Resources
      Returns:
      the MCP server specification.