Skip to content

fix the issue when configuring remote MCP servers, hint for naming#380

Open
peterj wants to merge 2 commits intomainfrom
peterj/fixforremotemcp
Open

fix the issue when configuring remote MCP servers, hint for naming#380
peterj wants to merge 2 commits intomainfrom
peterj/fixforremotemcp

Conversation

@peterj
Copy link
Contributor

@peterj peterj commented Mar 18, 2026

Description

fix the issue when configuring remote MCP servers (use the mcp instead of sse as it tries to do a tls handshake), add a hint for incorrect naming of remote servers + extract the actual errors, instead of showing the JSON.

e.g.:

# Before
Error: failed to publish to registry: unexpected status: 400 Bad Request, {"title":"Bad Request","status":400,"detail":"Failed to create server","errors":[{"message":"remote URL https://servereverything.dev/mcp does not match namespace org/servereverything.dev: invalid namespace format: namespace must use reverse-DNS notation (e.g., \"dev.servereverything\" for servereverything.dev)"}]}

# After

Error: failed to publish to registry: 400 Bad Request: remote URL https://servereverything.dev/mcp does not match namespace org/servereverything.dev: invalid namespace format: namespace must use reverse-DNS notation (e.g., "dev.servereverything" for servereverything.dev)

Change Type

/kind fix

Changelog

fix configuring/running remote MCP servers

…xtract actual errors)

Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
Copilot AI review requested due to automatic review settings March 18, 2026 22:37
Copy link
Contributor

Copilot AI left a comment

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 improves remote MCP server handling in the local agent-gateway configuration and makes CLI/API client errors more human-readable by extracting meaningful messages from Huma-style JSON error responses.

Changes:

  • Switch local agent-gateway config generation for remote MCP servers from sse targets to mcp targets (to avoid incorrect TLS-handshake behavior).
  • Add reverse-DNS “hint” messaging when remote URL hostnames don’t match an invalid/non-reverse-DNS namespace.
  • Extract and display server-provided API error messages (instead of dumping raw JSON) and enhance HTTP status parsing.

Reviewed changes

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

Show a summary per file
File Description
internal/registry/validators/validators.go Improves namespace/remote URL mismatch errors with a reverse-DNS hint helper.
internal/registry/platforms/local/deployment_adapter_local_platform.go Builds remote MCP target URLs and emits mcp targets for remote servers.
internal/registry/platforms/local/deployment_adapter_local_platform_test.go Adds unit tests for remote MCP URL building behavior.
internal/client/client.go Extracts human-readable API error messages and broadens HTTP status detection.
internal/client/client_test.go Adds tests for API error extraction and HTTP status parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +267 to +280
func buildRemoteMCPURL(remote *platformtypes.RemoteMCPServer) string {
scheme := "https"
host := remote.Host
port := remote.Port
path := remote.Path

if port == 80 {
scheme = "http"
}

portSuffix := ""
if (scheme == "https" && port != 443) || (scheme == "http" && port != 80) {
portSuffix = fmt.Sprintf(":%d", port)
}
Comment on lines +277 to +283
portSuffix := ""
if (scheme == "https" && port != 443) || (scheme == "http" && port != 80) {
portSuffix = fmt.Sprintf(":%d", port)
}

return fmt.Sprintf("%s://%s%s%s", scheme, host, portSuffix, path)
}
{"https standard port", &platformtypes.RemoteMCPServer{Host: "example.com", Port: 443, Path: "/mcp"}, "https://example.com/mcp"},
{"https custom port", &platformtypes.RemoteMCPServer{Host: "example.com", Port: 8443, Path: "/mcp"}, "https://example.com:8443/mcp"},
{"http standard port", &platformtypes.RemoteMCPServer{Host: "example.com", Port: 80, Path: "/sse"}, "http://example.com/sse"},
{"http custom port", &platformtypes.RemoteMCPServer{Host: "localhost", Port: 3005, Path: "/mcp/"}, "https://localhost:3005/mcp/"},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants