MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / prepareMcpOrgScope

Function prepareMcpOrgScope

apps/cloud/src/mcp/mount.ts:119–130  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

117 * worker so both classify + rewrite identically; a no-op for non-MCP paths.
118 */
119export const prepareMcpOrgScope = (request: Request): Request => {
120 const url = new URL(request.url);
121 const route = classifyMcpPath(url.pathname);
122 if (route === null) return request;
123 const bare = bareMcpPath(route);
124 if (url.pathname === bare && !request.headers.has(MCP_ORGANIZATION_HEADER)) return request;
125 url.pathname = bare;
126 const rewritten = new Request(url, request);
127 if (route.organizationId) rewritten.headers.set(MCP_ORGANIZATION_HEADER, route.organizationId);
128 else rewritten.headers.delete(MCP_ORGANIZATION_HEADER);
129 return rewritten;
130};
131
132// Production no longer mounts the /mcp transport here. `server.ts` intercepts MCP
133// transport requests for the hibernatable Agent bridge, while `ExecutorApp.make`

Callers 3

start.tsFile · 0.90
server.tsFile · 0.90
mount.test.tsFile · 0.90

Calls 4

classifyMcpPathFunction · 0.85
bareMcpPathFunction · 0.85
setMethod · 0.80
deleteMethod · 0.65

Tested by

no test coverage detected