@@ -32,15 +32,17 @@ Now you can create a simple MCP server with just one line of core code.
3232
3333``` java
3434import com.github.codeboyzhou.mcp.declarative.McpServers ;
35+ import com.github.codeboyzhou.mcp.declarative.annotation.McpI18nEnabled ;
3536import com.github.codeboyzhou.mcp.declarative.annotation.McpServerApplication ;
3637import com.github.codeboyzhou.mcp.declarative.server.McpServerInfo ;
3738
39+ @McpI18nEnabled
3840@McpServerApplication
3941public class McpStdioServer {
4042
41- public static void main (String [] args ) {
42- McpServers . run(McpStdioServer . class, args). startStdioServer(McpServerInfo . builder(). build());
43- }
43+ public static void main (String [] args ) {
44+ McpServers . run(McpStdioServer . class, args). startStdioServer(McpServerInfo . builder(). build());
45+ }
4446
4547}
4648```
@@ -83,48 +85,48 @@ For a MCP stdio server to run, you need to package your project into an executab
8385There is a Maven plugin that can handle this, just place the following configuration into your root ` pom.xml ` :
8486
8587``` xml
86-
8788<plugins >
88- <!-- Your other plugins ... -->
89- <plugin >
90- <groupId >org.apache.maven.plugins</groupId >
91- <artifactId >maven-shade-plugin</artifactId >
92- <version >${maven-shade-plugin.version}</version >
93- <executions >
94- <execution >
95- <goals >
96- <goal >shade</goal >
97- </goals >
98- <phase >package</phase >
99- <configuration >
100- <transformers >
101- <transformer
102- implementation =" org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" >
103- <mainClass >com.github.codeboyzhou.mcp.server.examples.McpStdioServer</mainClass >
104- </transformer >
105- </transformers >
106- </configuration >
107- </execution >
108- </executions >
109- </plugin >
89+ <!-- Your other plugins ... -->
90+ <plugin >
91+ <groupId >org.apache.maven.plugins</groupId >
92+ <artifactId >maven-shade-plugin</artifactId >
93+ <version >${maven-shade-plugin.version}</version >
94+ <executions >
95+ <execution >
96+ <goals >
97+ <goal >shade</goal >
98+ </goals >
99+ <phase >package</phase >
100+ <configuration >
101+ <transformers >
102+ <transformer implementation =" org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" >
103+ <mainClass >com.github.codeboyzhou.mcp.server.examples.McpStdioServer</mainClass >
104+ </transformer >
105+ </transformers >
106+ </configuration >
107+ </execution >
108+ </executions >
109+ </plugin >
110110</plugins >
111111```
112112
113- ### HTTP SSE Server
113+ ### HTTP SSE Server (Deprecated)
114114
115115#### Quick Start
116116
117117``` java
118118import com.github.codeboyzhou.mcp.declarative.McpServers ;
119+ import com.github.codeboyzhou.mcp.declarative.annotation.McpI18nEnabled ;
119120import com.github.codeboyzhou.mcp.declarative.annotation.McpServerApplication ;
120121import com.github.codeboyzhou.mcp.declarative.server.factory.McpSseServerInfo ;
121122
123+ @McpI18nEnabled
122124@McpServerApplication
123125public class McpSseServer {
124126
125- public static void main (String [] args ) {
126- McpServers . run(McpSseServer . class, args). startSseServer(McpSseServerInfo . builder(). build());
127- }
127+ public static void main (String [] args ) {
128+ McpServers . run(McpSseServer . class, args). startSseServer(McpSseServerInfo . builder(). build());
129+ }
128130
129131}
130132```
@@ -148,6 +150,28 @@ For the method `startSseServer`, you can specify the server information by using
148150
149151Just run the main class like you would launch a web application, and then it's all set.
150152
153+ ### Streamable HTTP Server
154+
155+ #### Quick Start
156+
157+ ``` java
158+ import com.github.codeboyzhou.mcp.declarative.McpServers ;
159+ import com.github.codeboyzhou.mcp.declarative.annotation.McpI18nEnabled ;
160+ import com.github.codeboyzhou.mcp.declarative.annotation.McpServerApplication ;
161+ import com.github.codeboyzhou.mcp.declarative.server.factory.McpStreamableServerInfo ;
162+
163+ @McpI18nEnabled
164+ @McpServerApplication
165+ public class McpStreamableServer {
166+
167+ public static void main (String [] args ) {
168+ McpStreamableServerInfo serverInfo = McpStreamableServerInfo . builder(). build();
169+ McpServers . run(McpStreamableServer . class, args). startStreamableServer(serverInfo);
170+ }
171+
172+ }
173+ ```
174+
151175## MCP Component
152176
153177In the previous section, we have learned how to create a MCP server, but the server still has no usable components, like
@@ -164,16 +188,16 @@ import com.github.codeboyzhou.mcp.declarative.annotation.McpResources;
164188@McpResources
165189public class MyMcpResources {
166190
167- /**
168- * This method defines a MCP resource to expose the OS env variables.
169- */
170- @McpResource (uri = " system://env" , description = " OS env variables" )
171- public String getSystemEnv () {
172- // Just put your logic code here, forget about the native MCP SDK details.
173- return System . getenv(). toString();
174- }
191+ /**
192+ * This method defines a MCP resource to expose the OS env variables.
193+ */
194+ @McpResource (uri = " system://env" , description = " OS env variables" )
195+ public String getSystemEnv () {
196+ // Just put your logic code here, forget about the native MCP SDK details.
197+ return System . getenv(). toString();
198+ }
175199
176- // Your other MCP resources here...
200+ // Your other MCP resources here...
177201}
178202```
179203
@@ -187,16 +211,16 @@ import com.github.codeboyzhou.mcp.declarative.annotation.McpPrompts;
187211@McpPrompts
188212public class MyMcpPrompts {
189213
190- /**
191- * This method defines a MCP prompt to read a file.
192- */
193- @McpPrompt (description = " A simple prompt to read a file" )
194- public String readFile (@McpPromptParam (name = " path" , description = " filepath" , required = true ) String path ) {
195- // Just put your logic code here, forget about the native MCP SDK details.
196- return String . format(" What is the complete contents of the file: %s" , path);
197- }
214+ /**
215+ * This method defines a MCP prompt to read a file.
216+ */
217+ @McpPrompt (description = " A simple prompt to read a file" )
218+ public String readFile (@McpPromptParam (name = " path" , description = " filepath" , required = true ) String path ) {
219+ // Just put your logic code here, forget about the native MCP SDK details.
220+ return String . format(" What is the complete contents of the file: %s" , path);
221+ }
198222
199- // Your other MCP prompts here...
223+ // Your other MCP prompts here...
200224}
201225```
202226
@@ -210,16 +234,16 @@ import com.github.codeboyzhou.mcp.declarative.annotation.McpTools;
210234@McpTools
211235public class MyMcpTools {
212236
213- /**
214- * This method defines a MCP tool to read a file.
215- */
216- @McpTool (description = " Read complete file contents with UTF-8 encoding" )
217- public String readFile (@McpToolParam (name = " path" , description = " filepath" , required = true ) String path ) {
218- // Just put your logic code here, forget about the native MCP SDK details.
219- return Files . readString(Path . of(path));
220- }
237+ /**
238+ * This method defines a MCP tool to read a file.
239+ */
240+ @McpTool (description = " Read complete file contents with UTF-8 encoding" )
241+ public String readFile (@McpToolParam (name = " path" , description = " filepath" , required = true ) String path ) {
242+ // Just put your logic code here, forget about the native MCP SDK details.
243+ return Files . readString(Path . of(path));
244+ }
221245
222- // Your other MCP tools here...
246+ // Your other MCP tools here...
223247}
224248```
225249
0 commit comments