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
{{ message }}
Repository navigation
[Server] Expose request-level metadata (e.g., securitySchema) to tool handlers #159
Is your feature request related to a problem? Please describe.
Tool handlers currently receive only the parameters defined for the tool call.
Metadata included in the request envelope (for example a securitySchema) is not available inside the handler.
This makes it impossible to perform logic that depends on contextual information from the request itself.
Describe the solution you’d like
A way for tool handlers to access the metadata from the incoming request envelope.
This could be done by injecting either the full request object or just the meta section into the handler method.
Having this information available would allow tools to perform authorization checks, tenant selection, and similar context-dependent actions.
Describe alternatives you’ve considered
The only workaround at the moment is extracting envelope metadata before the request reaches the tool dispatching layer and storing it somewhere manually.
Once inside the handler, that information can no longer be accessed in a clean or reliable way.
Additional context
A common use case is reading a securitySchema sent by the client.
This information is part of the envelope, not part of the tool parameters, and is therefore currently inaccessible inside tool logic.
What tool handlers currently look like
useMCP\Server\Attributes\McpTool;
finalclass ExampleTools
{
#[McpTool(name: 'example_action')]
publicfunctionexampleAction(string$input): array
{
// Only defined parameters are available.// Envelope metadata (e.g., securitySchema) cannot be accessed here.return ['result' => 'ok'];
}
}
changed the title [-]Expose request-level metadata (e.g., securitySchema) to tool handlers[/-][+][Server] Expose request-level metadata (e.g., securitySchema) to tool handlers[/+]on Nov 21, 2025
Yup, sounds valid to me, thankts @AgentSlim for raising this!
My first idea was to bring in a Metadata class that is part of the schema and we could use for type hinting and then provide based on the signature of the handler, similar to option b:
This is possible now with RequestContext (#176) - type hint it in your handler and use $context->getRequest()->getMeta(). Closing - please reopen if I got your use case wrong @AgentSlim.
Activity
[-]Expose request-level metadata (e.g., securitySchema) to tool handlers[/-][+][Server] Expose request-level metadata (e.g., securitySchema) to tool handlers[/+]chr-hertel commentedon Nov 21, 2025
Yup, sounds valid to me, thankts @AgentSlim for raising this!
My first idea was to bring in a
Metadataclass that is part of the schema and we could use for type hinting and then provide based on the signature of the handler, similar to option b:chr-hertel commentedon Oct 19, 2026
This is possible now with
RequestContext(#176) - type hint it in your handler and use$context->getRequest()->getMeta(). Closing - please reopen if I got your use case wrong @AgentSlim.