Mastra 发布 @mastra/mcp 2.0,支持无会话的 MCP 新规范
Mastra 表示 @mastra/mcp 2.0.0 已支持 MCP 2026-07-28 规范,该规范移除了 initialize 握手(SEP-2575)以及包括 Mcp-Session-Id 头在内的协议级会话(SEP-2567),使每个请求都自包含。Mastra 称,用它构建的 MCP 服务器现在可以跨负载均衡实例运行,也可以部署在可缩容至零的 serverless 平台上;此前会话会将客户端固定到签发会话 ID 的那个实例,负载均衡后请求若被路由到其他实例就可能出现 400 session not found 错误,变通方案是粘性会话或 Redis 之类的共享会话存储。文章还介绍了新增的 Mcp-Method 与 Mcp-Name 请求头、列表结果的缓存提示、server/discover 方法,以及在调用中途向用户提问的 requestState;tasks 现为正式扩展但 Mastra 仍在研究支持,规范还弃用了 HTTP+SSE 传输、roots、sampling、logging 和 OAuth 动态客户端注册,而 @mastra/mcp 2.0 已移除这些功能。
按 Mastra 的说法,无会话请求让扩展 Mastra 构建的 MCP 服务器时不再需要粘性会话或共享会话存储,从而可以像普通 HTTP 服务一样扩展。
Mastra now supports the MCP 2026-07-28 specification with @mastra/mcp ^2.0.0. The new spec removes server sessions, so every request is self-contained. If you build MCP servers with Mastra, you can now scale them like any other HTTP service, across load-balanced instances, or on serverless platforms that scale to zero.
How MCP 1.0 worked
In the previous MCP spec, a client opened every connection with an initialize request. The server created a session, sent back a session ID, and every following request had to include it.
This pinned the client to whichever server instance issued the session. If you ran multiple servers behind a load balancer, a request could be routed to an instance that didn't recognize the session ID, resulting in 400 session not found errors.
The workarounds were sticky sessions or a shared session store like Redis. Both solutions worked, but they added complexity, latency, and potentially cost.
Your browser does not support the video tag.