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
Is your feature request related to a problem? Please describe.
I'd like to implement a generic handler, for this I'm registering programmatically a few tools and resources. Basically a tool gets registered like this:
yield [
'type' => 'resource',
'definition' => [
'handler' => self::HANDLER,
'uri' => $uri,
'name' => $mcpName,
'description' => $operation->getDescription(),
],
];
// later we decorate the server builder and add them
I'd like for the handler to be aware of a few of these parameters. Currently the CallToolHandler does:
Add an interface ContextAwareHandlerInterface, userland can implement this and the sdk calls withContext on the handler
Use a closure as a handler that has use ($toolName) and then to call the handler with that argument and the actual arguments of the tool (closures are hard to cache for now and need to be hold in memory at rutime, opposed to an array-callable)
declare one service per toolName (which overloads the container for no reason)
Additional context
As I needed that I thought that maybe others will. I'm willing to contribute to a patch if one of the proposed alternatives is considered.
Activity
[-]Handler context[/-][+][Server] Handler context[/+]chr-hertel commentedon Oct 20, 2025
Is context only
toolNameor basically the entireTool&Requestobject?Can you check if partially reverting #100 would help with your situation?
cc @CodeWithKyrian
soyuka commentedon Oct 24, 2025
Probably that #111 helps with that I'll report back once I'm done with that part.
CodeWithKyrian commentedon Oct 25, 2025
Still doesn't does it?
soyuka commentedon Oct 25, 2025
With the registry loader I now have access to the registry it may help I need to try this.
chr-hertel commentedon Jan 23, 2026
Hey @soyuka, can we close here? your use case covered or still sth to follow up on?
soyuka commentedon Jan 24, 2026
Completely resolved! For anyone interested in how I did check out api-platform/core#7595
rvanlaak commentedon Jan 24, 2026
Exciting, congrats! Any ETA when a RC of APIP 4.3 could be expected?