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

Function deriveMcpNamespace

packages/plugins/mcp/src/sdk/manifest.ts:157–170  ·  view source on GitHub ↗
(input: {
  name?: string | null;
  endpoint?: string | null;
  command?: string | null;
})

Source from the content-addressed store, hash-verified

155const basenameOf = (path: string): string => path.trim().split(/[\\/]/).pop() ?? path.trim();
156
157export const deriveMcpNamespace = (input: {
158 name?: string | null;
159 endpoint?: string | null;
160 command?: string | null;
161}): string => {
162 if (input.name?.trim()) return slugify(input.name) || "mcp";
163
164 const fromEndpoint = input.endpoint?.trim() ? hostnameOf(input.endpoint) : null;
165 if (fromEndpoint) return slugify(fromEndpoint) || "mcp";
166
167 if (input.command?.trim()) return slugify(basenameOf(input.command)) || "mcp";
168
169 return "mcp";
170};

Callers 6

normalizeSlugFunction · 0.90
probeEndpointFunction · 0.90
plugin.tsFile · 0.90
plugin.test.tsFile · 0.90

Calls 3

hostnameOfFunction · 0.85
basenameOfFunction · 0.85
slugifyFunction · 0.70

Tested by

no test coverage detected