Repository navigation
feat: Pass CallContext (with Request data) to MCP Tool invocation - #50
Conversation
CallContext (with Request data) to MCP Tool invocationCallContext (with Request data) to MCP Tool invocation
Agree 👍
Agree 👍
I thought about this too, and while I like the simplicity about it, otoh I think it provokes error-prone usages. WDYT? |
1e1e668 to
8bc9807
Compare
8bc9807 to
1779f4a
Compare
|
Yeah, that makes total sense actually. I didn’t think of the stdio + nullable mismatch that could easily sneak in. I’m with you, let’s stick with the Context object. It’s cleaner and future-proof too. Go ahead 💪🏽 |
|
|
||
| namespace PhpMcp\Server\Tests\Unit; | ||
|
|
||
| use Grpc\Call; |
There was a problem hiding this comment.
Not used. It's probably accidental. Let’s remove this.

Requirement
In the context of the MCP Tool execution I would need access to the
Authorizationheader being sent with the HTTP request.My MCP Tool will further facilitate an SDK/API for which the authentication data is required.
Implementation
CallContextobject, which can hold also further properties in futureCallContextproperty on MCP Tool methods is not exposed in the MCP protocol (seeDiscovery)CallContextinstance is automatically passed to the method invocation if present in method signatureRemarks:
.php-cs-fixer.phpconfig file in the repo, but it is defined in thecomposer lintcommand 🤷Open Todos
(Please let me know your thoughts, then I will continue with the missing tests)
Example