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
  • 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
    • setConsoleOutputAtRuntime

      public static void setConsoleOutputAtRuntime()