Skip to content

Commit 3d01e9e

Browse files
Merge pull request #506 from modelcontextprotocol/basil/rollback
rollback path preservation fix
2 parents 6be4c60 + 82f5f70 commit 3d01e9e

File tree

2 files changed

+0
-70
lines changed

2 files changed

+0
-70
lines changed

src/client/sse.test.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -68,71 +68,6 @@ describe("SSEClientTransport", () => {
6868
});
6969

7070
describe("connection handling", () => {
71-
it("maintains custom path when constructing endpoint URL", async () => {
72-
// Create a URL with a custom path
73-
const customPathUrl = new URL("/custom/path/sse", baseUrl);
74-
transport = new SSEClientTransport(customPathUrl);
75-
76-
// Start the transport
77-
await transport.start();
78-
79-
// Send a test message to verify the endpoint URL
80-
const message: JSONRPCMessage = {
81-
jsonrpc: "2.0",
82-
id: "test-1",
83-
method: "test",
84-
params: {}
85-
};
86-
87-
await transport.send(message);
88-
89-
// Verify the POST request maintains the custom path
90-
expect(lastServerRequest.url).toBe("/custom/path/sse");
91-
});
92-
93-
it("handles multiple levels of custom paths", async () => {
94-
// Test with a deeper nested path
95-
const nestedPathUrl = new URL("/api/v1/custom/deep/path/sse", baseUrl);
96-
transport = new SSEClientTransport(nestedPathUrl);
97-
98-
await transport.start();
99-
100-
const message: JSONRPCMessage = {
101-
jsonrpc: "2.0",
102-
id: "test-1",
103-
method: "test",
104-
params: {}
105-
};
106-
107-
await transport.send(message);
108-
109-
// Verify the POST request maintains the full custom path
110-
expect(lastServerRequest.url).toBe("/api/v1/custom/deep/path/sse");
111-
});
112-
113-
it("maintains custom path for SSE connection", async () => {
114-
const customPathUrl = new URL("/custom/path/sse", baseUrl);
115-
transport = new SSEClientTransport(customPathUrl);
116-
await transport.start();
117-
expect(lastServerRequest.url).toBe("/custom/path/sse");
118-
});
119-
120-
it("handles URLs with query parameters", async () => {
121-
const urlWithQuery = new URL("/custom/path/sse?param=value", baseUrl);
122-
transport = new SSEClientTransport(urlWithQuery);
123-
await transport.start();
124-
125-
const message: JSONRPCMessage = {
126-
jsonrpc: "2.0",
127-
id: "test-1",
128-
method: "test",
129-
params: {}
130-
};
131-
132-
await transport.send(message);
133-
expect(lastServerRequest.url).toBe("/custom/path/sse");
134-
});
135-
13671
it("establishes SSE connection and receives endpoint", async () => {
13772
transport = new SSEClientTransport(baseUrl);
13873
await transport.start();

src/client/sse.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,7 @@ export class SSEClientTransport implements Transport {
143143
const messageEvent = event as MessageEvent;
144144

145145
try {
146-
// Use the original URL as the base to resolve the received endpoint
147146
this._endpoint = new URL(messageEvent.data, this._url);
148-
149-
// If the original URL had a custom path, preserve it in the endpoint URL
150-
this._endpoint.pathname = this._url.pathname;
151-
152147
if (this._endpoint.origin !== this._url.origin) {
153148
throw new Error(
154149
`Endpoint origin does not match connection origin: ${this._endpoint.origin}`,

0 commit comments

Comments
 (0)