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
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Writes output/08: builds the official ext-apps basic-host, points it at this server and drives it in Chromium.
# Needs the jar (mvn -pl mcp-apps package) and harness/node_modules (npm install in harness/).
set -euo pipefail
MODULE="$(cd "$(dirname "$0")/.." && pwd)"
WORK="$(mktemp -d)"
git clone -q https://github.com/modelcontextprotocol/ext-apps.git "$WORK/ext-apps"
git -C "$WORK/ext-apps" checkout -q 87bcdc8
cp -r "$WORK/ext-apps/examples/basic-host" "$WORK/basic-host"
cd "$WORK/basic-host"
sed -i 's/"@modelcontextprotocol\/ext-apps": "\^2.1.0"/"@modelcontextprotocol\/ext-apps": "2.0.4"/' package.json
npm install --silent
npm install --silent tsx
INPUT=index.html npx vite build >/dev/null
INPUT=sandbox.html npx vite build >/dev/null
java -jar "$MODULE/target/mcp-apps.jar" --spring.profiles.active=browserhost --logging.level.root=warn &
JAVA_PID=$!
SERVERS='["http://localhost:3001/mcp"]' node_modules/.bin/tsx serve.ts &
HOST_PID=$!
trap 'kill $JAVA_PID $HOST_PID 2>/dev/null || true' EXIT
sleep 15
cd "$MODULE/harness" && node basic-host.mjs
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Writes output/09: does anything in the MCP jars of Spring AI 2.1.0 or the Java SDK 2.2.0 know about MCP Apps?
set -euo pipefail
cd "$(dirname "$0")/.."
M="${M2_REPO:-$HOME/.m2/repository}"
TMP="$(mktemp -d)"
OUT=output/09-jar-search.txt
{
echo "# Strings searched in every class file: mcp-app | io.modelcontextprotocol/ui | McpUi | ui://"
for jar in "$M"/org/springframework/ai/*mcp*/2.1.0/*-2.1.0.jar "$M"/io/modelcontextprotocol/sdk/mcp-core/2.2.0/mcp-core-2.2.0.jar; do
dir="$TMP/$(basename "$jar" .jar)"
mkdir -p "$dir" && unzip -q -o "$jar" -d "$dir"
echo "$(basename "$jar"): $( { grep -rlaE 'mcp-app|io\.modelcontextprotocol/ui|McpUi|ui://' "$dir" || true; } | wc -l) class files match"
done
echo
echo "# javap: what the Java SDK does offer, a generic extensions map"
javap -cp "$M/io/modelcontextprotocol/sdk/mcp-core/2.2.0/mcp-core-2.2.0.jar" 'io.modelcontextprotocol.spec.McpSchema$ClientCapabilities' 2>/dev/null | grep -E 'extensions\(\)' | sed 's/^ *//'
echo
echo "# javap: the attributes of @McpTool in spring-ai-mcp-annotations 2.1.0"
javap -cp "$M/org/springframework/ai/spring-ai-mcp-annotations/2.1.0/spring-ai-mcp-annotations-2.1.0.jar" org.springframework.ai.mcp.annotation.McpTool 2>/dev/null | grep abstract | sed -E 's/^ *public abstract //'
} > "$OUT"
rm -rf "$TMP"
cat "$OUT"
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Regenerates output/01-07. Needs JDK 25, Maven, Node 20+ and Chromium (set CHROMIUM_PATH to use an installed one,
# otherwise run "npx playwright install chromium" inside harness/ first). output/08 comes from scripts/basic-host.sh.
set -euo pipefail
cd "$(dirname "$0")/.."
mvn -q -B -f ../pom.xml -pl mcp-apps clean package # tests write output/01-04
cd harness
npm install --silent
node run.mjs # writes output/05-07 and two screenshots
../scripts/jar-search.sh # writes output/09