From 8d123fb8f27e5b7e0afb0b7655339d879686e624 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Fri, 5 Jun 2026 01:24:25 +0900 Subject: [PATCH] [Doc] Clarify `server_context` Hash requirement for `_meta` merging ## Motivation and Context The README documents that request-level `_meta` becomes available to tools and prompts under `server_context[:_meta]`. However, `Server#server_context_with_meta` only merges `_meta` when `server_context` is a `Hash` (or `nil`, in which case a new `{ _meta: ... }` hash is synthesized). When a non-`Hash` value is assigned to `server_context`, `_meta` is silently dropped and tools will not see it under `server_context[:_meta]`. This adds a note clarifying that `server_context` must be kept as a `Hash` if tools need access to `_meta`. ## How Has This Been Tested? Documentation-only change, no behavioral modification. ## Breaking Changes None. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index bdf0bd7d..478fe823 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,11 @@ See the relevant sections below for the arguments they receive. The MCP protocol supports a special [`_meta` parameter](https://modelcontextprotocol.io/specification/2025-06-18/basic#general-fields) in requests that allows clients to pass request-specific metadata. The server automatically extracts this parameter and makes it available to tools and prompts as a nested field within the `server_context`. +> [!NOTE] +> `_meta` is only merged when `server_context` is a `Hash` (or `nil`, in which case a new `{ _meta: ... }` hash is synthesized). +> If you assign a non-`Hash` value to `server_context`, `_meta` is not merged and tools will not see it +> under `server_context[:_meta]`. Keep `server_context` as a `Hash` if your tools need access to `_meta`. + **Access Pattern:** When a client includes `_meta` in the request params, it becomes available as `server_context[:_meta]`: