Class AbstractMcpServer

java.lang.Object
org.machanism.machai.mcp.server.AbstractMcpServer
Direct Known Subclasses:
AbstractHttpMcpServer, StdioMcpServer

public abstract class AbstractMcpServer extends Object
Base implementation of a Model Context Protocol (MCP) server.

This class provides common hooks, constants, and working directory management for custom MCP server implementations designed to interact with generative-AI models.

Since:
1.2.0
Author:
Viktor Tovstyi
  • Field Details

    • MACHAI_MACHANISM_HOMEPAGE

      public static final String MACHAI_MACHANISM_HOMEPAGE
      The homepage URL for the Machai MCP server.
      See Also:
    • MACHAI_MACHANISM_ICON

      public static final String MACHAI_MACHANISM_ICON
      The icon URL for the Machai MCP server.
      See Also:
    • projectDir

      private File projectDir
  • Constructor Details

    • AbstractMcpServer

      AbstractMcpServer()
      Constructs a new AbstractMcpServer.
  • Method Details

    • tools

      abstract void tools(Configurator config)
      Registers or defines the available tools for this MCP server.

      Subclasses must implement this method to provide tool registration logic.

    • start

      abstract void start() throws Exception
      Starts the MCP server.

      Subclasses must implement this method to provide server startup logic.

      Throws:
      Exception - if the server fails to start
    • setProjectDir

      public void setProjectDir(File projectDir)
      Sets the project directory used by server tools.
      Parameters:
      projectDir - project directory to use, or null when request-specific
    • getProjectDir

      public File getProjectDir()
      Returns the configured project directory.
      Returns:
      project directory, or null when request-specific