Package io.micronaut.mcp.server
Class AbstractMcpServerFactory<Spec,S,T,C,P,R,U>
java.lang.Object
io.micronaut.mcp.server.AbstractMcpServerFactory<Spec,S,T,C,P,R,U>
- 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.U
- the type representing resource template specifications.
An abstract factory class responsible for creating MCP server specifications.
This class provides a framework for deriving specific implementations of MCP server factories.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildMcpServerSpec
(S transport, io.modelcontextprotocol.json.McpJsonMapper jsonMapper, io.modelcontextprotocol.json.schema.JsonSchemaValidator jsonSchemaValidator, @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, ResourceTemplateRegistry resourceTemplateRegistry, CompletionRegistry completionRegistry, List<T> tools, List<C> completions, List<P> prompts, List<R> resources, List<U> resourceTemplates) protected abstract Spec
createMcpServerSpec
(S transport, io.modelcontextprotocol.json.McpJsonMapper jsonMapper, io.modelcontextprotocol.json.schema.JsonSchemaValidator jsonSchemaValidator, @Nullable McpServerInfoConfiguration configuration, io.modelcontextprotocol.spec.McpSchema.ServerCapabilities capabilities, List<T> tools, List<C> completions, List<P> prompts, List<R> resources, List<U> resourcesTemplates) Creates an MCP server specification based on the provided parameters.getCompletions
(CompletionRegistry completionRegistry) Retrieves a list of completions from the providedCompletionRegistry
.getPrompts
(PromptRegistry promptRegistry) Retrieves a list of prompts from the providedPromptRegistry
.getResources
(ResourceRegistry resourceRegistry) Retrieves a list of resources from the providedResourceRegistry
.getResourceTemplates
(ResourceTemplateRegistry resourceTemplateRegistry) Retrieves a list of resources templates from the providedResourceTemplateRegistry
.getTools
(ToolRegistry toolRegistry) Retrieves a list of tools from the providedToolRegistry
.
-
Constructor Details
-
AbstractMcpServerFactory
public AbstractMcpServerFactory()
-
-
Method Details
-
getTools
Retrieves a list of tools from the providedToolRegistry
.- Parameters:
toolRegistry
- the registry of tools from which to retrieve the tools- Returns:
- a list of tools retrieved from the provided tool registry
-
getPrompts
Retrieves a list of prompts from the providedPromptRegistry
.- Parameters:
promptRegistry
- the registry of prompts from which to retrieve the prompts- Returns:
- a list of prompts retrieved from the provided prompt registry
-
getResources
Retrieves a list of resources from the providedResourceRegistry
.- Parameters:
resourceRegistry
- the registry of resources from which to retrieve the resources- Returns:
- a list of resources retrieved from the provided resource registry
-
getResourceTemplates
Retrieves a list of resources templates from the providedResourceTemplateRegistry
.- Parameters:
resourceTemplateRegistry
- the registry of resource templates from which to retrieve the resource templates.- Returns:
- a list of resources templates retrieved from the provided resource registry
-
getCompletions
Retrieves a list of completions from the providedCompletionRegistry
.- Parameters:
completionRegistry
- the registry of completions from which to retrieve the completions.- Returns:
- a list of completions 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<R> resources, List<U> resourcesTemplates) Creates an MCP server specification based on the provided parameters.- Parameters:
transport
- The transport protocol used by the MCP server.jsonMapper
- MCP JSON MapperjsonSchemaValidator
- MCP JSON schema validatorconfiguration
- 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.resources
- A list of server resources to be defined in the specification.resourcesTemplates
- A list of resource templates for the MCP server.- 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, ResourceTemplateRegistry resourceTemplateRegistry, CompletionRegistry completionRegistry, List<T> tools, List<C> completions, List<P> prompts, List<R> resources, List<U> resourceTemplates) - Parameters:
transport
- TransportjsonMapper
- MCP JSON MapperjsonSchemaValidator
- MCP JSON schema validatorconfiguration
- MCP Server Info ConfigurationtoolsConfiguration
- Tools ConfigurationpromptsConfiguration
- Prompts ConfigurationresourcesConfiguration
- Resources ConfigurationcapabilitiesBuilder
- Capabilities BuildercapabilitiesProvider
- Capabilities ProvidertoolRegistry
- Tool RegistrypromptRegistry
- Prompt RegistryresourceRegistry
- Resource RegistryresourceTemplateRegistry
- Resource Template RegistrycompletionRegistry
- Completion Registrytools
- Toolscompletions
- Completionsprompts
- PromptsresourceTemplates
- Resource Templatesresources
- Resources- Returns:
- the MCP server specification.
-