Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/sim/lib/mcp/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ describe('isSameMcpServerDestination', () => {
expect(isSameMcpServerDestination(url, 'https://mcp.example.com/MCP')).toBe(false)
expect(isSameMcpServerDestination(url, `${url}/`)).toBe(false)
})

it('treats different embedded credentials as a new destination', () => {
Comment thread
TheodoreSpeaks marked this conversation as resolved.
const url = 'https://user:pass@mcp.example.com/mcp'
expect(isSameMcpServerDestination(url, 'https://mcp.example.com/mcp')).toBe(false)
expect(isSameMcpServerDestination(url, 'https://other:pass@mcp.example.com/mcp')).toBe(false)
expect(isSameMcpServerDestination(url, 'https://user:other@mcp.example.com/mcp')).toBe(false)
})
})

describe('categorizeError', () => {
Expand Down
11 changes: 8 additions & 3 deletions apps/sim/lib/mcp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,20 @@ export function generateMcpServerId(workspaceId: string, url: string): string {
}

/**
* Whether two URLs name the same MCP server destination: the same origin and
* exact path. Only the query string and fragment may differ — paths can be
* Whether two URLs name the same MCP server destination: the same origin,
* credentials, and exact path. Only the query string and fragment may differ — paths can be
* case-sensitive, so this is stricter than the id hash.
*/
export function isSameMcpServerDestination(a: string, b: string): boolean {
try {
const parsedA = new URL(a)
const parsedB = new URL(b)
return parsedA.origin === parsedB.origin && parsedA.pathname === parsedB.pathname
return (
parsedA.origin === parsedB.origin &&
parsedA.username === parsedB.username &&
parsedA.password === parsedB.password &&
parsedA.pathname === parsedB.pathname
)
} catch {
return a === b
}
Expand Down
Loading