From b5ad53605da376f22d3aff8964e1fd5343aa7f0e Mon Sep 17 00:00:00 2001 From: Surya Prashanth Date: Mon, 13 Apr 2026 15:33:04 +0530 Subject: [PATCH] feat: support configurable subpath prefix via MCP_PATH_PREFIX Allows deploying the HTTP server under an ingress subpath (e.g. /mcp) by mounting the OAuth, header-auth, and SSE transports under the prefix and passing the prefix into each OAuth provider's base_url so advertised metadata URLs (issuer, authorize, token, register, resource) resolve to the externally-visible path. Co-Authored-By: Claude Opus 4.6 (1M context) --- plane_mcp/__main__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plane_mcp/__main__.py b/plane_mcp/__main__.py index d943d90..58ef721 100644 --- a/plane_mcp/__main__.py +++ b/plane_mcp/__main__.py @@ -87,13 +87,19 @@ def main() -> None: return if server_mode == ServerMode.HTTP: - oauth_mcp = get_oauth_mcp("/http") + + prefix = os.getenv("MCP_PATH_PREFIX") or "" + + oauth_mcp = get_oauth_mcp(prefix + "/http") oauth_app = oauth_mcp.http_app(stateless_http=True) header_app = get_header_mcp().http_app(stateless_http=True) - sse_mcp = get_oauth_mcp() + sse_mcp = get_oauth_mcp(prefix) sse_app = sse_mcp.http_app(transport="sse") + # mcp_path is appended to the auth provider's base_url to form the + # advertised resource URL. base_url already carries the prefix, so these + # stay at /mcp and /sse to avoid double-prefixing. oauth_well_known = oauth_mcp.auth.get_well_known_routes(mcp_path="/mcp") sse_well_known = sse_mcp.auth.get_well_known_routes(mcp_path="/sse") @@ -103,9 +109,9 @@ def main() -> None: *oauth_well_known, *sse_well_known, # Mount both MCP servers - Mount("/http/api-key", app=header_app), - Mount("/http", app=oauth_app), - Mount("/", app=sse_app), + Mount(prefix + "/http/api-key", app=header_app), + Mount(prefix + "/http", app=oauth_app), + Mount(prefix or "/", app=sse_app), ], lifespan=lambda app: combined_lifespan(oauth_app, header_app, sse_app), )