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

Function stripMcpOrgSegment

apps/host-selfhost/src/mcp/org-path.ts:32–50  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

30 * -> /.well-known/oauth-protected-resource/mcp/toolkits/<toolkit>
31 */
32export const stripMcpOrgSegment = (pathname: string): string | null => {
33 if (pathname.startsWith(`${PRM_PREFIX}/`)) {
34 const rest = pathname
35 .slice(PRM_PREFIX.length + 1)
36 .split("/")
37 .filter((segment) => segment.length > 0);
38 if (rest.length === 2 && rest[1] === "mcp") return PRM_PREFIX;
39 if (rest.length === 4 && rest[1] === "mcp" && rest[2] === "toolkits") {
40 return `${PRM_PREFIX}/mcp/toolkits/${rest[3]}`;
41 }
42 return null;
43 }
44 const segments = pathname.split("/").filter((segment) => segment.length > 0);
45 if (segments.length === 2 && segments[1] === "mcp") return "/mcp";
46 if (segments.length === 4 && segments[1] === "mcp" && segments[2] === "toolkits") {
47 return `/mcp/toolkits/${segments[3]}`;
48 }
49 return null;
50};
51
52/**
53 * Header the strip middleware (serve.ts's Effect middleware and the vite dev

Callers 4

configureServerFunction · 0.90
selfHostHttpMiddlewareFunction · 0.90
org-path.test.tsFile · 0.90
isRecognizedMcpOrgPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected