@@ -3,7 +3,17 @@ import { afterEach, beforeAll, beforeEach, describe, expect, mock, test, vi } fr
33const redisSetex = vi . fn ( async ( _key : string , _ttlSeconds : number , _value : string ) => 'OK' ) ;
44const redisGet = vi . fn ( async ( _key : string ) : Promise < string | null > => null ) ;
55const mockHeartbeat = vi . fn ( ) ;
6- const mockStartMcpDockerServer = vi . fn ( async ( ) => ( {
6+
7+ interface MockMcpDockerServerInput {
8+ context : {
9+ logger : {
10+ debug : ( ...args : unknown [ ] ) => void ;
11+ info : ( ...args : unknown [ ] ) => void ;
12+ } ;
13+ } ;
14+ }
15+
16+ const mockStartMcpDockerServer = vi . fn ( async ( _input : MockMcpDockerServerInput ) => ( {
717 endpoint : 'http://localhost:4100/mcp' ,
818 containerId : 'mcp-container-1' ,
919} ) ) ;
@@ -166,4 +176,49 @@ describe('MCP discovery activity diagnostics', () => {
166176 consoleLogSpy . mockRestore ( ) ;
167177 }
168178 } ) ;
179+
180+ test ( 'discoverMcpGroupToolsActivity does not mirror docker info/debug collector logs to console by default' , async ( ) => {
181+ mockStartMcpDockerServer . mockImplementationOnce ( async ( input : MockMcpDockerServerInput ) => {
182+ input . context . logger . info ( 'stdio proxy started' ) ;
183+ input . context . logger . debug ( 'stdio proxy details' ) ;
184+ return {
185+ endpoint : 'http://localhost:4100/mcp' ,
186+ containerId : 'mcp-container-1' ,
187+ } ;
188+ } ) ;
189+ globalThis . fetch = vi . fn ( async ( url : Parameters < typeof fetch > [ 0 ] ) => {
190+ const href = String ( url ) ;
191+ if ( href . endsWith ( '/health' ) ) {
192+ return createJsonResponse ( {
193+ status : 'ok' ,
194+ servers : [ { ready : true } ] ,
195+ } ) ;
196+ }
197+ return createJsonResponse ( {
198+ result : {
199+ tools : [ { name : 'list_buckets' , description : 'List storage buckets' } ] ,
200+ } ,
201+ } ) ;
202+ } ) as unknown as typeof fetch ;
203+ const consoleLogSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
204+ const consoleDebugSpy = vi . spyOn ( console , 'debug' ) . mockImplementation ( ( ) => { } ) ;
205+
206+ try {
207+ await discoverMcpGroupToolsActivity ( {
208+ servers : [
209+ {
210+ name : 'storage' ,
211+ transport : 'stdio' ,
212+ command : 'storage-mcp' ,
213+ } ,
214+ ] ,
215+ } ) ;
216+
217+ expect ( consoleLogSpy ) . not . toHaveBeenCalled ( ) ;
218+ expect ( consoleDebugSpy ) . not . toHaveBeenCalled ( ) ;
219+ } finally {
220+ consoleLogSpy . mockRestore ( ) ;
221+ consoleDebugSpy . mockRestore ( ) ;
222+ }
223+ } ) ;
169224} ) ;
0 commit comments