Skip to content

Commit d31ab36

Browse files
Add tests for MCP_PROXY_FULL_ADDRESS SSE endpoint support
Tests verify that proxyFullAddress query parameter is sent for both STDIO and SSE transports, but not Streamable HTTP, when MCP_PROXY_FULL_ADDRESS is configured. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 3e7c4b2 commit d31ab36

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

client/src/lib/hooks/__tests__/useConnection.test.tsx

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,4 +714,129 @@ describe("useConnection", () => {
714714
).toHaveProperty("X-MCP-Proxy-Auth", "Bearer test-proxy-token");
715715
});
716716
});
717+
718+
describe("MCP_PROXY_FULL_ADDRESS Configuration", () => {
719+
beforeEach(() => {
720+
jest.clearAllMocks();
721+
// Reset the mock transport objects
722+
mockSSETransport.url = undefined;
723+
mockSSETransport.options = undefined;
724+
mockStreamableHTTPTransport.url = undefined;
725+
mockStreamableHTTPTransport.options = undefined;
726+
});
727+
728+
test("sends proxyFullAddress query parameter for stdio transport when configured", async () => {
729+
const propsWithProxyFullAddress = {
730+
...defaultProps,
731+
transportType: "stdio" as const,
732+
command: "test-command",
733+
args: "test-args",
734+
env: {},
735+
config: {
736+
...DEFAULT_INSPECTOR_CONFIG,
737+
MCP_PROXY_FULL_ADDRESS: {
738+
...DEFAULT_INSPECTOR_CONFIG.MCP_PROXY_FULL_ADDRESS,
739+
value: "https://example.com/inspector/mcp_proxy",
740+
},
741+
},
742+
};
743+
744+
const { result } = renderHook(() =>
745+
useConnection(propsWithProxyFullAddress),
746+
);
747+
748+
await act(async () => {
749+
await result.current.connect();
750+
});
751+
752+
// Check that the URL contains the proxyFullAddress parameter
753+
expect(mockSSETransport.url?.searchParams.get("proxyFullAddress")).toBe(
754+
"https://example.com/inspector/mcp_proxy",
755+
);
756+
});
757+
758+
test("sends proxyFullAddress query parameter for sse transport when configured", async () => {
759+
const propsWithProxyFullAddress = {
760+
...defaultProps,
761+
transportType: "sse" as const,
762+
sseUrl: "http://localhost:8080",
763+
config: {
764+
...DEFAULT_INSPECTOR_CONFIG,
765+
MCP_PROXY_FULL_ADDRESS: {
766+
...DEFAULT_INSPECTOR_CONFIG.MCP_PROXY_FULL_ADDRESS,
767+
value: "https://example.com/inspector/mcp_proxy",
768+
},
769+
},
770+
};
771+
772+
const { result } = renderHook(() =>
773+
useConnection(propsWithProxyFullAddress),
774+
);
775+
776+
await act(async () => {
777+
await result.current.connect();
778+
});
779+
780+
// Check that the URL contains the proxyFullAddress parameter
781+
expect(mockSSETransport.url?.searchParams.get("proxyFullAddress")).toBe(
782+
"https://example.com/inspector/mcp_proxy",
783+
);
784+
});
785+
786+
test("does not send proxyFullAddress parameter when MCP_PROXY_FULL_ADDRESS is empty", async () => {
787+
const propsWithEmptyProxy = {
788+
...defaultProps,
789+
transportType: "stdio" as const,
790+
command: "test-command",
791+
args: "test-args",
792+
env: {},
793+
config: {
794+
...DEFAULT_INSPECTOR_CONFIG,
795+
MCP_PROXY_FULL_ADDRESS: {
796+
...DEFAULT_INSPECTOR_CONFIG.MCP_PROXY_FULL_ADDRESS,
797+
value: "",
798+
},
799+
},
800+
};
801+
802+
const { result } = renderHook(() => useConnection(propsWithEmptyProxy));
803+
804+
await act(async () => {
805+
await result.current.connect();
806+
});
807+
808+
// Check that the URL does not contain the proxyFullAddress parameter
809+
expect(
810+
mockSSETransport.url?.searchParams.get("proxyFullAddress"),
811+
).toBeNull();
812+
});
813+
814+
test("does not send proxyFullAddress parameter for streamable-http transport", async () => {
815+
const propsWithStreamableHttp = {
816+
...defaultProps,
817+
transportType: "streamable-http" as const,
818+
sseUrl: "http://localhost:8080",
819+
config: {
820+
...DEFAULT_INSPECTOR_CONFIG,
821+
MCP_PROXY_FULL_ADDRESS: {
822+
...DEFAULT_INSPECTOR_CONFIG.MCP_PROXY_FULL_ADDRESS,
823+
value: "https://example.com/inspector/mcp_proxy",
824+
},
825+
},
826+
};
827+
828+
const { result } = renderHook(() =>
829+
useConnection(propsWithStreamableHttp),
830+
);
831+
832+
await act(async () => {
833+
await result.current.connect();
834+
});
835+
836+
// Check that streamable-http transport doesn't get proxyFullAddress parameter
837+
expect(
838+
mockStreamableHTTPTransport.url?.searchParams.get("proxyFullAddress"),
839+
).toBeNull();
840+
});
841+
});
717842
});

0 commit comments

Comments
 (0)