Skip to content

Cannot connect to Agent Gateway with Java MCP client using SSE #166

@murphye

Description

@murphye

I have a problem connecting Java MCP client to Agent Gateway using SSE.

The official MCP Java client sets an Accept header of text/event-stream.

			HttpRequest request = requestBuilder.copy()
				.uri(Utils.resolveUri(this.baseUri, this.sseEndpoint))
				.header("Accept", "text/event-stream")
				.header("Cache-Control", "no-cache")
				.GET()
				.build();

https://github.com/modelcontextprotocol/java-sdk/blob/main/mcp/src/main/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransport.java#L331

When I try to connect the client to the Agent Gateway, I get a 406 , as there is not application/json as an Accept header:

406 - Not Acceptable: Client must accept both application/json and text/event-stream

Full error:

ERROR i.m.c.t.HttpClientSseClientTransport - Error sending message: Sending message failed with a non-OK HTTP code: 406 - Not Acceptable: Client must accept both application/json and text/event-stream

For my client configuration, here is my MCP Client settings:

spring.ai.mcp.client.sse.connections[server1].url: http://localhost:3000
spring.ai.mcp.client.sse.connections[server1].sse-endpoint: /sse

It seems that Agent Gateway should only check for text/event-stream to support official MCP clients?

If it helps, here is my config:

binds:
  - port: 3000
    listeners:
      - routes:
          - backends:
              - mcp:
                  name: default
                  targets:
                    - name: jokes-service
                      sse:
                        host: jokes-service
                        port: 8080
                        path: /sse

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions