Package org.machanism.machai.mcp.server


package org.machanism.machai.mcp.server
Provides the executable Model Context Protocol (MCP) server layer for Machai.

This package contains the command-line entry point and concrete server implementations used to expose Machai GenAI tools through MCP transports. The server can run over standard input/output for process-based integrations or over HTTP for remote clients. HTTP deployments support both stateless request handling and streamable, session-aware communication.

The package is organized around a shared server abstraction that defines common metadata, project-directory handling, tool registration, and startup behavior. StdioMcpServer, HttpStatelessMcpServer, and HttpStreamableMcpServer provide transport-specific implementations, while AbstractHttpMcpServer supplies the Jetty servlet hosting logic used by HTTP transports.

Tool exposure is handled through GenericGenaiAdapter, which converts Machai ToolFunction definitions and parameter descriptors into MCP tool schemas and synchronous tool specifications. The adapter invokes registered functions with request arguments, optional session identifiers, the configured project directory, and runtime configuration, then returns MCP-compliant tool results. HTTP server variants also register MCP prompts where supported.

The McpServer application class parses command-line options for the server name, version, project directory, port, and HTTP session mode. If a port is supplied, an HTTP server is started on that port; otherwise, the server runs in STDIO mode.

Since:
1.2.0
Author:
Viktor Tovstyi
  • Class
    Description
    Abstract base class for HTTP-based MCP (Model Context Protocol) server implementations.
    Abstract base class for MCP (Model Context Protocol) server implementations.
    Interface for building tool and tool specification objects for MCP servers.
    GenericGenaiAdapter<TExchange,TSpecification>
    A generic adapter for integrating GenAI tools with different server implementations.
    HttpStatelessMcpServer sets up and runs a Model Context Protocol (MCP) server that listens for HTTP requests on a specified port.
    HttpStatelessMcpServer sets up and runs a Model Context Protocol (MCP) server that listens for HTTP requests on a specified port.
    Entry point for starting the MCP (Model Context Protocol) server.
    StdioMcpServer sets up and runs a Model Context Protocol (MCP) server that communicates via standard input and output (STDIO).