Class MCPServerTools

java.lang.Object
org.machanism.machai.mcp.maven.tools.MCPServerTools
All Implemented Interfaces:
org.machanism.machai.ai.tools.FunctionTools

public class MCPServerTools extends Object implements org.machanism.machai.ai.tools.FunctionTools
Provides utility functions for managing the MCP server lifecycle. Implements FunctionTools to expose server control operations as callable functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    Delay in milliseconds before the server process exits after shutdown is initiated.
    private final org.slf4j.Logger
    Logger instance for server events and diagnostics.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    stopMcpServer(int exitCode)
    Stops the MCP server by initiating a delayed shutdown.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EXIT_DELAY

      private static final int EXIT_DELAY
      Delay in milliseconds before the server process exits after shutdown is initiated.
      See Also:
    • log

      private final org.slf4j.Logger log
      Logger instance for server events and diagnostics.
  • Constructor Details

    • MCPServerTools

      public MCPServerTools()
  • Method Details

    • stopMcpServer

      public String stopMcpServer(int exitCode)
      Stops the MCP server by initiating a delayed shutdown.

      This method logs the shutdown event, waits for a predefined delay, and then exits the JVM with the specified exit code.

      Parameters:
      exitCode - the exit code to use when shutting down the server (default is 0)
      Returns:
      a message indicating that the shutdown has been initiated