Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): derive remote client tests from the real internal-hop shape (R1-H1)
Diego Zacarias8e16e259985e
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 3988e441b..5223dec4b 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.464",+ "version": "0.1.465","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.464",+ "version": "0.1.465","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 2a5711a66..3ba364fb1 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.464",+ "version": "0.1.465","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/mcp/__tests__/clientRemoteTarget.test.ts b/mcp-host/src/mcp/__tests__/clientRemoteTarget.test.tsindex 42af0d321..0efa46cbb 100644--- a/mcp-host/src/mcp/__tests__/clientRemoteTarget.test.ts+++ b/mcp-host/src/mcp/__tests__/clientRemoteTarget.test.ts@@ -75,14 +75,15 @@ describe('remote server bypasses the MCP_PROXY_URL rail (e)', () => {const PROXY = 'http://mcp-proxy.svc:8080'it('targets the published transport.url, not ${proxy}/servers/<name>/mcp', async () => {- const client = new McpClient(- remoteServer('https://8.8.8.8/mcp'),- staticTokenProvider('t'),- PROXY- )+ // transport.url for a remote server is the HCC egress-proxy Service (http,+ // in-cluster) — the external baseUrl is validated upstream and never reaches+ // mcp-host. An https destination here would be a shape the producer never+ // emits, which is what hid the internal-hop SSRF-guard regression.+ const INTERNAL_HOP = 'http://remote-x.clerum-host-xyz.svc.cluster.local:3000/mcp'+ const client = new McpClient(remoteServer(INTERNAL_HOP), staticTokenProvider('t'), PROXY)await client.connect()- // The remote egress went to its own URL, never the in-cluster proxy rail.- expect(built.streamable).toEqual(['https://8.8.8.8/mcp'])+ // The remote egress went to its own published URL, never the in-cluster proxy rail.+ expect(built.streamable).toEqual([INTERNAL_HOP])expect(built.streamable[0]).not.toContain('mcp-proxy')})diff --git a/mcp-host/src/mcp/__tests__/managerRemoteOauthCatalog.test.ts b/mcp-host/src/mcp/__tests__/managerRemoteOauthCatalog.test.tsindex e0cf0a65e..a17f9c00b 100644--- a/mcp-host/src/mcp/__tests__/managerRemoteOauthCatalog.test.ts+++ b/mcp-host/src/mcp/__tests__/managerRemoteOauthCatalog.test.ts@@ -14,10 +14,11 @@* The pathological/authenticated states are reached with real manager APIs* (addServer / callTool / refreshAllServerStatus), never a hand-built map.*- * The SDK Client mock models a spec-compliant remote: a token-less request to an- * https target 401s at `initialize`. `core/net/ssrf` is mocked to a public no-op- * here (its real behavior is covered by clientRemoteTarget.test.ts) so these- * tests never touch DNS.+ * The SDK Client mock models a spec-compliant remote: a token-less `initialize`+ * 401s regardless of the (in-cluster, http) transport.url. The real internal-hop+ * handling (mcp-host does NOT SSRF-guard the remote proxy hop) is covered by+ * clientRemoteInternalHop.test.ts; the SDK Client is mocked here so nothing+ * touches the network.*/import { beforeEach, describe, expect, it, vi } from 'vitest'import type { McpServerInfo } from '../../types'@@ -55,9 +56,10 @@ vi.mock('@modelcontextprotocol/sdk/client/index.js', () => ({Client: class MockClient {private transport: MockTransport | null = nullconnect = vi.fn(async (t: MockTransport) => {- // Spec-compliant remote: a token-less request to an https target 401s at- // `initialize`. Local (http) targets serve initialize unauthenticated.- if (t.url.startsWith('https:') && !t.requestHeaders['Authorization']) {+ // Spec-compliant remote: a token-less `initialize` 401s. Every fixture here+ // is remote+oauth, whose real transport.url is the in-cluster http egress+ // hop — so the 401 keys off the missing Bearer, never the URL scheme.+ if (!t.requestHeaders['Authorization']) {throw new RemoteAuthRequired()}this.transport = t@@ -92,22 +94,15 @@ vi.mock('@modelcontextprotocol/sdk/client/sse.js', () => ({},}))-// Neutralize the SSRF guard for the catalog/heartbeat tests — the real guard is-// exercised in clientRemoteTarget.test.ts. Here it must never touch DNS.-vi.mock('../../core/net/ssrf', () => ({- SsrfBlockedError: class SsrfBlockedError extends Error {},- resolvePinnedPublicIp: vi.fn(async () => '203.0.113.10'),- // client.ts pins remote connections with a fetch from pinnedFetch(ip); the SDK- // Client is mocked here so the returned fetch is never invoked.- pinnedFetch: vi.fn(() => vi.fn(async () => new Response('{}'))),-}))-// ─── Fixtures ────────────────────────────────────────────────────────────────function remoteOauthUserServer(name = 'remote-gh'): McpServerInfo {return {name,- transport: { type: 'streamableHttp', url: `https://${name}.example.com/mcp` },+ transport: {+ type: 'streamableHttp',+ url: `http://${name}.clerum-host-xyz.svc.cluster.local:3000/mcp`,+ },authKind: 'oauth-user',remote: true,enabled: true,@@ -118,7 +113,10 @@ function remoteOauthUserServer(name = 'remote-gh'): McpServerInfo {function remoteOauthContextServer(name = 'remote-ctx'): McpServerInfo {return {name,- transport: { type: 'streamableHttp', url: `https://${name}.example.com/mcp` },+ transport: {+ type: 'streamableHttp',+ url: `http://${name}.clerum-host-xyz.svc.cluster.local:3000/mcp`,+ },authKind: 'oauth-context',remote: true,enabled: true,