Skip to content

Commit ab3f1dc

Browse files
committed
docs: add context-retrieved reverse method to MCP StringHelper example
1 parent 5c2e6d8 commit ab3f1dc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,19 @@ <h3 id="mcp-title">AI Ready (MCP)</h3>
222222
this.registerTool(new StringHelper());
223223
}
224224

225-
public static class StringHelper {
225+
public class StringHelper {
226226
@Action(value = "string/uppercase", description = "Convert to uppercase", arguments = {
227227
@Argument(key = "text", description = "The text to convert", type = "string")
228228
})
229229
public String toUpperCase(String text) {
230230
return text == null ? null : text.toUpperCase();
231231
}
232+
233+
@Action(value = "string/reverse", description = "Reverse a string")
234+
public String reverse() {
235+
Object text = getContext().getAttribute("text");
236+
return text != null ? new StringBuilder(text.toString()).reverse().toString() : "";
237+
}
232238
}
233239
}</code></pre>
234240
</div>

0 commit comments

Comments
 (0)