From 943cf26d77a653eb37f67c31990496f5980fc466 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 8 May 2026 10:27:46 -0500 Subject: [PATCH] workspace-mcp: strip /workspace prefix for API GW proxy route --- src/lambdas/workspace-mcp/handler.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lambdas/workspace-mcp/handler.py b/src/lambdas/workspace-mcp/handler.py index 1512eb7..fbd2bc5 100644 --- a/src/lambdas/workspace-mcp/handler.py +++ b/src/lambdas/workspace-mcp/handler.py @@ -111,4 +111,23 @@ class _ActorCredentialsMiddleware: await self._app(scope, receive, send) -handler = Mangum(_ActorCredentialsMiddleware(_app), lifespan='auto') +class _PathPrefixStripMiddleware: + """Strip /workspace prefix so API GW proxy route maps to FastMCP's /mcp path.""" + _PREFIX = b'/workspace' + + def __init__(self, app): + self._app = app + + async def __call__(self, scope, receive, send): + if scope['type'] in ('http', 'websocket'): + path: str = scope.get('path', '') + if path.startswith('/workspace'): + scope = dict(scope) + scope['path'] = path[len('/workspace'):] or '/' + raw: bytes = scope.get('raw_path') or b'' + if raw.startswith(self._PREFIX): + scope['raw_path'] = raw[len(self._PREFIX):] or b'/' + await self._app(scope, receive, send) + + +handler = Mangum(_PathPrefixStripMiddleware(_ActorCredentialsMiddleware(_app)), lifespan='auto')