Package io.micronaut.mcp.server
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.
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, List<T> tools, List<C> completions, List<P> prompts, List<io.modelcontextprotocol.spec.McpSchema.ResourceTemplate> resourceTemplates, List<R> resources) 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<io.modelcontextprotocol.spec.McpSchema.ResourceTemplate> resourceTemplates, List<R> resources) Creates an MCP server specification based on the provided parameters.getPrompts
(PromptRegistry promptRegistry) Retrieves a list of prompts from the providedPromptRegistry
.getResources
(ResourceRegistry resourceRegistry) Retrieves a list of resources from the providedResourceRegistry
.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
-
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 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.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
- 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 Registrytools
- Toolscompletions
- Completionsprompts
- PromptsresourceTemplates
- Resource Templatesresources
- Resources- Returns:
- the MCP server specification.
-