-
Notifications
You must be signed in to change notification settings - Fork 72
Add package imports to MCP blog #4615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
update prod
e8a0fda to
d9fe2f3
Compare
| String[] citiesArray = { "London", "Japan", "New York" }; | ||
| for (String city : citiesArray) { | ||
| cancellation.skipProcessingIfCancelled(); | ||
| System.out.println(city); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I get what the citiesArray is for here (since it seems to just determine how many times you call skipProcessingIfCancelled()). Also, not sure what the println is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh. I think you were just trying to show something being processed... but that seems like an odd example, since System.out.println calls would be so fast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried adding a better example below with the most recent commit:
@Tool(name = "processLargeDataset", title = "Process Large Dataset", description = "Processes data in chunks. Can be cancelled by the client.")
public String processLargeDataset(Cancellation cancellation) {
String[] itemsToProcess = { "Item1", "Item2", "Item3" };
List<String> processedItems = new ArrayList<>();
for (String item : itemsToProcess) {
// Throws exception if client requests cancellation
cancellation.skipProcessingIfCancelled();
// Simulates a long running process
processItem(item);
processedItems.add(item);
}
return processedItems.toString();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Habib, I like that better.
In the MCP blog, the package imports are now included within the code snippets. Here is a preview in the draft site https://blogs-draft-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/blog/2025/10/23/mcp-standalone-blog.html