```
> /mcp__serena__initial_instructions
⎿ You are a professional coding agent concerned with one particular codebase. You have
access to semantic coding tools on which you rely heavily for all your work, as well as collection of memory
files containing general information about the codebase. You operate in a frugal and intelligent manner, always
… +186 lines (ctrl+r to expand)
● I'm ready to help you with any coding tasks in the Serena codebase, jjshanks. I have access to semantic code analysis tools and can work
on modifications, analysis, or any other development tasks you need. What would you like me to work on?
```
Summary
Fixes X11/XCB crash when running serena-mcp-server in directories without source files
Adds headless environment detection to prevent GUI operations in SSH/WSL/Docker environments
Improves error messages to provide clear guidance when no source files are found
Problem
When running serena-mcp-server --context ide-assistant --project /empty/dir in a headless environment (SSH, WSL, Docker), the application would crash with X11/XCB errors:
[xcb] Unknown sequence number while appending request
[xcb] You called XInitThreads, this is not your fault
[xcb] Aborting, sorry about that.
python: ../../src/xcb_io.c:157: append_pending_request: Assertion `\!xcb_xlib_unknown_seq_number' failed.
Root Cause
Empty directories cause ProjectConfig.autogenerate() to raise a ValueError
The exception handler attempts to show a GUI error dialog using tkinter
In headless environments, tkinter crashes with X11/XCB errors
Solution
Headless Detection: Added is_headless_environment() to detect when running without a display
Skip GUI in Headless: Modified show_fatal_exception_safe() to skip GUI attempts in headless environments
Better Error Messages: Improved the error message for empty projects with clear instructions
* Added notion of internal SerenaAgentModes, which cannot be enabled dynamically
* Introduce 'jetbrains' SerenaAgentMode
* Add 'jetbrains' option to SerenaConfig, which enables the respective mode at
startup, appropriately configuring the set of exposed tools
* Refactoring: Made ToolSet immutable; methods return new instances
* In addition to exclusion, support notion of "optional tools" that
are disabled by default and enabled only upon request
* Unify the handling of inclusions/exclusions across
- SerenaConfig
- ProjectConfig
- SerenaAgentContext
- SerenaAgentMode
* Make ToolRegistry a singleton and simplify all related operations