Class McpServers
java.lang.Object
com.github.thought2code.mcp.annotated.McpServers
This class is a singleton that provides methods to start MCP servers.
Example usage:
McpServerInfo serverInfo = McpServerInfo.builder().build();
McpServers.run(MyApplication.class, args).startStdioServer(serverInfo);
McpSseServerInfo sseServerInfo = McpSseServerInfo.builder().build();
McpServers.run(MyApplication.class, args).startSseServer(sseServerInfo);
McpStreamableServerInfo streamableServerInfo = McpStreamableServerInfo.builder().build();
McpServers.run(MyApplication.class, args).startStreamableServer(streamableServerInfo);
McpServers.run(MyApplication.class, args).startServer("mcp-server-config.yml");
McpServers.run(MyApplication.class, args).startServer();
- Author:
- codeboyzhou
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic McpServersInitializes the McpServers instance with the specified application main class and arguments.voidStarts a server with the default configuration file name.voidstartServer(String configFileName) Starts a server with the specified configuration file name.voidstartSseServer(McpServerConfiguration.Builder configuration) Starts an http server-sent events (sse) server with the specified server configuration.voidstartSseServer(McpSseServerInfo serverInfo) Deprecated, for removal: This API element is subject to removal in a future version.voidstartStdioServer(McpServerConfiguration.Builder configuration) Starts a standard input/output (stdio) server with the specified server configuration.voidstartStdioServer(McpServerInfo serverInfo) Deprecated, for removal: This API element is subject to removal in a future version.voidstartStreamableServer(McpServerConfiguration.Builder configuration) Starts a streamable http server with the specified server configuration.voidstartStreamableServer(McpStreamableServerInfo serverInfo) Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Details
-
run
Initializes the McpServers instance with the specified application main class and arguments.- Parameters:
applicationMainClass- the main class of the applicationargs- the arguments passed to the application- Returns:
- the singleton instance of McpServers
-
startStdioServer
Deprecated, for removal: This API element is subject to removal in a future version.Starts a standard input/output (stdio) server with the specified server info.- Parameters:
serverInfo- the server info for the stdio server
-
startStdioServer
Starts a standard input/output (stdio) server with the specified server configuration.- Parameters:
configuration- the server configuration builder for the stdio server
-
startSseServer
@Deprecated(since="0.11.0", forRemoval=true) public void startSseServer(McpSseServerInfo serverInfo) Deprecated, for removal: This API element is subject to removal in a future version.Starts an http server-sent events (sse) server with the specified server info.- Parameters:
serverInfo- the server info for the sse server
-
startSseServer
Starts an http server-sent events (sse) server with the specified server configuration.- Parameters:
configuration- the server configuration builder for the sse server
-
startStreamableServer
@Deprecated(since="0.11.0", forRemoval=true) public void startStreamableServer(McpStreamableServerInfo serverInfo) Deprecated, for removal: This API element is subject to removal in a future version.Starts a streamable http server with the specified server info.- Parameters:
serverInfo- the server info for the streamable server
-
startStreamableServer
Starts a streamable http server with the specified server configuration.- Parameters:
configuration- the server configuration builder for the streamable server
-
startServer
Starts a server with the specified configuration file name.- Parameters:
configFileName- the name of the configuration file
-
startServer
public void startServer()Starts a server with the default configuration file name.
-