Skip to content

Conversation

@habiblawal1
Copy link
Member

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

Azquelt
Azquelt previously approved these changes Nov 21, 2025
Comment on lines 167 to 170
String[] citiesArray = { "London", "Japan", "New York" };
for (String city : citiesArray) {
cancellation.skipProcessingIfCancelled();
System.out.println(city);
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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();
	}

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants