-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Metadata Context #61
Comments
Is this looks good to you? I want to know your opinion! |
Awesome, I'll take a look now! |
Ok, my basic response is that I think the metadata should be always available on the
Let me know if that doesn't make sense |
@EItanya I do prefer an interface like this but it would be a challange for serialization and deserialization since the |
Is this a requirement, or a current implementation detail. Is meta part of the spec, I haven't seen it. Leaving aside the specific implementation for one second, typically metadata features like this are implemented alongside the protocol, rather than inside of it. For example, in this case the From reading the code, it seems like currently the metadata is being encoded into the I'll give you a concrete example. Let's say I was using
The code above is of course just for example, but notice the message metadata pairing. This could of course be an optional channel type for advanced use-cases. |
|
Ohhh, interesting, I didn't realize there was meta as part of the spec, that's good to know. In that case I agree with what you said: Can you expand on this:
|
@EItanya Are you familiar with Rust's |
So I looked into it a bit, and I'm not quite sure how this would help me. I have an Axum SSE server very similar to the example one, and I need to send metadata from the post request into the server handler. I could parse the message and perform some logic before sending it along, but that feels like a waste, so I'd rather perform all necessary checks/logic in the handler. Specifically I want to perform RBAC based on the tool_name using the claims extracted from the bearer token. |
@EItanya I mean, if we have some thing like |
Ahh yea, that would be perfect |
Update, in #56 you can add custom extensions for request and notification now. |
I would also really appreciate to get the request headers somehow in the service calls. We have a need to forward the headers as-is to the underlying service from the mcp proxy. Is this somehow already possible? I was reading the code, but it's not super easy to inject the headers from the axum routes to the service endpoints currently... |
@pimeys soon we will support it |
@4t145, the extensions changes in your PR are separate from the protocol update. Do you think we can pull it into its own PR? I can help if you'd like |
@EItanya We can remove the streamable http part and merge it. And implement streamable http transport later. |
That would be perfect |
First off I just want to say that this library is awesome, and I'm really glad you created it!
Is your feature request related to a problem? Please describe.
I am developing a server using this library in which I want to perform certain logic based on the identity of the client. For example, the client is using
sse
or the newstreamable HTTP
protocol, and there is a Bearer token present in the request which I need when performing the logic in the server.The function
call_tool
for example currently has the following signature:The
context
has information about the client, but it's limited to exactly what's in the spec. It would be very useful if a consumer of this library could also include some generic metadata struct to pass information from the source of the request into the handlers.Describe the solution you'd like
The metadata source could take many forms:
HashMap<String, serde_json::Value>
to allow for generic json values.I haven't dug too deep into the exact solution, but I think this would have to live on the sink/stream layer, for example instead of a
tokio::sync::mpsc::Sender<ClientJsonRpcMessage>
it might need to betokio::sync::mpsc::Sender<Option<Metadata>, ClientJsonRpcMessage>
or something like that. Thereby allowing the user to control it.Describe alternatives you've considered
Another alternative I considered is attempting to add a generic metadata mechanism to the upstream protocol. However I don't think that's actually necessary. All of the protocols already have ways of passing metadata back and forth, so all that's needed is a way within the library itself to access it.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: