fix: Java cookbook recipes to compile with copilot-sdk-java 0.2.1-java.1

Fix compilation errors and documentation inaccuracies in Java cookbook
recipes against the actual SDK API:

- MultipleSessions: Replace non-existent destroy() with close()
- AccessibilityReport: Replace non-existent McpServerConfig class with
  Map<String, Object> (the actual type accepted by setMcpServers)
- error-handling.md: Replace non-existent session.addTool(),
  ToolDefinition.builder(), and ToolResultObject with actual SDK APIs
  (ToolDefinition.create(), SessionConfig.setTools(),
  CompletableFuture<Object> return type)

All 7 recipes now compile successfully with jbang build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges
2026-04-06 15:12:06 -04:00
parent 0f06f346be
commit e03ccb978a
5 changed files with 52 additions and 35 deletions

View File

@@ -43,11 +43,12 @@ public class AccessibilityReport {
client.start().get();
// Configure Playwright MCP server for browser automation
var mcpConfig = new McpServerConfig()
.setType("local")
.setCommand("npx")
.setArgs(List.of("@playwright/mcp@latest"))
.setTools(List.of("*"));
Map<String, Object> mcpConfig = Map.of(
"type", "local",
"command", "npx",
"args", List.of("@playwright/mcp@latest"),
"tools", List.of("*")
);
var session = client.createSession(
new SessionConfig()