Skip to content

Let the client HTTP transports use a caller-supplied HTTP client, so a connection can be pinned to a checked IP #1359

Backlog

Description

@Vishnuujain
  • Problem: we call MCP servers at user-configured URLs. To block SSRF we resolve the host, reject private or internal IPs, and then must connect to that same IP. Otherwise a DNS change between the check and the connect gets around it. The transports take only a JDK HttpClient.Builder, and JDK HttpClient has no per-client DNS hook; only the JVM-wide resolver SPI exists (https://openjdk.org/jeps/418).
  • Ask: let HttpClientStreamableHttpTransport and the modern HttpClientMcpTransport take a pluggable HTTP layer, e.g. a small interface that sends a request and streams the response, so callers can plug in OkHttp, Apache or Netty with their own DNS. The Python SDK already accepts an httpx client and the Kotlin SDK a ktor HttpClient, which is how we pin the IP there.
  • Workarounds we looked at: an egress proxy through clientBuilder.proxy (extra infrastructure); Spring AI's WebClient transport (pulls WebFlux into a non-Spring app); our own McpClientTransport (re-implements the transport). Code at 81aed21: https://github.com/modelcontextprotocol/java-sdk/blob/81aed21/mcp-core/src/main/java/io/modelcontextprotocol/client/transport/HttpClientStreamableHttpTransport.java#L709-L725

Activity

  1. changed the title [-]Client HTTP transports can't pin a connection to a checked IP address[/-] [+]Let the client HTTP transports use a caller-supplied HTTP client, so a connection can be pinned to a checked IP[/+] on Nov 30, 2026
  2. yuT7-blue commented on Dec 1, 2026

    @yuT7-blue

    I'm interested in investigating this issue and potentially contributing a solution.

    My initial understanding is that both HTTP transports are tied to the JDK HttpClient, which limits the ability to use custom DNS resolution.

    Would introducing a small, pluggable HTTP abstraction that supports asynchronous requests and streaming responses be an acceptable direction?

    I'd appreciate the maintainers' feedback before proceeding with the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions