-
Notifications
You must be signed in to change notification settings - Fork 575
Open
Description
How can I retrieve information carried in the request (such as headers and client IP) from McpSyncServerExchange
or McpAsyncServerExchange
? I'm using HttpServletSseServerTransportProvider
and need to log client IPs calling MCP services while monitoring traffic. Currently I modified the 0.10.0 SDK source as follows: Made McpAsyncServerExchange.getSession()
public, McpServerSession.getTransport()
public, and HttpServletMcpSessionTransport.getAsyncContext()
public to implement:
/**
* Retrieves client IP from exchange
* @param exchange {@link McpSyncServerExchange}
* @return IP address
*/
private String getClientIp(McpSyncServerExchange exchange) {
var session = exchange.getExchange().getSession();
var transport = (HttpServletMcpSessionTransport) session.getTransport();
var context = transport.getAsyncContext();
var request = (HttpServletRequest) context.getRequest();
return NetUtils.getClientIpAddress(request);
}
But this approach feels hacky ("Monkey patch"). Are there plans to expose request context access during server-side processing in future versions?
Metadata
Metadata
Assignees
Labels
No labels