@@ -609,14 +609,18 @@ export const mcpServerIcon = registerIcon('mcp-server', Codicon.mcp, localize('m
609
609
export namespace McpResourceURI {
610
610
export const scheme = 'mcp-resource' ;
611
611
612
+ // Random placeholder for empty authorities, otherwise they're represente as
613
+ // `scheme//path/here` in the URI which would get normalized to `scheme/path/here`.
614
+ const emptyAuthorityPlaceholder = 'dylo78gyp' ; // chosen by a fair dice roll. Guaranteed to be random.
615
+
612
616
export function fromServer ( def : McpDefinitionReference , resourceURI : URI | string ) : URI {
613
617
if ( typeof resourceURI === 'string' ) {
614
618
resourceURI = URI . parse ( resourceURI ) ;
615
619
}
616
620
return resourceURI . with ( {
617
621
scheme,
618
622
authority : encodeHex ( VSBuffer . fromString ( def . id ) ) ,
619
- path : [ '' , resourceURI . scheme , resourceURI . authority ] . join ( '/' ) + resourceURI . path ,
623
+ path : [ '' , resourceURI . scheme , resourceURI . authority || emptyAuthorityPlaceholder ] . join ( '/' ) + resourceURI . path ,
620
624
} ) ;
621
625
}
622
626
@@ -636,8 +640,8 @@ export namespace McpResourceURI {
636
640
definitionId : decodeHex ( uri . authority ) . toString ( ) ,
637
641
resourceURI : uri . with ( {
638
642
scheme : serverScheme ,
639
- authority,
640
- path : '/' + path . join ( '/' ) ,
643
+ authority : authority . toLowerCase ( ) === emptyAuthorityPlaceholder ? '' : authority ,
644
+ path : path . length ? ( '/' + path . join ( '/' ) ) : '' ,
641
645
} ) ,
642
646
} ;
643
647
}
0 commit comments