@@ -322,6 +322,46 @@ test("SessionManager lists project skills from .agents with legacy .deepcode com
322322 assert . equal ( sharedSkill ?. description , "Project .agents skill" ) ;
323323} ) ;
324324
325+ test ( "SessionManager dispose disconnects MCP servers" , async ( ) => {
326+ const workspace = createTempDir ( "deepcode-mcp-dispose-workspace-" ) ;
327+ const serverPath = path . join ( workspace , "mcp-server.cjs" ) ;
328+ fs . writeFileSync (
329+ serverPath ,
330+ `
331+ const readline = require("readline");
332+ const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
333+ function send(message) {
334+ process.stdout.write(JSON.stringify(message) + "\\n");
335+ }
336+ rl.on("line", (line) => {
337+ const request = JSON.parse(line);
338+ if (!("id" in request)) {
339+ return;
340+ }
341+ if (request.method === "initialize") {
342+ send({ jsonrpc: "2.0", id: request.id, result: { protocolVersion: "2024-11-05", capabilities: { tools: {} } } });
343+ return;
344+ }
345+ if (request.method === "tools/list") {
346+ send({ jsonrpc: "2.0", id: request.id, result: { tools: [{ name: "echo", inputSchema: { type: "object", properties: {} } }] } });
347+ return;
348+ }
349+ send({ jsonrpc: "2.0", id: request.id, result: { content: [] } });
350+ });
351+ ` ,
352+ "utf8"
353+ ) ;
354+
355+ const manager = createSessionManager ( workspace , "machine-id-mcp-dispose" ) ;
356+ await manager . initMcpServers ( { smoke : { command : process . execPath , args : [ serverPath ] } } ) ;
357+
358+ assert . deepEqual ( manager . getMcpStatus ( ) , [ { name : "smoke" , connected : true , toolCount : 1 , tools : [ "echo" ] } ] ) ;
359+
360+ manager . dispose ( ) ;
361+
362+ assert . deepEqual ( manager . getMcpStatus ( ) , [ ] ) ;
363+ } ) ;
364+
325365test ( "createSession stores /init and sends the active .deepcode project AGENTS path to the LLM" , async ( ) => {
326366 const workspace = createTempDir ( "deepcode-init-deepcode-workspace-" ) ;
327367 const home = createTempDir ( "deepcode-init-deepcode-home-" ) ;
0 commit comments