Package org.machanism.machai.mcp.server
Class HttpStreamableMcpServer
java.lang.Object
org.machanism.machai.mcp.server.AbstractMcpServer
org.machanism.machai.mcp.server.AbstractHttpMcpServer
org.machanism.machai.mcp.server.HttpStreamableMcpServer
Configures and runs a streamable HTTP Model Context Protocol (MCP) server
that listens for HTTP requests on a specified port.
This server loads GenAI tools, configures server capabilities, and exposes the MCP API over HTTP using Jetty.
- Since:
- 1.2.0
- Author:
- Viktor Tovstyi
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassBuilds streamable MCP tool specifications from generic tool definitions.Nested classes/interfaces inherited from class org.machanism.machai.mcp.server.AbstractMcpServer
AbstractMcpServer.ToolSpecificationBuilder<E> -
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.StreamableSyncSpecification> The MCP server specification for streamable synchronous operation.private io.modelcontextprotocol.server.transport.HttpServletStreamableServerTransportProviderHTTP transport provider for the MCP server.Fields inherited from class org.machanism.machai.mcp.server.AbstractMcpServer
MACHAI_MACHANISM_HOMEPAGE, MACHAI_MACHANISM_ICON -
Constructor Summary
ConstructorsConstructorDescriptionHttpStreamableMcpServer(String name, String version) Constructs a new streamable HTTP MCP server with the given name and version. -
Method Summary
Modifier and TypeMethodDescriptionvoidstart()Starts the HTTP server and listens for incoming MCP requests on the specified port.voidtools(Configurator config) Loads and registers GenAI tools with the MCP server.Methods inherited from class org.machanism.machai.mcp.server.AbstractHttpMcpServer
getPort, getTransportProvider, setPort, setTransportProvider, startHttpServerMethods inherited from class org.machanism.machai.mcp.server.AbstractMcpServer
getEnabledTools, getProjectDir, setProjectDir
-
Field Details
-
log
private final org.slf4j.Logger log -
server
private final io.modelcontextprotocol.server.McpServer.SyncSpecification<io.modelcontextprotocol.server.McpServer.StreamableSyncSpecification> serverThe MCP server specification for streamable synchronous operation. -
functionToolsLoader
Loader for registering function-based tools. -
transportProvider
private io.modelcontextprotocol.server.transport.HttpServletStreamableServerTransportProvider transportProviderHTTP transport provider for the MCP server.
-
-
Constructor Details
-
HttpStreamableMcpServer
Constructs a new streamable HTTP MCP server 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
Starts the HTTP server and listens for incoming MCP requests on the specified port.- Specified by:
startin classAbstractMcpServer- Throws:
McpServerStartupException- if the server fails to start
-