类 McpServers
java.lang.Object
com.github.codeboyzhou.mcp.declarative.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();
- 作者:
- codeboyzhou
- 另请参阅:
-
方法概要
修饰符和类型方法说明static 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(McpSseServerInfo serverInfo) Starts a http server-sent events (sse) server with the specified server info.voidstartStdioServer(McpServerInfo serverInfo) Starts a standard input/output (stdio) server with the specified server info.voidstartStreamableServer(McpStreamableServerInfo serverInfo) Starts a streamable http server with the specified server info.
-
方法详细资料
-
run
Initializes the McpServers instance with the specified application main class and arguments.- 参数:
applicationMainClass- the main class of the applicationargs- the arguments passed to the application- 返回:
- the singleton instance of McpServers
-
startStdioServer
Starts a standard input/output (stdio) server with the specified server info.- 参数:
serverInfo- the server info for the stdio server
-
startSseServer
Starts a http server-sent events (sse) server with the specified server info.- 参数:
serverInfo- the server info for the sse server
-
startStreamableServer
Starts a streamable http server with the specified server info.- 参数:
serverInfo- the server info for the streamable server
-
startServer
Starts a server with the specified configuration file name.- 参数:
configFileName- the name of the configuration file
-
startServer
public void startServer()Starts a server with the default configuration file name.
-