mcp-handler 現已支援 WebMCP
WebMCP support now available in mcp-handler
mcp-handler 現已支援 WebMCP,允許開發者透過單一 script 標籤將 MCP 工具直接注入瀏覽器,並以已登入使用者身分代理呼叫。
- 功能:WebMCP 讓 MCP 工具可在瀏覽器中使用,省去 OAuth 流程。
mcp-handler now has experimental support for WebMCP, the proposed web standard for exposing tools to in-browser agents. Add a single script tag to your site, and your existing MCP tools become available there too.
Opt tools in by adding them to the experimental_webMcp object:
app/api/mcp/route.ts
import { createMcpHandler } from "mcp-handler";
const handler = createMcpHandler(
(server) => {
server.registerTool("roll_dice", /* ... */);
},
{
experimental_webMcp: {
tools: ["roll_dice"],
},
},
);
export { handler as GET, handler as POST };
Then load the script from your MCP endpoint with the ?webmcp-script parameter:
<script src="/api/mcp?webmcp-script"></script>
The script registers those tools with the page and proxies each call back to your MCP server as the signed-in user, so authenticated tools work without a browser-side OAuth flow.
Upgrade to mcp-handler@2.2.0 and read the documentation to get started.
來源:Vercel Blog · vercel.com