You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: posts/2026-03-10-26.0.0.3-beta.adoc
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,18 +36,18 @@ See also link:{url-prefix}/blog/?search=beta&key=tag[previous Open Liberty beta
36
36
37
37
The link:https://modelcontextprotocol.io/docs/getting-started/intro[Model Context Protocol (MCP)] is an open standard that enables AI applications to access real-time information from external sources. The Liberty MCP Server feature (`mcpServer-1.0`) allows developers to expose the business logic of their applications, allowing it to be integrated into agentic AI workflows.
38
38
39
-
When a client calls a tool, the object returned by the tool method is converted to a `ToolResponse`, which usually contains one or more `Content` objects. The `ToolResponse` maps directly to the result returned in the response.
39
+
When a client calls a tool, the object that is returned by the tool method is converted to a `ToolResponse`, which usually contains one or more `Content` objects. The `ToolResponse` maps directly to the result returned in the response.
40
40
41
-
If you need more control over the response from your tool, you can return a `ToolResponse` or `Content` object directly, but now it's also possible to register encoders to control how other objects are converted into a response.
41
+
If you need more control over the response from your tool, you can return a `ToolResponse` or `Content` object directly. Now it is also possible to register encoders to control how other objects are converted into a response.
42
42
43
43
* Use `ToolResponseEncoder` to convert an object into a `ToolResponse`, which gives you complete control over the whole response.
44
-
* Use `ContentEncoder` when you only need to convert an object into a `Content` that will be included in the response. This also allows you to return a list of objects, and each object will be individually converted into a `Content` and included in the response.
44
+
* Use `ContentEncoder` only when you need to convert an object into a `Content` that is included in the response. You can also return a list of objects, and each object is individually converted into a `Content` and included in the response.
45
45
46
-
If a tool method returns an object for which no encoder is provided, JSON-B is used to encode the object as JSON which is returned as text content.
46
+
If a tool method returns an object for which no encoder is provided, JSON-B encodes the object as JSON, which is returned as text content.
47
47
48
48
=== Example
49
49
50
-
Say you have a tool which does a search over some datastore:
50
+
Consider a tool which does a search over some datastore:
51
51
52
52
[source,java]
53
53
----
@@ -58,11 +58,11 @@ public SearchResult search(@ToolArg(name="query", description="the query to run"
58
58
}
59
59
----
60
60
61
-
Imagine that the `SearchResult` object includes a list of results which includes a summary, some metadata, and an indication of how relevant the result is to the query.
61
+
In this scenario, the `SearchResult` object encapsulates a list of individual results. Each entry contains a summary, associated metadata, and a relevance score that indicates its relationship to the query.
62
62
63
-
By default, the returned `SearchResult` object will be encoded as JSON using JSON-B and the resulting JSON put into a `TextContent`. However, if instead we wanted each search result summary to be returned as its own `TextContent`, and set the priority annotation based on the relevance score, we can do that with a `ToolResponseEncoder`.
63
+
By default, the `SearchResult` object that is returned is encoded as JSON by using JSON-B and placed into a `TextContent`. However, to return each search result summary as an individual `TextContent` and map the relevance score to a priority annotation, a `ToolResponseEncoder` is to be used
64
64
65
-
Create a CDI bean which implements the `ToolResponseEncoder` interface and implement:
65
+
Create a CDI bean that implements the `ToolResponseEncoder` interface and implement:
66
66
67
67
* the `encode` method to create a `ToolResponse` from a `SearchResult`
68
68
* the `supports` method to indicate that your encoder can be used for any `SearchResult`.
@@ -96,7 +96,7 @@ public class SearchResultEncoder implements ToolResponseEncoder<SearchResult> {
96
96
}
97
97
----
98
98
99
-
This encoder will be used for any tools in the application which return a `SearchResult`.
99
+
This encoder is used for any tools in the application that return a `SearchResult`.
100
100
101
101
// DO NOT MODIFY THIS LINE. </GHA-BLOG-TOPIC>
102
102
@@ -107,9 +107,9 @@ This encoder will be used for any tools in the application which return a `Searc
107
107
[#requestid]
108
108
== Access the request ID from a tool
109
109
110
-
Every request from an MCP client includes a Request ID which is unique to that session. Tools can now access that ID. This is mostly useful for logging or auditing.
110
+
Each request from an MCP client includes a unique session-based Request ID, which is now accessible to tools and is useful for logging and auditing.
111
111
112
-
To access the ID, simply add a `RequestId` parameter to the tool method:
112
+
To access the ID, add a `RequestId` parameter to the tool method:
0 commit comments