Skip to content

Commit 25cdb38

Browse files
committed
Refactor annotation codegen structure and simplify config naming.
Split AnnotationProcessor code emission into typed *Codegen modules and rename configuration and converter classes to remove redundant Mcp prefixes, updating docs and tests accordingly.
1 parent e2d170a commit 25cdb38

37 files changed

Lines changed: 1080 additions & 750 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ The SDK creates **one instance per component class** (no-arg constructor) and re
296296
This project builds on the official [MCP Java SDK](https://github.com/modelcontextprotocol/java-sdk) **2.0.0-M3**, a **pre-release milestone**. APIs may change before 2.0 GA — pin dependency versions and re-run tests when upgrading.
297297

298298
- **STREAMABLE** is the recommended HTTP transport for new projects.
299-
- **SSE** (`ServerMode.SSE`, `McpSseServer`, `McpServerSSE`, `sse.*` in YAML) is **deprecated with `forRemoval = true` since 0.16.0** and scheduled for removal in a future release. Existing deployments may still use it for compatibility; migrate to **STREAMABLE** (`McpStreamableServer`, `streamable.*`).
299+
- **SSE** (`ServerMode.SSE`, `McpSseServer`, `ServerSse`, `sse.*` in YAML) is **deprecated with `forRemoval = true` since 0.16.0** and scheduled for removal in a future release. Existing deployments may still use it for compatibility; migrate to **STREAMABLE** (`McpStreamableServer`, `streamable.*`).
300300

301301
## 🏗️ Project Structure
302302

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ SDK 为每个组件类创建 **唯一实例**(无参构造),该类上所
298298
本项目基于官方 [MCP Java SDK](https://github.com/modelcontextprotocol/java-sdk) **2.0.0-M3**,属于 **预发布里程碑**。2.0 正式版发布前 API 可能变更 — 请锁定依赖版本,升级后重新跑集成测试。
299299

300300
- 新项目 HTTP 传输推荐 **STREAMABLE**。
301-
- **SSE**(`ServerMode.SSE`、`McpSseServer`、`McpServerSSE`、YAML 中的 `sse.*`)自 **0.16.0** 起已标记为 **`@Deprecated(forRemoval = true)`**,将在后续版本中移除。现有部署仍可兼容使用;请迁移至 **STREAMABLE**(`McpStreamableServer`、`streamable.*`)。
301+
- **SSE**(`ServerMode.SSE`、`McpSseServer`、`ServerSse`、YAML 中的 `sse.*`)自 **0.16.0** 起已标记为 **`@Deprecated(forRemoval = true)`**,将在后续版本中移除。现有部署仍可兼容使用;请迁移至 **STREAMABLE**(`McpStreamableServer`、`streamable.*`)。
302302

303303
## 🏗️ 推荐项目结构
304304

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ The SDK creates **one instance per component class** and reuses it for all reque
210210
This SDK depends on MCP Java SDK **2.0.0-M3** (pre-release). Pin versions and retest when upgrading.
211211

212212
- **STREAMABLE** is the recommended HTTP transport for new projects.
213-
- **SSE** (`ServerMode.SSE`, `McpSseServer`, `McpServerSSE`, `sse.*` in YAML) is **deprecated with `forRemoval = true` since 0.16.0** and scheduled for removal in a future release. Existing deployments may still use it for compatibility; migrate to **STREAMABLE** (`McpStreamableServer`, `streamable.*`).
213+
- **SSE** (`ServerMode.SSE`, `McpSseServer`, `ServerSse`, `sse.*` in YAML) is **deprecated with `forRemoval = true` since 0.16.0** and scheduled for removal in a future release. Existing deployments may still use it for compatibility; migrate to **STREAMABLE** (`McpStreamableServer`, `streamable.*`).
214214

215215
## Profile-based Configuration
216216

llms-full.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public String createUser(
478478
## Important Notes
479479

480480
1. **Entry point**: Use `McpApplication.run()`; component classes are discovered via `@McpServerApplication` package scanning.
481-
2. **Deprecated SSE (for removal since 0.16.0)**: HTTP SSE mode and related APIs (`ServerMode.SSE`, `McpSseServer`, `McpServerSSE`, `sse.*` config) are deprecated with `forRemoval = true` since 0.16.0. Use STREAMABLE mode (`McpStreamableServer`, `streamable.*`) for new HTTP projects.
481+
2. **Deprecated SSE (for removal since 0.16.0)**: HTTP SSE mode and related APIs (`ServerMode.SSE`, `McpSseServer`, `ServerSse`, `sse.*` config) are deprecated with `forRemoval = true` since 0.16.0. Use STREAMABLE mode (`McpStreamableServer`, `streamable.*`) for new HTTP projects.
482482
3. **MCP SDK milestone**: This project depends on MCP Java SDK **2.0.0-M3** (pre-release). Pin versions and retest when upgrading.
483483
4. **ASYNC is not reactive**: `type: ASYNC` selects the async MCP server API; handlers wrap blocking Java methods in `Mono.fromCallable(...)`. Annotated methods do not return `Mono`/`Flux`.
484484
5. **Singleton components**: One instance per component class is shared across concurrent requests. Keep components stateless or thread-safe.

llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ change-notification:
131131

132132
- Use `McpApplication.run()` as the server entry point; components are discovered through `@McpServerApplication` package scanning
133133
- `instructions` must be a non-blank string in `mcp-server.yml` (validated at startup)
134-
- SSE mode and related APIs (`ServerMode.SSE`, `McpSseServer`, `McpServerSSE`, `sse.*` config) are deprecated with `forRemoval = true` since 0.16.0; use STREAMABLE for new HTTP deployments
134+
- SSE mode and related APIs (`ServerMode.SSE`, `McpSseServer`, `ServerSse`, `sse.*` config) are deprecated with `forRemoval = true` since 0.16.0; use STREAMABLE for new HTTP deployments
135135
- Built on MCP Java SDK **2.0.0-M3** (milestone) — pin versions and retest when upgrading
136136
- `type: ASYNC` uses the async MCP server API; annotated methods stay blocking Java wrapped in `Mono.fromCallable(...)` — not Project Reactor
137137
- One instance per component class is created and shared across concurrent requests — keep components stateless or thread-safe

src/main/java/com/github/thought2code/mcp/annotated/McpApplication.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.github.thought2code.mcp.annotated;
22

3-
import com.github.thought2code.mcp.annotated.configuration.McpConfigurationLoader;
4-
import com.github.thought2code.mcp.annotated.configuration.McpServerConfiguration;
5-
import com.github.thought2code.mcp.annotated.configuration.McpServerDefaults;
3+
import com.github.thought2code.mcp.annotated.configuration.ConfigurationLoader;
4+
import com.github.thought2code.mcp.annotated.configuration.ServerConfiguration;
5+
import com.github.thought2code.mcp.annotated.configuration.ServerDefaults;
66
import com.github.thought2code.mcp.annotated.enums.ServerMode;
77
import com.github.thought2code.mcp.annotated.enums.ServerType;
88
import com.github.thought2code.mcp.annotated.server.AnnotatedMcpServer;
@@ -65,7 +65,7 @@ public static void run(Class<?> mainClass, String[] args, String configFileName)
6565
* @param args the command-line arguments passed to the application
6666
*/
6767
public static void run(Class<?> mainClass, String[] args) {
68-
run(mainClass, args, McpServerDefaults.CONFIG_FILE_NAME);
68+
run(mainClass, args, ServerDefaults.CONFIG_FILE_NAME);
6969
}
7070

7171
/**
@@ -92,14 +92,14 @@ public static void run(Class<?> mainClass, String[] args) {
9292
* @param configFileName the name of the configuration file to load
9393
* @param context the application context for component discovery and localization
9494
* @see McpApplicationContext
95-
* @see McpConfigurationLoader
96-
* @see McpServerConfiguration
95+
* @see ConfigurationLoader
96+
* @see ServerConfiguration
9797
* @see AnnotatedMcpServer
9898
* @see McpSyncServer
9999
*/
100100
private static void startMcpServer(String configFileName, McpApplicationContext context) {
101-
McpConfigurationLoader configurationLoader = new McpConfigurationLoader(configFileName);
102-
McpServerConfiguration configuration = configurationLoader.loadConfig();
101+
ConfigurationLoader configurationLoader = new ConfigurationLoader(configFileName);
102+
ServerConfiguration configuration = configurationLoader.loadConfig();
103103
log.info("Starting MCP server with config: {}", JacksonHelper.toJsonString(configuration));
104104

105105
if (!configuration.enabled()) {
@@ -143,7 +143,7 @@ private static void startMcpServer(String configFileName, McpApplicationContext
143143
*/
144144
@Deprecated(since = "0.16.0", forRemoval = true)
145145
private static AnnotatedMcpServer createSseServer(
146-
McpServerConfiguration configuration, McpApplicationContext context) {
146+
ServerConfiguration configuration, McpApplicationContext context) {
147147
return new McpSseServer(configuration, context);
148148
}
149149
}

src/main/java/com/github/thought2code/mcp/annotated/configuration/McpConfigurationChecker.java renamed to src/main/java/com/github/thought2code/mcp/annotated/configuration/ConfigurationChecker.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
* validates both base configuration properties and mode-specific settings for SSE and STREAMABLE
1313
* server modes.
1414
*
15-
* @see McpServerConfiguration
15+
* @see ServerConfiguration
1616
* @author codeboyzhou
1717
*/
18-
public final class McpConfigurationChecker {
18+
public final class ConfigurationChecker {
1919

20-
private McpConfigurationChecker() {
20+
private ConfigurationChecker() {
2121
throw new UnsupportedOperationException("Utility class should not be instantiated");
2222
}
2323

@@ -27,7 +27,7 @@ private McpConfigurationChecker() {
2727
* @param configuration the MCP server configuration to validate
2828
* @throws McpServerConfigurationException if any required configuration property is missing
2929
*/
30-
public static void check(McpServerConfiguration configuration) {
30+
public static void check(ServerConfiguration configuration) {
3131
checkCore(configuration);
3232
checkCapabilities(configuration.capabilities());
3333
checkChangeNotification(configuration.changeNotification());
@@ -38,7 +38,7 @@ public static void check(McpServerConfiguration configuration) {
3838
}
3939
}
4040

41-
private static void checkCore(McpServerConfiguration configuration) {
41+
private static void checkCore(ServerConfiguration configuration) {
4242
checkNull("enabled", configuration.enabled());
4343
checkNull("mode", configuration.mode());
4444
checkBlank("name", configuration.name());
@@ -50,7 +50,7 @@ private static void checkCore(McpServerConfiguration configuration) {
5050
checkNull("change-notification", configuration.changeNotification());
5151
}
5252

53-
private static void checkCapabilities(McpServerCapabilities capabilities) {
53+
private static void checkCapabilities(ServerCapabilities capabilities) {
5454
checkNull("capabilities.resource", capabilities.resource());
5555
if (capabilities.resource()) {
5656
checkNull("capabilities.subscribe-resource", capabilities.subscribeResource());
@@ -60,7 +60,7 @@ private static void checkCapabilities(McpServerCapabilities capabilities) {
6060
checkNull("capabilities.completion", capabilities.completion());
6161
}
6262

63-
private static void checkChangeNotification(McpServerChangeNotification changeNotification) {
63+
private static void checkChangeNotification(ServerChangeNotification changeNotification) {
6464
checkNull("change-notification.resource", changeNotification.resource());
6565
checkNull("change-notification.prompt", changeNotification.prompt());
6666
checkNull("change-notification.tool", changeNotification.tool());
@@ -73,15 +73,15 @@ private static void checkChangeNotification(McpServerChangeNotification changeNo
7373
* @deprecated HTTP SSE mode is deprecated; use {@link ServerMode#STREAMABLE} instead.
7474
*/
7575
@Deprecated(since = "0.16.0", forRemoval = true)
76-
private static void checkSse(McpServerSSE sse) {
76+
private static void checkSse(ServerSse sse) {
7777
checkNull("sse", sse);
7878
checkBlank("sse.message-endpoint", sse.messageEndpoint());
7979
checkBlank("sse.endpoint", sse.endpoint());
8080
checkBlank("sse.base-url", sse.baseUrl());
8181
checkNull("sse.port", sse.port());
8282
}
8383

84-
private static void checkStreamable(McpServerStreamable streamable) {
84+
private static void checkStreamable(ServerStreamable streamable) {
8585
checkNull("streamable", streamable);
8686
checkBlank("streamable.mcp-endpoint", streamable.mcpEndpoint());
8787
checkNull("streamable.disallow-delete", streamable.disallowDelete());

src/main/java/com/github/thought2code/mcp/annotated/configuration/McpConfigurationLoader.java renamed to src/main/java/com/github/thought2code/mcp/annotated/configuration/ConfigurationLoader.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@
2424
* Annotated Java SDK Documentation</a>
2525
* @author codeboyzhou
2626
*/
27-
public record McpConfigurationLoader(String configFileName) {
27+
public record ConfigurationLoader(String configFileName) {
2828

2929
/** The logger instance for this class. */
30-
private static final Logger log = LoggerFactory.getLogger(McpConfigurationLoader.class);
30+
private static final Logger log = LoggerFactory.getLogger(ConfigurationLoader.class);
3131

3232
/**
3333
* Loads the MCP server configuration from the specified YAML file.
3434
*
3535
* @return the loaded MCP server configuration
3636
* @throws McpServerConfigurationException if the configuration file cannot be loaded
3737
*/
38-
public McpServerConfiguration loadConfig() {
38+
public ServerConfiguration loadConfig() {
3939
File file = getConfigFilePath(configFileName).toFile();
40-
McpServerConfiguration configuration =
41-
JacksonHelper.fromYaml(file, McpServerConfiguration.class);
40+
ServerConfiguration configuration = JacksonHelper.fromYaml(file, ServerConfiguration.class);
4241
log.info("Configuration loaded successfully from file: {}", configFileName);
4342

4443
final String profile = configuration.profile();
@@ -48,13 +47,13 @@ public McpServerConfiguration loadConfig() {
4847
final String profileConfigFileName = configFileName.replace(".yml", "-" + profile + ".yml");
4948
File profileConfigFile = getConfigFilePath(profileConfigFileName).toFile();
5049
configuration =
51-
JacksonHelper.mergeYaml(configuration, profileConfigFile, McpServerConfiguration.class);
50+
JacksonHelper.mergeYaml(configuration, profileConfigFile, ServerConfiguration.class);
5251
log.info("Profile configuration merged successfully from file: {}", profileConfigFileName);
5352
}
5453

55-
McpServerConfiguration mergedConfig =
56-
McpConfigurationSupport.finalizeMerged(Objects.requireNonNull(configuration), profile);
57-
McpConfigurationChecker.check(mergedConfig);
54+
ServerConfiguration mergedConfig =
55+
ConfigurationSupport.finalizeMerged(Objects.requireNonNull(configuration), profile);
56+
ConfigurationChecker.check(mergedConfig);
5857
return mergedConfig;
5958
}
6059

@@ -67,7 +66,7 @@ public McpServerConfiguration loadConfig() {
6766
*/
6867
private Path getConfigFilePath(String fileName) {
6968
try {
70-
ClassLoader classLoader = McpConfigurationLoader.class.getClassLoader();
69+
ClassLoader classLoader = ConfigurationLoader.class.getClassLoader();
7170
URL configFileUrl = classLoader.getResource(fileName);
7271
if (configFileUrl == null) {
7372
throw new McpServerConfigurationException(

src/main/java/com/github/thought2code/mcp/annotated/configuration/McpConfigurationSupport.java renamed to src/main/java/com/github/thought2code/mcp/annotated/configuration/ConfigurationSupport.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* <p>Jackson profile merging handles field overlays; this class applies MCP-specific rules that are
1010
* not expressible through generic YAML merge alone.
1111
*/
12-
public final class McpConfigurationSupport {
12+
public final class ConfigurationSupport {
1313

14-
private McpConfigurationSupport() {
14+
private ConfigurationSupport() {
1515
throw new UnsupportedOperationException("Utility class should not be instantiated");
1616
}
1717

@@ -27,13 +27,13 @@ private McpConfigurationSupport() {
2727
* @param profileFromBase profile name from the base configuration file
2828
* @return finalized configuration
2929
*/
30-
public static McpServerConfiguration finalizeMerged(
31-
McpServerConfiguration configuration, String profileFromBase) {
30+
public static ServerConfiguration finalizeMerged(
31+
ServerConfiguration configuration, String profileFromBase) {
3232
ServerMode mode = configuration.mode();
3333
final String profile =
3434
StringHelper.isBlank(profileFromBase) ? configuration.profile() : profileFromBase;
3535

36-
return new McpServerConfiguration(
36+
return new ServerConfiguration(
3737
profile,
3838
configuration.enabled(),
3939
mode,

src/main/java/com/github/thought2code/mcp/annotated/configuration/McpServerCapabilities.java renamed to src/main/java/com/github/thought2code/mcp/annotated/configuration/ServerCapabilities.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,38 @@
77
*
88
* @author codeboyzhou
99
*/
10-
public record McpServerCapabilities(
10+
public record ServerCapabilities(
1111
@JsonProperty("resource") Boolean resource,
1212
@JsonProperty("subscribe-resource") Boolean subscribeResource,
1313
@JsonProperty("prompt") Boolean prompt,
1414
@JsonProperty("tool") Boolean tool,
1515
@JsonProperty("completion") Boolean completion) {
1616

1717
/**
18-
* Creates a new instance of {@code Builder} to build {@code McpServerCapabilities}.
18+
* Creates a new instance of {@code Builder} to build {@code ServerCapabilities}.
1919
*
2020
* @return A new instance of {@code Builder}.
2121
*/
2222
public static Builder builder() {
2323
return new Builder();
2424
}
2525

26-
/** Builder class for {@code McpServerCapabilities}. */
26+
/** Builder class for {@code ServerCapabilities}. */
2727
public static class Builder {
2828
/** The resource capability. */
29-
private Boolean resource = McpServerDefaults.CAPABILITY_ENABLED;
29+
private Boolean resource = ServerDefaults.CAPABILITY_ENABLED;
3030

3131
/** The subscribe-resource capability. */
32-
private Boolean subscribeResource = McpServerDefaults.CAPABILITY_ENABLED;
32+
private Boolean subscribeResource = ServerDefaults.CAPABILITY_ENABLED;
3333

3434
/** The prompt capability. */
35-
private Boolean prompt = McpServerDefaults.CAPABILITY_ENABLED;
35+
private Boolean prompt = ServerDefaults.CAPABILITY_ENABLED;
3636

3737
/** The tool capability. */
38-
private Boolean tool = McpServerDefaults.CAPABILITY_ENABLED;
38+
private Boolean tool = ServerDefaults.CAPABILITY_ENABLED;
3939

4040
/** The completion capability. */
41-
private Boolean completion = McpServerDefaults.CAPABILITY_ENABLED;
41+
private Boolean completion = ServerDefaults.CAPABILITY_ENABLED;
4242

4343
/**
4444
* Sets the resource capability.
@@ -96,12 +96,12 @@ public Builder completion(Boolean completion) {
9696
}
9797

9898
/**
99-
* Builds an instance of {@code McpServerCapabilities} with the configured values.
99+
* Builds an instance of {@code ServerCapabilities} with the configured values.
100100
*
101-
* @return A new instance of {@code McpServerCapabilities}.
101+
* @return A new instance of {@code ServerCapabilities}.
102102
*/
103-
public McpServerCapabilities build() {
104-
return new McpServerCapabilities(resource, subscribeResource, prompt, tool, completion);
103+
public ServerCapabilities build() {
104+
return new ServerCapabilities(resource, subscribeResource, prompt, tool, completion);
105105
}
106106
}
107107
}

0 commit comments

Comments
 (0)