Package org.machanism.machai.mcp.server
Class AbstractMcpServer
java.lang.Object
org.machanism.machai.mcp.server.AbstractMcpServer
- Direct Known Subclasses:
AbstractHttpMcpServer,StdioMcpServer
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceInterface for building tool and tool specification objects for MCP servers. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the configured project directory.voidsetProjectDir(File projectDir) Sets the project directory used by server tools.(package private) abstract voidstart()Starts the MCP server.(package private) abstract voidtools(Configurator config) Registers or defines the available tools for this MCP server.
-
Field Details
-
MACHAI_MACHANISM_HOMEPAGE
The homepage URL for the Machai MCP server.- See Also:
-
MACHAI_MACHANISM_ICON
The icon URL for the Machai MCP server.- See Also:
-
projectDir
-
-
Constructor Details
-
AbstractMcpServer
AbstractMcpServer()Constructs a newAbstractMcpServer.
-
-
Method Details
-
tools
Registers or defines the available tools for this MCP server.Subclasses must implement this method to provide tool registration logic.
-
start
Starts the MCP server.Subclasses must implement this method to provide server startup logic.
- Throws:
Exception- if the server fails to start
-
setProjectDir
Sets the project directory used by server tools.- Parameters:
projectDir- project directory to use, ornullwhen request-specific
-
getProjectDir
Returns the configured project directory.- Returns:
- project directory, or
nullwhen request-specific
-