Skip to content

Return more compatible SSE endpoint#455

Merged
howardjohn merged 1 commit into
agentgateway:mainfrom
howardjohn:mcp/less-relative-url
Sep 22, 2025
Merged

Return more compatible SSE endpoint#455
howardjohn merged 1 commit into
agentgateway:mainfrom
howardjohn:mcp/less-relative-url

Conversation

@howardjohn

Copy link
Copy Markdown
Collaborator

Before: ?sessionId=23cab33d-8f1e-46cf-902a-9793335ab90f
After: /sse?sessionId=23cab33d-8f1e-46cf-902a-9793335ab90f

A proper SDK supports both... but some clients are not great. The latter is more standard.

Fixes #166

Copilot AI review requested due to automatic review settings September 22, 2025 22:27
@howardjohn howardjohn requested a review from a team as a code owner September 22, 2025 22:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the SSE endpoint format to be more standards-compliant by returning /sse?sessionId=<id> instead of just ?sessionId=<id>. This change improves compatibility with clients that may not handle the previous endpoint format well.

Key Changes:

  • Implemented URL construction logic to create proper SSE endpoints with full path and query parameters
  • Added utility function modify_url for converting between URIs and URLs to manipulate query parameters
  • Updated SSE service to use the new endpoint format when establishing connections

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/agentgateway/src/mcp/sse.rs Updates SSE endpoint construction to use full path with query parameters
crates/agentgateway/src/http/mod.rs Adds utility function for URL manipulation and URI/URL conversion

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +110 to +113
anyhow::bail!("no authority");
}
if !url.has_host() {
anyhow::bail!("no host");

Copilot AI Sep 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error messages 'no authority' and 'no host' are not descriptive enough for debugging. Consider including the URL in the error message, e.g., 'URL has no authority: {url}' and 'URL has no host: {url}'.

Suggested change
anyhow::bail!("no authority");
}
if !url.has_host() {
anyhow::bail!("no host");
anyhow::bail!("URL has no authority: {}", url.as_str());
}
if !url.has_host() {
anyhow::bail!("URL has no host: {}", url.as_str());

Copilot uses AI. Check for mistakes.
}) {
return http_error(
StatusCode::INTERNAL_SERVER_ERROR,
format!("fail to create SSE url: {e}"),

Copilot AI Sep 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message contains a grammatical error. 'fail to create' should be 'failed to create'.

Suggested change
format!("fail to create SSE url: {e}"),
format!("failed to create SSE url: {e}"),

Copilot uses AI. Check for mistakes.
Before: `?sessionId=23cab33d-8f1e-46cf-902a-9793335ab90f`
After: `/sse?sessionId=23cab33d-8f1e-46cf-902a-9793335ab90f`

A proper SDK supports both... but some clients are not great. The latter
is more standard.
@howardjohn howardjohn force-pushed the mcp/less-relative-url branch from 58fc400 to 9c81525 Compare September 22, 2025 22:34
@howardjohn howardjohn merged commit 8d94121 into agentgateway:main Sep 22, 2025
9 checks passed
surinderunitone pushed a commit to UnitOneAI/agentgateway that referenced this pull request Feb 1, 2026
Before: `?sessionId=23cab33d-8f1e-46cf-902a-9793335ab90f`
After: `/sse?sessionId=23cab33d-8f1e-46cf-902a-9793335ab90f`

A proper SDK supports both... but some clients are not great. The latter
is more standard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot connect to Agent Gateway with Java MCP client using SSE

2 participants