MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / resolveMCPServerURL

Function resolveMCPServerURL

server/src/mcp/routes.ts:49–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 * actually set BASE_URL to something valid is still authoritative.
48 */
49export function resolveMCPServerURL(): string {
50 const raw = process.env.BASE_URL;
51 if (typeof raw === 'string') {
52 const trimmed = raw.replace(/\/$/, '').trim();
53 if (trimmed) {
54 try {
55 new URL(trimmed);
56 return trimmed;
57 } catch {
58 logger.warn(
59 { baseUrl: raw },
60 'BASE_URL is set but does not parse as a URL — falling back to the development default',
61 );
62 }
63 }
64 }
65 const port = process.env.PORT || process.env.CONDUCTOR_PORT || '3000';
66 return `http://localhost:${port}`;
67}
68
69const MCP_SERVER_URL = resolveMCPServerURL();
70

Callers 3

setupMiddlewareMethod · 0.85
routes.tsFile · 0.85

Calls 2

warnMethod · 0.80
trimMethod · 0.65

Tested by

no test coverage detected