Improved for Visual Code on Ubuntu 2024 - #3
Open
diego-minguzzi-sw wants to merge 5 commits into
Open
Conversation
diego-minguzzi-sw
commented
Oct 8, 2025
- Added a small section on how to configure cplusplus_mcp with Visual Studio Code in Ubuntu 2024
- In Linux, when the MCP server is started, now it tries to load the most recent version of the library. In my installation, it loaded the version 15, which later raised an error, even though I had the version 20 installed. So I added the function _find_latest_linux_libclang() in the cpp_mcp_server.py file.
- Added the script run_mcp_server.sh used to start the MCP server in Visual Studio Code.
andreymedv
referenced
this pull request
in andreymedv/clang_index_mcp
Nov 9, 2025
Root Cause:
When compile_commands.json was deleted after being loaded, the
get_compile_args() method continued to return cached compilation
arguments from the deleted file. The cache persisted even though
the source file no longer existed, preventing fallback to
hardcoded arguments.
The issue was that get_compile_args() only checked the in-memory
cache but never verified if the compile_commands.json file still
existed on disk. This created a situation where:
1. File is loaded and cached
2. File is deleted
3. Cache still returns stale data from deleted file
4. get_compile_args_with_fallback() gets cached data instead of None
5. Fallback arguments are never used
Test Failure:
test_fallback_behavior created a compile_commands.json file,
loaded it into the manager, then deleted the file. It expected
get_compile_args_with_fallback() to return fallback arguments
(containing '-DNOMINMAX'), but instead got the cached arguments
from the deleted file ('['-std=c++17', '-I', 'include']').
Solution:
Added file existence check in get_compile_args() before returning
cached data:
- Check if compile_commands.json exists before checking cache
- If file doesn't exist, return None immediately
- This allows get_compile_args_with_fallback() to properly fall back
- Works in conjunction with Fix #5 (refresh_if_needed cache clearing)
The fix ensures that when the compile_commands.json file is removed,
the system properly falls back to hardcoded compilation arguments
instead of using stale cached data.
Result:
- test_fallback_behavior now passes
- Cached data is not returned when source file is deleted
- Fallback arguments properly activated when compile_commands.json removed
- System behavior is more robust to file deletion scenarios
Status: 3-4 test failures remaining (down from 4, one test may be flaky)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.