Skip to content

[BUG][TRANSPORT]: SSE generate_response uses client-facing URL for self-referencing RPC call, fails behind proxy/mesh #3049

@scwhaley

Description

@scwhaley

🐞 Bug Summary

I am using Hybrid Cloud Mesh to connect a MCP client in Fyre (Environment A) to a ContextForge instance in AWS (Environment B). SSE messages fail to generate a response due to ContextForge leveraging the URL used by the client's original SSE connection when calling it's own /rpc endpoint. This is because the client URL is only resolvable/reachable from the client's Fyre environment.

The setup:

  • MCP Client is in environment A, ContextForge in environment B. Neither the client or ContextForge have a public endpoint.
  • Mesh gateways in both environments, where Mesh creates a local endpoint in environment A that proxies traffic to ContextForge in environment B.
  • This local endpoint only makes sense in environment A. For example, environment A is a 192.168.x.x private network, environment B is a 10.x.x.x private network.
  • MCP Client reaches ContextForge at that local endpoint (i.e. 192.168.0.10).

The behavior:

  1. Client connects to ContextForge at http://$ENV_A_ENDPOINT/servers/$SERVER_ID/sse , the SSE stream and session_id is set up correctly
  2. Client sends a POST request to ContextForge at http://$ENV_A_ENDPOINT/servers/$SERVER_ID/message?session_id=$SESSION_ID
  3. The /message handler in main.py > message_endpoint() broadcasts the message to the corresponding session using session_registry.broadcast()
  4. To actually respond to the client, ContextForge handles the broadcasted message in session_registry.py > respond() > generate_response()
  5. In generate_response(), ContextForge attempts to make a RPC call to ContextForge/itself using the URL that the original client used when setting up the SSE stream
  6. The issue: Because the client reached ContextForge at a URL that only makes sense in environment A, the RPC call fails (since there is no corresponding endpoint in environment B)

🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

🔁 Steps to Reproduce

Steps are described above in Bug Summary


🤔 Expected Behavior

What should have happened instead?

ContextForge should not rely on the URL used by the client because it may not be resolvable/reachable in ContextForge's environment. It should handle the /rpc call internally rather than going back out over the network to simply reach itself.


📓 Logs / Error Output

Paste any relevant stack traces or logs here.
⚠️ Do not paste secrets, credentials, or tokens.


🧠 Environment Info

You can retrieve most of this from the /version endpoint.

Key Value
Version or commit 1.0.0-RC1
Platform / OS Ubuntu 24.04
Container Kubernetes (microk8s)

🧩 Additional Context (optional)

Add any configuration details, flags, or related issues.

Metadata

Metadata

Assignees

Labels

SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingreadyValidated, ready-to-work-on items

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions