(input: {
name?: string | null;
endpoint?: string | null;
command?: string | null;
})
| 155 | const basenameOf = (path: string): string => path.trim().split(/[\\/]/).pop() ?? path.trim(); |
| 156 | |
| 157 | export 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 | }; |
no test coverage detected