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

Function classifyMcpPath

apps/cloud/src/mcp/mount.ts:79–96  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

77 * org-scoped path to the bare path the shared envelope actually routes.
78 */
79export const classifyMcpPath = (pathname: string): McpRoute => {
80 if (pathname === AUTHORIZATION_SERVER_METADATA_PATH) {
81 return { kind: "oauth-authorization-server", organizationId: null };
82 }
83 const segments = pathname.split("/").filter((segment) => segment.length > 0);
84
85 // Protected-resource metadata: `${prefix}/mcp` or `${prefix}/<org>/mcp`. The
86 // org sits after the well-known prefix (RFC 9728), not at the path root.
87 const prmPrefix = "/.well-known/oauth-protected-resource";
88 if (pathname.startsWith(`${prmPrefix}/`)) {
89 const matched = matchMcpSuffix(segments.slice(2));
90 return matched === undefined ? null : { kind: "oauth-protected-resource", ...matched };
91 }
92
93 // MCP transport: `/mcp` or `/<org>/mcp`.
94 const matched = matchMcpSuffix(segments);
95 return matched === undefined ? null : { kind: "mcp", ...matched };
96};
97
98const bareMcpPath = (route: Exclude<McpRoute, null>): string =>
99 route.kind === "mcp"

Callers 4

isAppOwnedPathFunction · 0.90
server.tsFile · 0.90
mount.test.tsFile · 0.90
prepareMcpOrgScopeFunction · 0.85

Calls 1

matchMcpSuffixFunction · 0.85

Tested by

no test coverage detected