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

Function toolkitSlugFromPath

apps/host-cloudflare/src/mcp/auth.ts:17–29  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

15const TOOLKIT_PROTECTED_RESOURCE_METADATA_PATH = `${MCP_PROTECTED_RESOURCE_METADATA_PATH}/toolkits/:toolkitSlug`;
16
17const toolkitSlugFromPath = (pathname: string): string | undefined => {
18 const mcpPrefix = "/mcp/toolkits/";
19 if (pathname.startsWith(mcpPrefix)) {
20 const slug = pathname.slice(mcpPrefix.length).split("/", 1)[0];
21 return slug ? decodeURIComponent(slug) : undefined;
22 }
23 const metadataPrefix = `${MCP_PROTECTED_RESOURCE_METADATA_PATH}/toolkits/`;
24 if (pathname.startsWith(metadataPrefix)) {
25 const slug = pathname.slice(metadataPrefix.length).split("/", 1)[0];
26 return slug ? decodeURIComponent(slug) : undefined;
27 }
28 return undefined;
29};
30
31const toolkitPath = (slug: string): string => `/mcp/toolkits/${encodeURIComponent(slug)}`;
32

Callers 2

resourcePathForRequestFunction · 0.85
metadataPathForRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected