Class McpServer

java.lang.Object
org.machanism.machai.mcp.server.McpServer

public class McpServer extends Object
Entry point for starting the MCP (Model Context Protocol) server.

Supports both STDIO and Remote (network) server modes, configurable via command-line options.

  • STDIO mode: Default, starts a server that communicates via standard input/output.
  • Remote mode: If the -p or --port option is specified, starts a server that listens on the given port.

Command-line options:

  • -h, --help: Show help message and exit.
  • -n, --name: Specify the MCP server name (default: mcp-machai-server).
  • -d, --projectDir: Specify the project directory path.
  • -v, --version: Specify the MCP server version (default: implementation version or "latest").
  • -p, --port: Specify the port number for Remote MCP Server mode.
  • -s, --session: Use streamable MCP server mode (only for Http MCP Server).
Since:
1.2.0
Author:
Viktor Tovstyi
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • MCP_CONFIG_FILE_NAME

      public static final String MCP_CONFIG_FILE_NAME
      Default Ghostwriter properties file name.

      This is the name of the configuration properties file that can be used as one of the configuration data sources.

      It can be overridden by the MCP_CONFIG_FILE_NAME property.

      See Also:
  • Constructor Details

    • McpServer

      public McpServer()
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Main entry point for the MCP server application.

      Parses command-line arguments to determine server mode and configuration, then starts the appropriate server.

      Parameters:
      args - command-line arguments
      Throws:
      Exception - if an error occurs during server startup
    • getConfigurator

      public static PropertiesConfigurator getConfigurator(String configFile) throws IOException
      Creates a configurator and loads the requested properties file. If no file is specified, a missing default file is tolerated.
      Parameters:
      configFile - configuration file path, or null to use MCP_CONFIG_FILE_NAME
      Returns:
      configured properties reader
      Throws:
      IOException - if an explicitly requested file cannot be loaded