( config: McpServerConfig, )
| 560 | * Returns undefined for stdio/sdk servers or if URL parsing fails. |
| 561 | */ |
| 562 | export function getLoggingSafeMcpBaseUrl( |
| 563 | config: McpServerConfig, |
| 564 | ): string | undefined { |
| 565 | if (!('url' in config) || typeof config.url !== 'string') { |
| 566 | return undefined |
| 567 | } |
| 568 | |
| 569 | try { |
| 570 | const url = new URL(config.url) |
| 571 | url.search = '' |
| 572 | return url.toString().replace(/\/$/, '') |
| 573 | } catch { |
| 574 | return undefined |
| 575 | } |
| 576 | } |
no test coverage detected