MCP 应用允许一个支持 MCP 的 AI 应用,也称为主机,在其对话中打开路由的 webforJ 视图。该视图仍然是 Java 应用的一部分,因此使用与浏览器中相同的组件、服务、路由和状态。
人和 AI 可以在相同的实时用户界面中工作。当打开视图时,AI 可以提供输入,调用更改开放视图的操作,并根据用户在 UI 中所做的选择接收上下文。用户可以继续直接使用渲染的 webforJ 组件。
使用 Spring Boot 和 Spring AI 是发布 MCP 应用的主要方式。集成会发现标记的路由并将其添加到 Spring AI 的 MCP 服务器。首先从 Spring Boot 设置 开始,然后使用最小的发布视图 测试连接。不使用 Spring Boot 的应用可以改用 标准 Servlet 设置。
MCP 应用是 MCP 规范的一项不断发展的扩展,因此主机以自己的节奏采纳其修订和安全政策。应用声明其加载和连接的视图来源,允许它们的主机会呈现该视图。主机也可以施加更严格的政策。打开工具始终返回其文本内容,路由仍然作为常规浏览器页面可用。请通过 测试 中的步骤验证每个目标主机。
主题
Spring Boot MCP 应用
Build and publish a routed webforJ view as an MCP App with Spring Boot and Spring AI.
测试 MCP 应用
Test a webforJ MCP App with an MCP Apps-capable host, including the Codex app, Claude Desktop, and MCPJam.
使用输入打开视图
Accept structured opening input in a routed MCP App and choose its requested display mode.
为已打开的视图添加工具
Add tools that work with an MCP App already open in the current conversation.
使用 MCP 客户端
Connect a rendered webforJ view to its MCP client.
配置 MCP 应用
Configure the public app origin, allowed embedding clients, and external browser domains.
标准 webforJ 设置
Assemble an MCP server and register webforJ MCP Apps in a standard servlet-based webforJ application.