Add mcp-apps module: Spring AI 2.1.0 MCP server with MCP Apps HTML views, app-only tool callbacks, CSP declarations, SDK client tests and a Chromium harness on the official AppBridge

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4RzcCS5JCAgcxLz7T
This commit is contained in:
Claude
2026-12-05 16:43:24 +05:30
parent 8fa3c5d682
commit 508fed3b98
46 changed files with 1730 additions and 0 deletions
@@ -0,0 +1,36 @@
package com.ankurm.mcpapps;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.springframework.ai.mcp.annotation.McpResource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
/** The HTML views, served as ordinary MCP resources under the ui:// scheme. */
@Component
public class UiResources {
private final boolean unsafeRender;
public UiResources(@Value("${app.unsafe-render:false}") boolean unsafeRender) {
this.unsafeRender = unsafeRender;
}
@McpResource(uri = UiMeta.BOARD_URI, name = "inventory_board", description = "Stock board view",
mimeType = UiMeta.MIME_TYPE, metaProvider = UiMeta.BoardResource.class)
public String board() throws IOException {
// app.unsafe-render=true switches the view to innerHTML, to demonstrate script injection. Never ship that.
return load("ui/board.html").replace("__UNSAFE_RENDER__", Boolean.toString(unsafeRender));
}
@McpResource(uri = UiMeta.SDK_URI, name = "inventory_board_sdk", description = "Stock board view (ext-apps SDK)",
mimeType = UiMeta.MIME_TYPE, metaProvider = UiMeta.SdkResource.class)
public String sdkBoard() throws IOException {
return load("ui/board-sdk.html");
}
private static String load(String path) throws IOException {
return new ClassPathResource(path).getContentAsString(StandardCharsets.UTF_8);
}
}