New Features
mcp — Opt-in HTTP request metadata bridge for tool handlers (#5550)
Added WithRequestMetadataExtractor option to the MCP server. When set, HTTP request metadata (headers, query parameters, path variables) is captured and injected into each handler's context.Context. Handlers retrieve it via the provided context helpers:
server := mcp.NewMcpServer(conf, mcp.WithRequestMetadataExtractor(mcp.DefaultRequestMetadataExtractor))
server.AddTool(tool, func(ctx context.Context, req *mcp.ServerRequest) (*mcp.ToolResult, error) {
tenantID, _ := mcp.HeaderFromContext(ctx, "X-Tenant-ID")
userID, _ := mcp.QueryFromContext(ctx, "user_id")
// ...
})Available helpers: RequestMetadataFromContext, HeaderFromContext, QueryFromContext, PathFromContext. Fully backward-compatible — existing NewMcpServer(c) calls are unaffected.
Bug Fixes
discov — Go 1.26 etcd URI compatibility (#5548)
Go 1.26 enforces strict RFC 3986 URI parsing and rejects comma-separated hosts in the URI authority component. BuildDiscovTarget was producing URIs in the form etcd://host1:2379,host2:2379/key, which broke all gRPC services using etcd service discovery with multiple endpoints on Go 1.26+.
The etcd target URL format has been updated to place hosts in the path and the etcd key in a query parameter:
# Before (breaks Go 1.26):
etcd://host1:2379,host2:2379/my-service-key
# After (RFC 3986 compliant, works on all Go versions):
etcd:///host1:2379,host2:2379?key=my-service-key
discov — Unbounded memory growth on duplicate etcd PUT events (#5580)
Fixed two related bugs in discov that caused memory to grow without bound in long-running zRPC services:
- Redundant
OnAddcalls:handleWatchEventscalledOnAddon every etcdPUTevent regardless of whether the value changed (e.g. lease refreshes, watch reconnects). Duplicate PUTs are now skipped; value changes fireOnDelete(old)followed byOnAdd(new)to keep listeners consistent. - Unbounded slice growth in
addKv: Keys were appended to the internalcontainer.valuesslice unconditionally, causing a single etcd key to accumulate thousands of duplicates over time.addKvnow returns early for exact duplicates, and cleans up stale entries when a key moves to a new server address.
New Contributors
- @caltechustc made their first contribution in #5596
Full Changelog: v1.10.1...v1.10.2