稻草人新闻RSS 聚合阅读

← 返回 💻 编程 & 软件工程

WebMCP support now available in mcp-handler

Vercel News Andrew Qu 9月18日 vercel.com

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.

Contributors

Ben Sabic

在原文站打开 ↗

Cloudflare Workers 每 3 分钟抓一批,9 批轮完最快约 27 分钟 · 点右上 ↻ 立刻全量抓一次