Class McpServers

java.lang.Object
com.github.thought2code.mcp.annotated.McpServers

public final class McpServers extends Object
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 Details

    • run

      public static McpServers run(Class<?> applicationMainClass, String[] args)
      Initializes the McpServers instance with the specified application main class and arguments.
      Parameters:
      applicationMainClass - the main class of the application
      args - the arguments passed to the application
      Returns:
      the singleton instance of McpServers
    • startStdioServer

      @Deprecated(since="0.11.0", forRemoval=true) public void startStdioServer(McpServerInfo serverInfo)
      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

      public void startStdioServer(McpServerConfiguration.Builder configuration)
      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

      public void startSseServer(McpServerConfiguration.Builder configuration)
      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

      public void startStreamableServer(McpServerConfiguration.Builder configuration)
      Starts a streamable http server with the specified server configuration.
      Parameters:
      configuration - the server configuration builder for the streamable server
    • startServer

      public void startServer(String configFileName)
      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.