Package org.machanism.machai.mcp.server
Class StdioMcpServer
java.lang.Object
org.machanism.machai.mcp.server.AbstractMcpServer
org.machanism.machai.mcp.server.StdioMcpServer
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classNested classes/interfaces inherited from class org.machanism.machai.mcp.server.AbstractMcpServer
AbstractMcpServer.ToolSpecificationBuilder<TExchange> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FunctionToolsLoaderLoader for registering function-based tools.private final org.slf4j.Loggerprivate final io.modelcontextprotocol.server.McpServer.SyncSpecification<io.modelcontextprotocol.server.McpServer.SingleSessionSyncSpecification> The MCP server specification for single-session sync operation.Fields inherited from class org.machanism.machai.mcp.server.AbstractMcpServer
MACHAI_MACHANISM_HOMEPAGE, MACHAI_MACHANISM_ICON -
Constructor Summary
ConstructorsConstructorDescriptionStdioMcpServer(String name, String version) Constructs a new StdioMcpServer with the given name and version. -
Method Summary
Modifier and TypeMethodDescription(package private) voidstart()Builds and returns the configuredMcpSyncServerinstance.(package private) voidtools(Configurator config) Loads and registers GenAI tools with the MCP server.Methods inherited from class org.machanism.machai.mcp.server.AbstractMcpServer
getProjectDir, setProjectDir
-
Field Details
-
log
private final org.slf4j.Logger log -
server
private final io.modelcontextprotocol.server.McpServer.SyncSpecification<io.modelcontextprotocol.server.McpServer.SingleSessionSyncSpecification> serverThe MCP server specification for single-session sync operation. -
functionToolsLoader
Loader for registering function-based tools.
-
-
Constructor Details
-
StdioMcpServer
Constructs a new StdioMcpServer with the given name and version.- Parameters:
name- the server name to report in the MCP APIversion- the server version to report in the MCP API
-
-
Method Details
-
tools
Loads and registers GenAI tools with the MCP server.This method uses a
FunctionToolsLoaderto apply tools to the server using aGenericGenaiAdapter.- Specified by:
toolsin classAbstractMcpServer
-
start
void start()Builds and returns the configuredMcpSyncServerinstance.Also registers a shutdown hook to ensure the server is closed gracefully on JVM exit.
- Specified by:
startin classAbstractMcpServer
-