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.

  • Field Details

    • logger

      static final org.slf4j.Logger logger
    • basedir

      @Parameter(defaultValue="${basedir}", required=true) protected File basedir
      The Maven module base directory.
    • project

      @Parameter(readonly=true, defaultValue="${project}") protected org.apache.maven.project.MavenProject project
      The current Maven project.
    • port

      @Parameter(property="mcp.port", required=true) protected int port
      The port on which the MCP server will run.
    • params

      @Parameter protected Map<String,String> 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 new AbstractMCPServerMojo.
  • Method Details

    • applyParameters

      public void applyParameters() throws org.apache.maven.plugin.MojoExecutionException
      Applies environment parameters and credentials to the system properties.

      Sets each parameter in params as 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