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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected File
    The Maven module base directory.
    protected Map<String,String>
    Map of environment variables for MCP server.
    protected int
    The port on which the MCP server will run.
    protected org.apache.maven.project.MavenProject
    The current Maven project.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new AbstractMCPServerMojo.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Applies environment parameters and credentials to the system properties.

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.maven.plugin.Mojo

    execute
  • Field Details

    • 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.
  • Constructor Details

    • AbstractMCPServerMojo

      public 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. If serverId is specified, resolves credentials from Maven settings.xml and sets them as system properties. Also applies any custom configuration properties found in the server configuration.

      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the specified server ID is not found in Maven settings