Skip to content
Open
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
15 changes: 15 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ process.on('SIGTERM', () => {
process.exit(0);
});

// Handle MCP stdio transport close. The MCP protocol's standard shutdown
// signal is stdin close on the stdio transport, not POSIX signals. Without
// these handlers, parent disconnect (e.g. `claude -p` exit) leaves cclsp
// and its spawned LSP children orphaned, accumulating memory across
// long-running parent sessions. See issue #47.
process.stdin.on('close', () => {
lspClient.dispose();
process.exit(0);
});

process.stdin.on('end', () => {
lspClient.dispose();
process.exit(0);
});

async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
Expand Down