arguments);
+}
\ No newline at end of file
diff --git a/framework/fel/java/services/tool-mcp-client-service/src/main/java/modelengine/fel/tool/mcp/client/McpClientFactory.java b/framework/fel/java/services/tool-mcp-client-service/src/main/java/modelengine/fel/tool/mcp/client/McpClientFactory.java
new file mode 100644
index 00000000..1956b909
--- /dev/null
+++ b/framework/fel/java/services/tool-mcp-client-service/src/main/java/modelengine/fel/tool/mcp/client/McpClientFactory.java
@@ -0,0 +1,25 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
+ * This file is a part of the ModelEngine Project.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+package modelengine.fel.tool.mcp.client;
+
+/**
+ * Indicates the factory of {@link McpClient}.
+ *
+ * Each {@link McpClient} instance created by this factory is designed to connect to a single specified MCP server.
+ *
+ * @author 季聿阶
+ * @since 2025-05-21
+ */
+public interface McpClientFactory {
+ /**
+ * Creates a {@link McpClient} instance.
+ *
+ * @param connectionString The connection {@link String}.
+ * @return The connected {@link McpClient} instance.
+ */
+ McpClient create(String connectionString);
+}
\ No newline at end of file
diff --git a/framework/fel/java/services/tool-mcp-common/pom.xml b/framework/fel/java/services/tool-mcp-common/pom.xml
new file mode 100644
index 00000000..09c0fd96
--- /dev/null
+++ b/framework/fel/java/services/tool-mcp-common/pom.xml
@@ -0,0 +1,39 @@
+
+
+ 4.0.0
+
+
+ org.fitframework.fel
+ fel-services-parent
+ 3.5.0-SNAPSHOT
+
+
+ tool-mcp-common
+
+
+
+
+ org.fitframework
+ fit-api
+
+
+ org.fitframework
+ fit-util
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+
+
+ org.mockito
+ mockito-core
+
+
+ org.assertj
+ assertj-core
+
+
+
\ No newline at end of file
diff --git a/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Event.java b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Event.java
new file mode 100644
index 00000000..61adf739
--- /dev/null
+++ b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Event.java
@@ -0,0 +1,45 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
+ * This file is a part of the ModelEngine Project.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+package modelengine.fel.tool.mcp.entity;
+
+/**
+ * Represents different types of events used in MCP.
+ *
+ * @author 季聿阶
+ * @since 2025-05-22
+ */
+public enum Event {
+ /**
+ * Represents an endpoint event.
+ */
+ ENDPOINT("endpoint"),
+
+ /**
+ * Represents a message event.
+ */
+ MESSAGE("message");
+
+ private final String code;
+
+ /**
+ * Constructor to initialize the event with a specific code.
+ *
+ * @param code The code associated with the event.
+ */
+ Event(String code) {
+ this.code = code;
+ }
+
+ /**
+ * Returns the code associated with the event.
+ *
+ * @return The code of the event.
+ */
+ public String code() {
+ return this.code;
+ }
+}
\ No newline at end of file
diff --git a/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/JsonRpc.java b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/JsonRpc.java
new file mode 100644
index 00000000..1e0e84d5
--- /dev/null
+++ b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/JsonRpc.java
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
+ * This file is a part of the ModelEngine Project.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+package modelengine.fel.tool.mcp.entity;
+
+import java.util.Map;
+
+/**
+ * Represents a JSON RPC request entity, encapsulating information related to JSON RPC requests.
+ * This class follows the JSON RPC specification, supporting the construction and parsing of JSON RPC request objects.
+ *
+ * @author 季聿阶
+ * @since 2025-05-15
+ */
+public class JsonRpc {
+ /**
+ * Creates a JSON RPC request with the specified ID and method.
+ *
+ * @param id The unique identifier for the request.
+ * @param method The method name to be invoked.
+ * @param The type of the request ID.
+ * @return A JSON RPC request object.
+ */
+ public static Request createRequest(T id, String method) {
+ return new Request<>("2.0", id, method, null);
+ }
+
+ /**
+ * Creates a JSON RPC request with the specified ID, method, and parameters.
+ *
+ * @param id The unique identifier for the request.
+ * @param method The method name to be invoked.
+ * @param params The parameters associated with the method.
+ * @param The type of the request ID.
+ * @return A JSON RPC request object.
+ */
+ public static Request createRequest(T id, String method, Map params) {
+ return new Request<>("2.0", id, method, params);
+ }
+
+ /**
+ * Creates a JSON RPC response with the specified ID and result.
+ *
+ * @param id The unique identifier for the response.
+ * @param result The result of the request.
+ * @param The type of the response ID.
+ * @return A JSON RPC response object.
+ */
+ public static Response createResponse(T id, Object result) {
+ return new Response<>("2.0", id, result, null);
+ }
+
+ /**
+ * Creates a JSON RPC response with the specified ID and error.
+ *
+ * @param id The unique identifier for the response.
+ * @param error The error associated with the request.
+ * @param The type of the response ID.
+ * @return A JSON RPC response object.
+ */
+ public static Response createResponseWithError(T id, Object error) {
+ return new Response<>("2.0", id, null, error);
+ }
+
+ /**
+ * Creates a JSON RPC notification with the specified method.
+ *
+ * @param method The method name to be invoked.
+ * @return A JSON RPC notification object.
+ */
+ public static Notification createNotification(String method) {
+ return new Notification("2.0", method, null);
+ }
+
+ /**
+ * Creates a JSON RPC notification with the specified method and parameters.
+ *
+ * @param method The method name to be invoked.
+ * @param params The parameters associated with the method.
+ * @return A JSON RPC notification object.
+ */
+ public static Notification createNotification(String method, Map params) {
+ return new Notification("2.0", method, params);
+ }
+
+ /**
+ * Represents a JSON RPC request.
+ *
+ * @param The type of the request ID.
+ */
+ public record Request(String jsonrpc, T id, String method, Map params) {}
+
+ /**
+ * Represents a JSON RPC response.
+ *
+ * @param The type of the response ID.
+ */
+ public record Response(String jsonrpc, T id, Object result, Object error) {}
+
+ /**
+ * Represents a JSON RPC notification.
+ */
+ public record Notification(String jsonrpc, String method, Map params) {}
+}
diff --git a/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Method.java b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Method.java
new file mode 100644
index 00000000..b281aecd
--- /dev/null
+++ b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Method.java
@@ -0,0 +1,60 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
+ * This file is a part of the ModelEngine Project.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+package modelengine.fel.tool.mcp.entity;
+
+/**
+ * Represents different methods used in MCP, which are essential for communication and interaction.
+ *
+ * @author 季聿阶
+ * @since 2025-05-23
+ */
+public enum Method {
+ /**
+ * Represents the initialization method, used to set up the environment or system.
+ */
+ INITIALIZE("initialize"),
+
+ /**
+ * Represents the ping method, used to check the availability or connectivity of a service.
+ */
+ PING("ping"),
+
+ /**
+ * Represents the method to retrieve a list of tools, typically used in tool management.
+ */
+ TOOLS_LIST("tools/list"),
+
+ /**
+ * Represents the method to call a specific tool, used for executing tool functions.
+ */
+ TOOLS_CALL("tools/call"),
+
+ /**
+ * Represents the notification method indicating that the system has been initialized.
+ */
+ NOTIFICATION_INITIALIZED("notifications/initialized"),
+
+ /**
+ * Represents the notification method indicating a change in the list of tools.
+ */
+ NOTIFICATION_TOOLS_CHANGED("notifications/tools/list_changed");
+
+ private final String code;
+
+ Method(String code) {
+ this.code = code;
+ }
+
+ /**
+ * Returns the code associated with the method.
+ *
+ * @return The code of the method.
+ */
+ public String code() {
+ return this.code;
+ }
+}
\ No newline at end of file
diff --git a/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Server.java b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Server.java
new file mode 100644
index 00000000..9700c823
--- /dev/null
+++ b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Server.java
@@ -0,0 +1,213 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
+ * This file is a part of the ModelEngine Project.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+package modelengine.fel.tool.mcp.entity;
+
+/**
+ * Represents a server entity in the MCP framework, encapsulating information about the server's protocol version,
+ * capabilities, and additional server details.
+ *
+ * @author 季聿阶
+ * @since 2025-05-22
+ */
+public class Server {
+ private String protocolVersion;
+ private Capabilities capabilities;
+ private Info serverInfo;
+
+ /**
+ * Returns the protocol version used by the server.
+ *
+ * @return The protocol version.
+ */
+ public String getProtocolVersion() {
+ return this.protocolVersion;
+ }
+
+ /**
+ * Sets the protocol version used by the server.
+ *
+ * @param protocolVersion The protocol version to set.
+ */
+ public void setProtocolVersion(String protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ /**
+ * Returns the capabilities supported by the server.
+ *
+ * @return The server capabilities.
+ */
+ public Capabilities getCapabilities() {
+ return this.capabilities;
+ }
+
+ /**
+ * Sets the capabilities supported by the server.
+ *
+ * @param capabilities The server capabilities to set.
+ */
+ public void setCapabilities(Capabilities capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ /**
+ * Returns additional information about the server.
+ *
+ * @return The server information.
+ */
+ public Info getServerInfo() {
+ return this.serverInfo;
+ }
+
+ /**
+ * Sets additional information about the server.
+ *
+ * @param serverInfo The server information to set.
+ */
+ public void setServerInfo(Info serverInfo) {
+ this.serverInfo = serverInfo;
+ }
+
+ @Override
+ public String toString() {
+ return "Server{" + "protocolVersion='" + protocolVersion + '\'' + ", capabilities=" + capabilities
+ + ", serverInfo=" + serverInfo + '}';
+ }
+
+ /**
+ * Represents the capabilities supported by the server, including logging and tool-related functionalities.
+ */
+ public static class Capabilities {
+ private Logging logging;
+ private Tools tools;
+
+ /**
+ * Returns the logging capabilities of the server.
+ *
+ * @return The logging capabilities.
+ */
+ public Logging getLogging() {
+ return this.logging;
+ }
+
+ /**
+ * Sets the logging capabilities of the server.
+ *
+ * @param logging The logging capabilities to set.
+ */
+ public void setLogging(Logging logging) {
+ this.logging = logging;
+ }
+
+ /**
+ * Returns the tool-related capabilities of the server.
+ *
+ * @return The tool-related capabilities.
+ */
+ public Tools getTools() {
+ return this.tools;
+ }
+
+ /**
+ * Sets the tool-related capabilities of the server.
+ *
+ * @param tools The tool-related capabilities to set.
+ */
+ public void setTools(Tools tools) {
+ this.tools = tools;
+ }
+
+ @Override
+ public String toString() {
+ return "Capabilities{" + "logging=" + logging + ", tools=" + tools + '}';
+ }
+
+ /**
+ * Represents the logging capabilities of the server.
+ */
+ public static class Logging {}
+
+ /**
+ * Represents the tool-related capabilities of the server, including whether the tool list has changed.
+ */
+ public static class Tools {
+ private boolean listChanged;
+
+ /**
+ * Returns whether the tool list has changed.
+ *
+ * @return True if the tool list has changed, false otherwise.
+ */
+ public boolean isListChanged() {
+ return this.listChanged;
+ }
+
+ /**
+ * Sets whether the tool list has changed.
+ *
+ * @param listChanged The change status of the tool list.
+ */
+ public void setListChanged(boolean listChanged) {
+ this.listChanged = listChanged;
+ }
+
+ @Override
+ public String toString() {
+ return "Tools{" + "listChanged=" + listChanged + '}';
+ }
+ }
+ }
+
+ /**
+ * Represents additional information about the server, such as its name and version.
+ */
+ public static class Info {
+ private String name;
+ private String version;
+
+ /**
+ * Returns the name of the server.
+ *
+ * @return The server name.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Sets the name of the server.
+ *
+ * @param name The server name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the version of the server.
+ *
+ * @return The server version.
+ */
+ public String getVersion() {
+ return this.version;
+ }
+
+ /**
+ * Sets the version of the server.
+ *
+ * @param version The server version to set.
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public String toString() {
+ return "Info{" + "name='" + name + '\'' + ", version='" + version + '\'' + '}';
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/fel/java/plugins/tool-mcp-server/src/main/java/modelengine/fel/tool/mcp/server/entity/ToolEntity.java b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Tool.java
similarity index 97%
rename from framework/fel/java/plugins/tool-mcp-server/src/main/java/modelengine/fel/tool/mcp/server/entity/ToolEntity.java
rename to framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Tool.java
index 7ffe45b9..0b7c0f69 100644
--- a/framework/fel/java/plugins/tool-mcp-server/src/main/java/modelengine/fel/tool/mcp/server/entity/ToolEntity.java
+++ b/framework/fel/java/services/tool-mcp-common/src/main/java/modelengine/fel/tool/mcp/entity/Tool.java
@@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
-package modelengine.fel.tool.mcp.server.entity;
+package modelengine.fel.tool.mcp.entity;
import java.util.Map;
@@ -14,7 +14,7 @@
* @author 季聿阶
* @since 2025-05-15
*/
-public class ToolEntity {
+public class Tool {
/**
* The name of the tool.
* This serves as a unique identifier for the tool within the system.
diff --git a/framework/fel/java/services/tool-service/src/main/java/modelengine/fel/tool/support/AbstractTool.java b/framework/fel/java/services/tool-service/src/main/java/modelengine/fel/tool/support/AbstractTool.java
index d50157b6..022198d6 100644
--- a/framework/fel/java/services/tool-service/src/main/java/modelengine/fel/tool/support/AbstractTool.java
+++ b/framework/fel/java/services/tool-service/src/main/java/modelengine/fel/tool/support/AbstractTool.java
@@ -86,8 +86,7 @@ public Object executeWithJsonObject(Map jsonObject) {
}
private static Object getArg(Object value, Type type) {
- if (type instanceof OneOfType) {
- OneOfType oneOfType = (OneOfType) type;
+ if (type instanceof OneOfType oneOfType) {
List types = oneOfType.types();
for (Type actualType : types) {
try {
diff --git a/framework/fit/java/fit-builtin/plugins/fit-message-serializer-json-jackson/src/main/java/modelengine/fit/serialization/json/jackson/JacksonObjectSerializer.java b/framework/fit/java/fit-builtin/plugins/fit-message-serializer-json-jackson/src/main/java/modelengine/fit/serialization/json/jackson/JacksonObjectSerializer.java
index e5efcf4c..aac622dc 100644
--- a/framework/fit/java/fit-builtin/plugins/fit-message-serializer-json-jackson/src/main/java/modelengine/fit/serialization/json/jackson/JacksonObjectSerializer.java
+++ b/framework/fit/java/fit-builtin/plugins/fit-message-serializer-json-jackson/src/main/java/modelengine/fit/serialization/json/jackson/JacksonObjectSerializer.java
@@ -16,6 +16,7 @@
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
import com.fasterxml.jackson.databind.module.SimpleModule;
@@ -85,7 +86,8 @@ public JacksonObjectSerializer(@Value("${date-time-format}") String dateTimeForm
.build()).build()).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setAnnotationIntrospector(new FitAnnotationIntrospector())
.setVisibility(visibilityChecker)
- .setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
SimpleModule module = new SimpleModule();
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(dateTimeFormat));
module.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(dateTimeFormat));
diff --git a/framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/entity/serializer/TextEventStreamSerializer.java b/framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/entity/serializer/TextEventStreamSerializer.java
index 4cc6194b..5d8e7728 100644
--- a/framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/entity/serializer/TextEventStreamSerializer.java
+++ b/framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/entity/serializer/TextEventStreamSerializer.java
@@ -86,7 +86,7 @@ private void emitData(Emitter emitter, BufferedReader reader) throws
}
private Object deserializeData(String data) {
- if (this.type == String.class) {
+ if (this.type == String.class || this.type == TextEvent.class) {
return data;
}
return this.jsonSerializer.deserialize(data, this.type);