Class StdioMcpServer

java.lang.Object
org.machanism.machai.mcp.server.AbstractMcpServer
org.machanism.machai.mcp.server.StdioMcpServer

public class StdioMcpServer extends AbstractMcpServer
StdioMcpServer sets up and runs a Model Context Protocol (MCP) server that communicates via standard input and output (STDIO).

This server loads GenAI tools, configures server capabilities, and exposes the MCP API over STDIO for integration with other processes.

Since:
1.2.0
Author:
Viktor Tovstyi
  • Constructor Details

    • StdioMcpServer

      public StdioMcpServer(String name, String version)
      Constructs a new StdioMcpServer with the given name and version.
      Parameters:
      name - the server name to report in the MCP API
      version - the server version to report in the MCP API
  • Method Details

    • tools

      public void tools()
      Loads and registers GenAI tools with the MCP server.

      This method uses a FunctionToolsLoader to apply tools to the server using a GenericGenaiAdapter.

      Specified by:
      tools in class AbstractMcpServer
    • start

      public void start()
      Builds and returns the configured McpSyncServer instance.

      Also registers a shutdown hook to ensure the server is closed gracefully on JVM exit.

      Specified by:
      start in class AbstractMcpServer