@@ -220,5 +220,47 @@ describe('McpToolServerConfigurationService', () => {
220220 expect . stringContaining ( 'Either mcpServerName or mcpServerUniqueName must be provided' )
221221 ) ;
222222 } ) ;
223+
224+ it ( 'should preserve custom headers when provided in manifest' , async ( ) => {
225+ // Arrange
226+ const manifestContent = {
227+ mcpServers : [
228+ {
229+ mcpServerName : 'serverWithHeaders' ,
230+ url : 'http://localhost:3000/custom-mcp' ,
231+ headers : {
232+ 'Authorization' : 'Bearer token123' ,
233+ 'X-Custom-Header' : 'custom-value'
234+ }
235+ } ,
236+ {
237+ mcpServerName : 'serverWithoutHeaders' ,
238+ url : 'http://localhost:4000/another-mcp'
239+ }
240+ ]
241+ } ;
242+
243+ jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( true ) ;
244+ jest . spyOn ( fs , 'readFileSync' ) . mockReturnValue ( JSON . stringify ( manifestContent ) ) ;
245+
246+ // Act
247+ const servers = await service . listToolServers ( 'test-agent-id' , 'mock-auth-token' ) ;
248+
249+ // Assert
250+ expect ( servers ) . toHaveLength ( 2 ) ;
251+
252+ // First server should have headers preserved
253+ expect ( servers [ 0 ] . mcpServerName ) . toBe ( 'serverWithHeaders' ) ;
254+ expect ( servers [ 0 ] . url ) . toBe ( 'http://localhost:3000/custom-mcp' ) ;
255+ expect ( servers [ 0 ] . headers ) . toEqual ( {
256+ 'Authorization' : 'Bearer token123' ,
257+ 'X-Custom-Header' : 'custom-value'
258+ } ) ;
259+
260+ // Second server should have undefined headers
261+ expect ( servers [ 1 ] . mcpServerName ) . toBe ( 'serverWithoutHeaders' ) ;
262+ expect ( servers [ 1 ] . url ) . toBe ( 'http://localhost:4000/another-mcp' ) ;
263+ expect ( servers [ 1 ] . headers ) . toBeUndefined ( ) ;
264+ } ) ;
223265 } ) ;
224266} ) ;
0 commit comments