You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MCP protocol specification includes a _meta parameter that allows
clients to pass request-specific metadata. This commit adds automatic
extraction of this parameter and makes it available to tools and prompts
as a nested field within server_context.
Key changes:
- Extract _meta from request params in call_tool and get_prompt methods
- Pass _meta as a nested field in server_context (server_context[:_meta])
- Only create context when there's either server_context or _meta present
- Add comprehensive tests for _meta extraction and nesting
- Update documentation with _meta usage examples and link to spec
This maintains compatibility with TypeScript and Python SDKs which also
nest _meta within the context rather than merging it at the top level.
Copy file name to clipboardExpand all lines: README.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,6 +286,50 @@ server = MCP::Server.new(
286
286
287
287
This hash is then passed as the `server_context` argument to tool and prompt calls, and is included in exception and instrumentation callbacks.
288
288
289
+
#### Request-specific `_meta` Parameter
290
+
291
+
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`.
292
+
293
+
**Access Pattern:**
294
+
295
+
When a client includes `_meta` in the request params, it becomes available as `server_context[:_meta]`:
0 commit comments