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

Function matchMcpSuffix

apps/cloud/src/mcp/mount.ts:48–64  ·  view source on GitHub ↗
(segments: readonly string[])

Source from the content-addressed store, hash-verified

46// Matches a trailing MCP endpoint: `mcp`, `mcp/toolkits/<slug>`, or either with
47// a leading org selector. Returns undefined when the segments are not MCP.
48const matchMcpSuffix = (segments: readonly string[]): MatchedMcpSuffix | undefined => {
49 if (segments.length === 1 && segments[0] === "mcp") return { organizationId: null };
50 if (segments.length === 3 && segments[0] === "mcp" && segments[1] === "toolkits") {
51 const toolkitSlug = segments[2];
52 return toolkitSlug ? { organizationId: null, toolkitSlug } : undefined;
53 }
54 if (segments.length === 2 && segments[1] === "mcp") {
55 const organizationId = orgSelectorSegment(segments[0]);
56 return organizationId ? { organizationId } : undefined;
57 }
58 if (segments.length === 4 && segments[1] === "mcp" && segments[2] === "toolkits") {
59 const organizationId = orgSelectorSegment(segments[0]);
60 const toolkitSlug = segments[3];
61 return organizationId && toolkitSlug ? { organizationId, toolkitSlug } : undefined;
62 }
63 return undefined;
64};
65
66/**
67 * Returns the MCP route (kind + optional URL-pinned org) for a pathname, or

Callers 1

classifyMcpPathFunction · 0.85

Calls 1

orgSelectorSegmentFunction · 0.85

Tested by

no test coverage detected