-
Notifications
You must be signed in to change notification settings - Fork 456
Open
Description
Hi,
I have been struggling to work out how to pass information from my http server (axum) for use it tools. After a few hours of digging I found how to get the HTTP headers in the tool (#365), specifically, I can get the mcp-session-id. For those wanting a example you can use this code:
#[tool(description = "Example tool")]
async fn example_tool(&self, ctx: RequestContext<RoleServer>) -> Result<CallToolResult, rmcp::ErrorData> {
let parts = ctx.extensions.get::<axum::http::request::Parts>().unwrap();
let mcp_session_id = parts.headers.get("mcp-session-id").unwrap().to_str().unwrap();
todo!("do something with the mcp-session_id")
}Is there a way to pass something that is in Axum extensions to the extensions in the RequestContext of the tool? They appear to separate. I might be missing something obvious but any help is appreciated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels