MCP Server Maven Plugin 1.4.1 API

MCP Server Maven Plugin

The MCP Server Maven Plugin integrates a Machai Model Context Protocol (MCP) server into a Maven build through aggregator goals for stateless and streamable HTTP transports. It uses the current project's name, version, and base directory, loads the configured PropertiesConfigurator, applies Maven parameters without overriding existing system properties, registers the configured Machai AI tools, and starts the selected server.

The plugin exposes configured tools to MCP clients without a separate launcher, supporting local development, repeatable integration tests, demonstrations, and build-driven automation. Because both goals are aggregators, a multi-module reactor starts one server for the reactor rather than one server per module. The MCP Server Maven Plugin supports all types of project files, including source code, documentation, project-site content, and other relevant files exposed through its configured tools.

Architecture

The org.machanism.machai.mcp.maven package contains the shared abstract Mojo and the concrete transport Mojos. AbstractMCPServerMojo supplies Maven parameter handling and configuration loading: it copies configured parameter values to JVM system properties only when no value is already present, then loads the MCP server configurator. The shared configuration support also accommodates environment variables and credentials required by the configured server. HttpStatelessServerMojo and HttpStreamableMcpServerMojo use that foundation to create the respective Machai HTTP server, set its project directory and port, register the configured tools, and start it.

The org.machanism.machai.mcp.maven.tools package provides MCP lifecycle functions and supporting server-control behavior during Maven build execution. Its MCPServerTools implementation is supported for McpServer instances and exposes stop-mcp-server, which returns a shutdown acknowledgement before a delayed task records usage statistics and exits the JVM.

Class diagram showing AbstractMCPServerMojo as the shared base class of HttpStatelessServerMojo and HttpStreamableMcpServerMojo, plus MCPServerTools as the McpServer lifecycle function tool.

Packages

org.machanism.machai.mcp.maven
Maven plugin Mojos for configuring and starting stateless or streamable MCP HTTP servers, with shared support for Maven project metadata, server configuration, system properties, environment variables and credentials, the project directory, and the listening port.
org.machanism.machai.mcp.maven.tools
Function tools that control MCP server lifecycle behavior during Maven build execution, including the controlled stop-mcp-server shutdown operation.

Usage

Configure the plugin with the desired transport, HTTP port, configuration file, and Machai tool settings, then invoke the stateless or streamable Maven goal. The selected aggregator goal loads the configuration, applies additional parameters only when their JVM system properties are absent, and starts one server for the complete reactor. Connected MCP clients can then use the configured tools and request controlled shutdown through stop-mcp-server when the server is no longer needed.

Packages
Package
Description
Provides Maven plugin Mojos and utilities for managing MCP server lifecycle and configuration.
Contains utility classes and tools for MCP server operations within Maven plugins.