Strip endpointPrefix from request paths in transparent proxy
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
Description
Problem
The transparent proxy currently rewrites SSE endpoint URLs in responses to include the configured endpointPrefix, but it doesn't strip the prefix from incoming request paths before forwarding to the backend MCP server.
This causes issues in two scenarios:
-
Direct client access: When a client makes a request directly to the proxy with the prefix (e.g.,
/playwright/sse), the proxy forwards it as-is to the backend, which expects/ssewithout the prefix. -
Ingress without prefix stripping: When an ingress controller doesn't strip the prefix before forwarding, the backend receives requests with the prefix that it doesn't expect.
Current Behavior
- SSE response URLs are rewritten with prefix:
/sse→/playwright/sse✓ - Request paths are forwarded as-is:
/playwright/sse→ backend receives/playwright/sse✗
Expected Behavior
- If ingress already stripped the prefix (detected via
X-Forwarded-Prefixheader), proxy should not strip again - If ingress didn't strip OR client makes direct request, proxy should strip the prefix before forwarding
- Backend should always receive paths without the prefix:
/playwright/sse→/sse
Solution
Implement prefix stripping in the proxy's Director function that:
- Strips
endpointPrefixfrom request paths when present at the start - Detects if ingress already stripped via
X-Forwarded-Prefixheader (whentrustProxyHeadersis enabled) - Handles edge cases like prefix appearing later in path (e.g.,
/abc/abc/ssewith prefix/abc→/abc/sse)
Related
- Affects: SSE transport with
endpointPrefixconfiguration - Related to: Ingress path-based routing scenarios
- Implementation:
pkg/transport/proxy/transparent/transparent_proxy.go
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/transport/proxy/transparent/transparent_proxy.go at the proxy's Director function and trace how endpointPrefix and X-Forwarded-Prefix are handled. Verify direct and ingress-forwarded requests, including repeated prefixes such as /abc/abc/sse; done means the backend receives paths without an unstripped prefix while already-stripped requests remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100