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:
@@ -0,0 +1,37 @@
|
||||
# Raw Streamable HTTP against the Spring AI 2.1.0 server
|
||||
|
||||
## initialize: server capabilities
|
||||
{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"subscribe":false,"listChanged":true},"tools":{"listChanged":true}}
|
||||
|
||||
## tools/list: name and _meta of each tool
|
||||
restock_item _meta={"ui":{"visibility":["app"],"resourceUri":"ui://inventory/board.html"}}
|
||||
show_inventory _meta={"ui":{"visibility":["model","app"],"resourceUri":"ui://inventory/board.html"}}
|
||||
show_inventory_sdk _meta={"ui":{"visibility":["model","app"],"resourceUri":"ui://inventory/board-sdk.html"}}
|
||||
|
||||
## resources/list
|
||||
ui://inventory/board-sdk.html mimeType=text/html;profile=mcp-app _meta={"ui":{"prefersBorder":true,"csp":{"resourceDomains":["https://unpkg.com"]}}}
|
||||
ui://inventory/board.html mimeType=text/html;profile=mcp-app _meta={"ui":{"prefersBorder":true}}
|
||||
ui://probe/explicit.html mimeType=text/html;profile=mcp-app _meta={"ui":{"prefersBorder":true}}
|
||||
|
||||
## resources/templates/list (the {theme} probe lands here)
|
||||
ui://probe/{theme}.html
|
||||
|
||||
## resources/read ui://inventory/board.html
|
||||
mimeType=text/html;profile=mcp-app
|
||||
_meta={"ui":{"prefersBorder":true}}
|
||||
text starts: <!DOCTYPE html>
|
||||
|
||||
## resources/read ui://inventory/board-sdk.html
|
||||
mimeType=text/html;profile=mcp-app
|
||||
_meta={"ui":{"prefersBorder":true,"csp":{"resourceDomains":["https://unpkg.com"]}}}
|
||||
text starts: <!DOCTYPE html>
|
||||
|
||||
## resources/read ui://probe/dark.html
|
||||
mimeType=text/html;profile=mcp-app
|
||||
_meta=(absent)
|
||||
text starts: <!DOCTYPE html><title>dark</title>
|
||||
|
||||
## resources/read ui://probe/explicit.html
|
||||
mimeType=text/html;profile=mcp-app
|
||||
_meta=(absent)
|
||||
text starts: <!DOCTYPE html><title>explicit</title>
|
||||
@@ -0,0 +1,13 @@
|
||||
# show_inventory seen by two MCP Java SDK clients
|
||||
|
||||
## client that declares io.modelcontextprotocol/ui: content
|
||||
2 of 3 items are below their reorder level.
|
||||
|
||||
## client that does not: content
|
||||
2 of 3 items are below their reorder level.
|
||||
KB-01 Mechanical keyboard: 4 in stock, reorder at 10
|
||||
MN-27 27 inch monitor: 25 in stock, reorder at 8
|
||||
HB-04 USB4 hub: 0 in stock, reorder at 15
|
||||
|
||||
## structuredContent (same for both)
|
||||
{"items":[{"name":"Mechanical keyboard","reorderAt":10,"sku":"KB-01","stock":4},{"name":"27 inch monitor","reorderAt":8,"sku":"MN-27","stock":25},{"name":"USB4 hub","reorderAt":15,"sku":"HB-04","stock":0}]}
|
||||
@@ -0,0 +1,18 @@
|
||||
# restock_item, the tool the view calls back into
|
||||
|
||||
## tools/list from a client with no UI support
|
||||
[restock_item, show_inventory, show_inventory_sdk]
|
||||
|
||||
## restock_item sku=KB-01 quantity=10
|
||||
isError=false
|
||||
Restocked KB-01 by 10, now 14 in stock.
|
||||
|
||||
## restock_item sku=KB-01 quantity=500
|
||||
isError=true
|
||||
quantity must be between 1 and 100, got 500
|
||||
quantity must be between 1 and 100, got 500
|
||||
|
||||
## restock_item sku=ZZ-00 quantity=1
|
||||
isError=true
|
||||
unknown sku ZZ-00
|
||||
unknown sku ZZ-00
|
||||
@@ -0,0 +1,10 @@
|
||||
# Spring AI 2.1.0 SyncMcpToolCallbackProvider as the host
|
||||
|
||||
## tools offered to the model, no filter
|
||||
[restock_item, show_inventory, show_inventory_sdk]
|
||||
|
||||
## tools offered to the model, with VisibilityFilter
|
||||
[show_inventory, show_inventory_sdk]
|
||||
|
||||
## string that SyncMcpToolCallback hands back to the model for show_inventory
|
||||
[{"text":"2 of 3 items are below their reorder level.\nKB-01 Mechanical keyboard: 4 in stock, reorder at 10\nMN-27 27 inch monitor: 25 in stock, reorder at 8\nHB-04 USB4 hub: 0 in stock, reorder at 15"}]
|
||||
@@ -0,0 +1,34 @@
|
||||
# Hand-written view (board.html) in Chromium, AppBridge as the host, strict CSP
|
||||
|
||||
## rows after the tool result
|
||||
KB-01 Mechanical keyboard 4 +10
|
||||
MN-27 27 inch monitor 25 +10
|
||||
HB-04 USB4 hub 0 +10
|
||||
|
||||
## rows after clicking +10 on KB-01
|
||||
KB-01 Mechanical keyboard 14 +10
|
||||
MN-27 27 inch monitor 25 +10
|
||||
HB-04 USB4 hub 0 +10
|
||||
|
||||
status line: Restocked KB-01 by 10, now 14 in stock.
|
||||
|
||||
## host log (repeated size-changed lines removed)
|
||||
host: tool show_inventory -> ui://inventory/board.html, declared csp none
|
||||
view -> host: ui/notifications/sandbox-proxy-ready
|
||||
view -> host: ui/initialize
|
||||
view -> host: ui/notifications/initialized
|
||||
view -> host: ui/notifications/size-changed
|
||||
host: tool-input and tool-result delivered
|
||||
view -> host: tools/call restock_item {"sku":"KB-01","quantity":10} (id 2)
|
||||
view -> host: ui/update-model-context
|
||||
host: model context = The user restocked KB-01 by 10 from the stock board.
|
||||
|
||||
## probes run inside the view's frame
|
||||
read host page DOM: SecurityError
|
||||
fetch undeclared origin: TypeError: Failed to fetch
|
||||
fetch the MCP server directly: TypeError: Failed to fetch
|
||||
ui/message, content as one object (spec text): error -32602
|
||||
ui/message, content as an array (SDK types): ok
|
||||
eval(): EvalError
|
||||
fetch from the sandbox origin ('self'): TypeError
|
||||
fetch undeclared origin: TypeError
|
||||
@@ -0,0 +1,16 @@
|
||||
# SDK view (board-sdk.html), strict CSP
|
||||
|
||||
## with _meta.ui.csp.resourceDomains = [https://unpkg.com]
|
||||
KB-01 Mechanical keyboard: 4
|
||||
MN-27 27 inch monitor: 25
|
||||
HB-04 USB4 hub: 0
|
||||
host: tool show_inventory_sdk -> ui://inventory/board-sdk.html, declared csp {"resourceDomains":["https://unpkg.com"]}
|
||||
host: tool-input and tool-result delivered
|
||||
host: chat message = Which items should I reorder first?
|
||||
|
||||
## the same view when no domains are declared, 4 seconds later
|
||||
view shows: Waiting for the tool result…
|
||||
host: tool show_inventory_sdk -> ui://inventory/board-sdk.html, declared csp none
|
||||
view -> host: ui/notifications/sandbox-proxy-ready
|
||||
browser console:
|
||||
Loading the script 'https://unpkg.com/@modelcontextprotocol/[email protected]/dist/src/app-with-deps.js' violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
|
||||
@@ -0,0 +1,15 @@
|
||||
# A product name carrying <img onerror=...>, rendered two ways
|
||||
|
||||
## textContent (the shipped view)
|
||||
CB-99 row text: Cable <img src="x" onerror="parent.postMessage({jsonrpc:'2.0
|
||||
clicks by the user: 0
|
||||
tools/call sent by the view: none
|
||||
KB-01 stock on the server afterwards: 4
|
||||
|
||||
## innerHTML (app.unsafe-render=true)
|
||||
CB-99 row text: Cable
|
||||
clicks by the user: 0
|
||||
tools/call sent by the view:
|
||||
view -> host: tools/call restock_item {"sku":"KB-01","quantity":99} (id 666)
|
||||
KB-01 stock on the server afterwards: 103
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# The official ext-apps basic-host against the Spring AI server
|
||||
|
||||
tools offered in basic-host's tool list: ["show_inventory","show_inventory_sdk"]
|
||||
show_inventory, after clicking +10 on KB-01: Restocked KB-01 by 10, now 14 in stock.
|
||||
|
||||
probes in a view that declares no CSP domains:
|
||||
eval(): ALLOWED
|
||||
fetch from the sandbox origin ('self'): ALLOWED
|
||||
fetch undeclared origin: TypeError
|
||||
|
||||
basic-host Model Context panel shows: The user restocked KB-01 by 10 from the stock board.
|
||||
|
||||
show_inventory_sdk renders: KB-01 Mechanical keyboard: 14 | MN-27 27 inch monitor: 25 | HB-04 USB4 hub: 0
|
||||
|
||||
initialize sent by basic-host: {"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"MCP Apps Host","version":"1.0.0"}}
|
||||
methods basic-host sent while loading and running the first tool: initialize, notifications/initialized, tools/list, resources/list, tools/call, resources/read
|
||||
@@ -0,0 +1,24 @@
|
||||
# Strings searched in every class file: mcp-app | io.modelcontextprotocol/ui | McpUi | ui://
|
||||
mcp-spring-webmvc-2.1.0.jar: 0 class files match
|
||||
spring-ai-autoconfigure-mcp-client-common-2.1.0.jar: 0 class files match
|
||||
spring-ai-autoconfigure-mcp-client-httpclient-2.1.0.jar: 0 class files match
|
||||
spring-ai-autoconfigure-mcp-server-common-2.1.0.jar: 0 class files match
|
||||
spring-ai-autoconfigure-mcp-server-webmvc-2.1.0.jar: 0 class files match
|
||||
spring-ai-mcp-annotations-2.1.0.jar: 0 class files match
|
||||
spring-ai-mcp-2.1.0.jar: 0 class files match
|
||||
spring-ai-starter-mcp-client-2.1.0.jar: 0 class files match
|
||||
spring-ai-starter-mcp-server-webmvc-2.1.0.jar: 0 class files match
|
||||
mcp-core-2.2.0.jar: 0 class files match
|
||||
|
||||
# javap: what the Java SDK does offer, a generic extensions map
|
||||
public java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Object>> extensions();
|
||||
|
||||
# javap: the attributes of @McpTool in spring-ai-mcp-annotations 2.1.0
|
||||
java.lang.String name();
|
||||
java.lang.String description();
|
||||
org.springframework.ai.mcp.annotation.McpTool$McpAnnotations annotations();
|
||||
boolean generateOutputSchema();
|
||||
java.lang.String title();
|
||||
java.lang.Class<? extends org.springframework.ai.mcp.annotation.context.MetaProvider> metaProvider();
|
||||
org.springframework.ai.mcp.annotation.McpIcon[] icons();
|
||||
org.springframework.ai.mcp.annotation.McpClientCapability[] requiredCapabilities();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user