V
vercel-labs/mcp-handler
MCP server helper for Next.js, Nuxt and Svelte
在 GitHub 查看 ↗链接已于 2026-11-12 核查 · HTTP 200 · 打开的是厂商自己的官网
我们没有从该仓库取到可核对的安装命令,也没有公开的远端端点。这两样都没有时,我们不出配置——编一条出来比不给更糟。 各客户端的接法 →
- 来源明细
- 收录自 abordage/awesome-mcp 榜单(我们从中收集的条目之一) · 条目类型:MCP 服务
- 收录与活跃
- 收录于 2026-11-05 · 最近见到 2026-11-14 · 共见到 10 次 · 被 10 个来源列出
- 评分构成
- 综合分 1,003 · 10 个来源 · mcp
常见问题(答案都来自我们的记录)
它适合谁 / 用来做什么?
我们把它归在这些标签下: MCP 服务。标签来自条目自身,不是我们强加的分类。
谁维护它、还在更新吗?
我们收录于 2026-11-05;最近见到 2026-11-14。这里没有"官方认证"或"质量评级"——我们只记录来源与时间。
# mcp-handler
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
mcp-handler is a framework-agnostic HTTP adapter for hosting Model Context Protocol (MCP) servers in JavaScript and TypeScript applications. It turns an MCP server definition into a Web-standard (Request) => Promise handler that can be mounted in Next.js, Nuxt/Nitro, SvelteKit, Hono, and other Fetch-compatible frameworks.
Built on MCP SDK v2, it serves the 2026-07-28 MCP specification natively while transparently falling back to stateless Streamable HTTP for 2025-era clients — one handler, both protocol generations.
## Installation
bash
npm install mcp-handler@^2 @modelcontextprotocol/server@^2 zod@^4
> Note: mcp-handler 2.x requires the MCP SDK v2 packages (@modelcontextprotocol/server ^2.0.0), zod ^4.2.0, and Node.js 20+. If you're on @modelcontextprotocol/sdk 1.x, use mcp-handler 1.x.
## Framework Compatibility
createMcpHandler returns a Web-standard request handler, so the package is not tied to Vercel or any particular framework. It can be mounted in:
Next.js Route Handlers
Nuxt/Nitro server handlers using fromWebHandler
SvelteKit server routes
Hono routes using c.req.raw
Other frameworks that expose Fetch-compatible Request and Response APIs
Frameworks based on Node.js IncomingMessage and ServerResponse, such as Express, require a Web Request adapter or the official MCP framework middleware.
## Quick Start (Next.js)
typescript
// app/api/mcp/route.ts
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";
const handler = createMcpHandler((server) => {
server.registerTool(
"rolldice",
title: "Roll Dice",
description: "Roll a dice with a specified number of sides.",
inputSchema: z.object({
sides: z.number().int().min(2),
}),
},
async ({ sides }) => {
const value = 1 + Math.floor(Math.random() sides);
return {
content: [{ type: "text", text: 🎲 You rolled a ${value}! }],
};
},
);
});
export { handler as GET, handler as POST };
/api/mcp is a convention, not a required path. mcp-handler does not inspect
the request pathname, so you can place this handler at any framework route and
give clients that route's complete URL.
## Connecting Clients
If your client supports Streamable HTTP, connect directly:
json
"remote-example": {
"url": "http://localhost:3000/api/mcp"
For stdio-only clients, use mcp-remote:
json
"remote-example": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3000/api/mcp"]
## Protocol Support
2026-07-28 (current): served natively — stateless, no sessions, per-request meta envelope, server/discover.
2025-era Streamable HTTP: served via the SDK's stateless legacy fallback from the same handler. GET/DELETE session operations answer 405 (serving is stateless).
HTTP+SSE transport (2024-11-05): removed in 2.x. Mount only the Streamable HTTP handler; unmounted /sse and /message paths are handled by your framework. Redis is no longer needed or used.
### Authorization (CIMD era)
The 2026-07-28 spec deprecates Dynamic Client Registration (DCR) in favor of Client ID Metadata Documents (CIMD), where the OAuth client identifies itself with an HTTPS URL that serves its metadata. CIMD support is advertised and implemented by your authorization server (clientidmetadatadocumentsupported in its RFC 8414 metadata); this package keeps your MCP server's resource-server surface up to date:
Built on MCP SDK v2, it serves the 2026-07-28 MCP specification natively while transparently falling back to stateless Streamable HTTP for 2025-era clients — one handler, both protocol generations.
## Installation
bash
npm install mcp-handler@^2 @modelcontextprotocol/server@^2 zod@^4
> Note: mcp-handler 2.x requires the MCP SDK v2 packages (@modelcontextprotocol/server ^2.0.0), zod ^4.2.0, and Node.js 20+. If you're on @modelcontextprotocol/sdk 1.x, use mcp-handler 1.x.
## Framework Compatibility
createMcpHandler returns a Web-standard request handler, so the package is not tied to Vercel or any particular framework. It can be mounted in:
Next.js Route Handlers
Nuxt/Nitro server handlers using fromWebHandler
SvelteKit server routes
Hono routes using c.req.raw
Other frameworks that expose Fetch-compatible Request and Response APIs
Frameworks based on Node.js IncomingMessage and ServerResponse, such as Express, require a Web Request adapter or the official MCP framework middleware.
## Quick Start (Next.js)
typescript
// app/api/mcp/route.ts
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";
const handler = createMcpHandler((server) => {
server.registerTool(
"rolldice",
title: "Roll Dice",
description: "Roll a dice with a specified number of sides.",
inputSchema: z.object({
sides: z.number().int().min(2),
}),
},
async ({ sides }) => {
const value = 1 + Math.floor(Math.random() sides);
return {
content: [{ type: "text", text: 🎲 You rolled a ${value}! }],
};
},
);
});
export { handler as GET, handler as POST };
/api/mcp is a convention, not a required path. mcp-handler does not inspect
the request pathname, so you can place this handler at any framework route and
give clients that route's complete URL.
## Connecting Clients
If your client supports Streamable HTTP, connect directly:
json
"remote-example": {
"url": "http://localhost:3000/api/mcp"
For stdio-only clients, use mcp-remote:
json
"remote-example": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3000/api/mcp"]
## Protocol Support
2026-07-28 (current): served natively — stateless, no sessions, per-request meta envelope, server/discover.
2025-era Streamable HTTP: served via the SDK's stateless legacy fallback from the same handler. GET/DELETE session operations answer 405 (serving is stateless).
HTTP+SSE transport (2024-11-05): removed in 2.x. Mount only the Streamable HTTP handler; unmounted /sse and /message paths are handled by your framework. Redis is no longer needed or used.
### Authorization (CIMD era)
The 2026-07-28 spec deprecates Dynamic Client Registration (DCR) in favor of Client ID Metadata Documents (CIMD), where the OAuth client identifies itself with an HTTPS URL that serves its metadata. CIMD support is advertised and implemented by your authorization server (clientidmetadatadocumentsupported in its RFC 8414 metadata); this package keeps your MCP server's resource-server surface up to date:
收录徽章(可选)
想把收录标记放进 README 就复制这行,可选,不影响收录。
[](https://anclum.com/zh/s/vercel-labs-mcp-handler/)
- 来源
- awesome · https://github.com/vercel-labs/mcp-handler
- 按领域浏览
- MCP 服务
- 收录来源
- 10 个独立来源
- 收录于
- 今天
同类推荐
所属领域与标签
每个标签都能点进去看同类的全部条目。数字是当前库里的真实条数。