Skip to content

Commit 20a7350

Browse files
fix(mcp): treat different URL credentials as a new destination (#8656)
1 parent 269f9b8 commit 20a7350

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎apps/sim/lib/mcp/utils.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ describe('isSameMcpServerDestination', () => {
6363
expect(isSameMcpServerDestination(url, 'https://mcp.example.com/MCP')).toBe(false)
6464
expect(isSameMcpServerDestination(url, `${url}/`)).toBe(false)
6565
})
66+
67+
it('treats different embedded credentials as a new destination', () => {
68+
const url = 'https://user:pass@mcp.example.com/mcp'
69+
expect(isSameMcpServerDestination(url, 'https://mcp.example.com/mcp')).toBe(false)
70+
expect(isSameMcpServerDestination(url, 'https://other:pass@mcp.example.com/mcp')).toBe(false)
71+
expect(isSameMcpServerDestination(url, 'https://user:other@mcp.example.com/mcp')).toBe(false)
72+
})
6673
})
6774

6875
describe('categorizeError', () => {

‎apps/sim/lib/mcp/utils.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,20 @@ export function generateMcpServerId(workspaceId: string, url: string): string {
244244
}
245245

246246
/**
247-
* Whether two URLs name the same MCP server destination: the same origin and
248-
* exact path. Only the query string and fragment may differ — paths can be
247+
* Whether two URLs name the same MCP server destination: the same origin,
248+
* credentials, and exact path. Only the query string and fragment may differ — paths can be
249249
* case-sensitive, so this is stricter than the id hash.
250250
*/
251251
export function isSameMcpServerDestination(a: string, b: string): boolean {
252252
try {
253253
const parsedA = new URL(a)
254254
const parsedB = new URL(b)
255-
return parsedA.origin === parsedB.origin && parsedA.pathname === parsedB.pathname
255+
return (
256+
parsedA.origin === parsedB.origin &&
257+
parsedA.username === parsedB.username &&
258+
parsedA.password === parsedB.password &&
259+
parsedA.pathname === parsedB.pathname
260+
)
256261
} catch {
257262
return a === b
258263
}

0 commit comments

Comments
 (0)