Package org.machanism.machai.mcp.maven
Class AbstractMCPServerMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.machanism.machai.mcp.maven.AbstractMCPServerMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
HttpStatelessServerMojo,HttpStreamableMcpServerMojo
public abstract class AbstractMCPServerMojo
extends org.apache.maven.plugin.AbstractMojo
Abstract base class for MCP server Maven plugin Mojos.
Provides common configuration and utility methods for managing environment variables and credentials required by the MCP server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileThe Maven module base directory.private File(package private) static final org.slf4j.LoggerMap of environment variables for MCP server.protected intThe port on which the MCP server will run.protected org.apache.maven.project.MavenProjectThe current Maven project.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a newAbstractMCPServerMojo. -
Method Summary
Modifier and TypeMethodDescriptionvoidApplies environment parameters and credentials to the system properties.protected PropertiesConfiguratorloadConfigurator(String configurationPath) Loads the configurator used by this Mojo.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
logger
static final org.slf4j.Logger logger -
basedir
The Maven module base directory. -
project
@Parameter(readonly=true, defaultValue="${project}") protected org.apache.maven.project.MavenProject projectThe current Maven project. -
port
@Parameter(property="mcp.port", required=true) protected int portThe port on which the MCP server will run. -
params
Map of environment variables for MCP server. -
configFile
@Parameter(property="mcp.config", required=false, defaultValue="mcp.properties") private File configFile
-
-
Constructor Details
-
AbstractMCPServerMojo
protected AbstractMCPServerMojo()Constructs a newAbstractMCPServerMojo.
-
-
Method Details
-
applyParameters
public void applyParameters() throws org.apache.maven.plugin.MojoExecutionExceptionApplies environment parameters and credentials to the system properties.Sets each parameter in
paramsas a system property if not already set.- Throws:
org.apache.maven.plugin.MojoExecutionException- if applying the parameters fails
-
getConfigurator
public PropertiesConfigurator getConfigurator() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
loadConfigurator
protected PropertiesConfigurator loadConfigurator(String configurationPath) throws AbstractMCPServerMojo.ConfigurationLoadingException Loads the configurator used by this Mojo. Kept as a separate operation so transport Mojos can be tested without starting the static server bootstrap.- Parameters:
configurationPath- absolute path of the configuration file- Returns:
- the loaded configurator
- Throws:
AbstractMCPServerMojo.ConfigurationLoadingException
-