Skip to content

Failed to connect in Claude code #494

Description

@AkideLiu

I have:

  • Read the readme and verified that the issue cannot be solved by adjusting configuration
  • Understood that Serena's dashboard can be disabled through the config
  • Understood that by default a client session will start a separate instance of a Serena server.
  • Understood that for multi-agent setups, the SSE mode should be used.
  • Verified that non-project files are ignored using either gitignore or the corresponding setting in .serena/project.yml
  • Have looked for similar issues and discussions, including closed ones
  • Made sure it's an actual issue and not a question - those should be opened as discussion instead.

If you have encountered a real and new issue:

  • I performed <uv invocation> serena project health-check
  • I indexed the project as described in the readme
  • Added sufficient explanation of my setup: the MCP client, the OS, the programming language, any config adjustments or relevant project specifics
  • Explained how the issue arose, added instructions on how to reproduce it (if possible)
  • If the issue happens on an open source project, I have added the link
  • Wrote a meaningful title and description

I have installed the mcp by claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd)

after start the claude code, it shows the mcp server failed to connect error :

Image

the logs attached below :

INFO  2025-08-18 17:23:08,785 [MainThread] serena.cli:start_mcp_server:166 - Initializing Serena MCP server
INFO  2025-08-18 17:23:08,785 [MainThread] serena.cli:start_mcp_server:167 - Storing logs in /mnt/bn/cloud-project-hl/code/akide/.serena/logs/2025-08-18/mcp_20250818-172308.txt
INFO  2025-08-18 17:23:08,787 [MainThread] serena.config.serena_config:from_config_file:406 - Loading Serena configuration from /mnt/bn/cloud-project-hl/code/akide/.serena/serena_config.yml
INFO  2025-08-18 17:23:09,086 [MainThread] serena.agent:__init__:198 - Starting Serena server (version=0.1.4-6c811629-dirty, process id=3200400, parent process id=3200051)
INFO  2025-08-18 17:23:09,087 [MainThread] serena.agent:__init__:199 - Configuration file: /mnt/bn/cloud-project-hl/code/akide/.serena/serena_config.yml
INFO  2025-08-18 17:23:09,087 [MainThread] serena.agent:__init__:200 - Available projects: diffusion_decoder
INFO  2025-08-18 17:23:09,087 [MainThread] serena.agent:__init__:201 - Loaded tools (36): read_file, create_text_file, list_dir, find_file, replace_regex, delete_lines, replace_lines, insert_at_line, search_for_pattern, restart_language_server, get_symbols_overview, find_symbol, find_referencing_symbols, replace_symbol_body, insert_after_symbol, insert_before_symbol, write_memory, read_memory, list_memories, delete_memory, execute_shell_command, activate_project, remove_project, switch_modes, get_current_config, check_onboarding_performed, onboarding, think_about_collected_information, think_about_task_adherence, think_about_whether_you_are_done, summarize_changes, prepare_for_new_conversation, initial_instructions, jet_brains_find_symbol, jet_brains_find_referencing_symbols, jet_brains_get_symbols_overview
INFO  2025-08-18 17:23:09,087 [MainThread] serena.config.serena_config:start:329 - Loading project instance for RegisteredProject[project_root=/mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder, project_config=ProjectConfig[project_name='diffusion_decoder']] starting ...
INFO  2025-08-18 17:23:09,087 [MainThread] serena.project:__init__:31 - Parsing all gitignore files in /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder
INFO  2025-08-18 17:23:46,401 [MainThread] serena.project:__init__:33 - Found 2 gitignore files.
INFO  2025-08-18 17:23:46,402 [MainThread] serena.config.serena_config:stop:336 - Loading project instance for RegisteredProject[project_root=/mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder, project_config=ProjectConfig[project_name='diffusion_decoder']] completed in 37.315 seconds
INFO  2025-08-18 17:23:46,402 [MainThread] serena.agent:load_project_from_path_or_name:469 - Found registered project 'diffusion_decoder' at path /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder
INFO  2025-08-18 17:23:46,402 [MainThread] serena.config.serena_config:apply:108 - SerenaAgentContext[name='ide-assistant'] excluded 5 tools: create_text_file, read_file, execute_shell_command, prepare_for_new_conversation, replace_regex
INFO  2025-08-18 17:23:46,403 [MainThread] serena.config.serena_config:apply:108 - ToolInclusionDefinition(excluded_tools=['activate_project'], included_optional_tools=()) excluded 1 tools: activate_project
INFO  2025-08-18 17:23:46,459 [MainThread] serena.agent:__init__:215 - Number of exposed tools: 18
INFO  2025-08-18 17:23:46,488 [MainThread] serena.agent:_update_active_tools:397 - Active tools (18): check_onboarding_performed, delete_memory, find_file, find_referencing_symbols, find_symbol, get_symbols_overview, insert_after_symbol, insert_before_symbol, list_dir, list_memories, onboarding, read_memory, replace_symbol_body, search_for_pattern, think_about_collected_information, think_about_task_adherence, think_about_whether_you_are_done, write_memory
INFO  2025-08-18 17:23:46,488 [MainThread] serena.agent:load_project_from_path_or_name:469 - Found registered project 'diffusion_decoder' at path /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder
INFO  2025-08-18 17:23:46,488 [MainThread] serena.agent:_activate_project:437 - Activating diffusion_decoder at /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder
INFO  2025-08-18 17:23:46,489 [MainThread] serena.agent:_update_active_tools:397 - Active tools (18): check_onboarding_performed, delete_memory, find_file, find_referencing_symbols, find_symbol, get_symbols_overview, insert_after_symbol, insert_before_symbol, list_dir, list_memories, onboarding, read_memory, replace_symbol_body, search_for_pattern, think_about_collected_information, think_about_task_adherence, think_about_whether_you_are_done, write_memory
INFO  2025-08-18 17:23:46,489 [MainThread] serena.agent:issue_task:416 - Scheduling Task-1[init_language_server]
INFO  2025-08-18 17:23:46,490 [SerenaAgentExecutor_0] serena.agent:start:329 - Task-1[init_language_server] starting ...
INFO  2025-08-18 17:23:46,490 [MainThread] serena.agent:create_system_prompt:369 - Generating system prompt with available_tools=(see exposed tools), available_markers={'ToolMarkerCanEdit', 'InsertBeforeSymbolTool', 'ToolMarkerSymbolicEdit', 'ReplaceSymbolBodyTool', 'FindReferencingSymbolsTool', 'FindSymbolTool', 'GetSymbolsOverviewTool', 'InsertAfterSymbolTool', 'ToolMarkerSymbolicRead'}
INFO  2025-08-18 17:23:46,490 [SerenaAgentExecutor_0] serena.agent:start:329 - Language server initialization starting ...
INFO  2025-08-18 17:23:46,493 [MainThread] serena.agent:create_system_prompt:376 - System prompt:
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 resource-efficient and intelligent manner, always
keeping in mind to not read or generate content that is not needed for the task at hand.

When reading code in order to answer a user question or task, you should try reading only the necessary code. 
Some tasks may require you to understand the architecture of large parts of the codebase, while for others,
it may be enough to read a small set of symbols or a single file.
Generally, you should avoid reading entire files unless it is absolutely necessary, instead relying on
intelligent step-by-step acquisition of information. However, if you already read a file, it does not make
sense to further analyse it with the symbolic tools (except for the `find_referencing_symbols` tool), 
as you already have the information.

I WILL BE SERIOUSLY UPSET IF YOU READ ENTIRE FILES WITHOUT NEED!

CONSIDER INSTEAD USING THE OVERVIEW TOOL AND SYMBOLIC TOOLS TO READ ONLY THE NECESSARY CODE FIRST!
I WILL BE EVEN MORE UPSET IF AFTER HAVING READ AN ENTIRE FILE YOU KEEP READING THE SAME CONTENT WITH THE SYMBOLIC TOOLS!
THE PURPOSE OF THE SYMBOLIC TOOLS IS TO HAVE TO READ LESS CODE, NOT READ THE SAME CONTENT MULTIPLE TIMES!


You can achieve the intelligent reading of code by using the symbolic tools for getting an overview of symbols and
the relations between them, and then only reading the bodies of symbols that are necessary to answer the question 
or complete the task. 
You can use the standard tools like list_dir, find_file and search_for_pattern if you need to.
When tools allow it, you pass the `relative_path` parameter to restrict the search to a specific file or directory.
For some tools, `relative_path` can only be a file path, so make sure to properly read the tool descriptions.

If you are unsure about a symbol's name or location (to the extent that substring_matching for the symbol name is not enough), you can use the `search_for_pattern` tool, which allows fast
and flexible search for patterns in the codebase.This way you can first find candidates for symbols or files,
and then proceed with the symbolic tools.



Symbols are identified by their `name_path and `relative_path`, see the description of the `find_symbol` tool for more details
on how the `name_path` matches symbols.
You can get information about available symbols by using the `get_symbols_overview` tool for finding top-level symbols in a file,
or by using `find_symbol` if you already know the symbol's name path. You generally try to read as little code as possible
while still solving your task, meaning you only read the bodies when you need to, and after you have found the symbol you want to edit.
For example, if you are working with python code and already know that you need to read the body of the constructor of the class Foo, you can directly
use `find_symbol` with the name path `Foo/__init__` and `include_body=True`. If you don't know yet which methods in `Foo` you need to read or edit,
you can use `find_symbol` with the name path `Foo`, `include_body=False` and `depth=1` to get all (top-level) methods of `Foo` before proceeding
to read the desired methods with `include_body=True`
You can understand relationships between symbols by using the `find_referencing_symbols` tool.



You generally have access to memories and it may be useful for you to read them, but also only if they help you
to answer the question or complete the task. You can infer which memories are relevant to the current task by reading
the memory names and descriptions.


The context and modes of operation are described below. From them you can infer how to interact with your user
and which tasks and kinds of interactions are expected of you.

Context description:
You are running in IDE assistant context where file operations, basic (line-based) edits and reads, 
and shell commands are handled by your own, internal tools.
The initial instructions and the current config inform you on which tools are available to you,
and how to use them.
Don't attempt to use any excluded tools, instead rely on your own internal tools
for achieving the basic file or shell operations.

If serena's tools can be used for achieving your task, 
you should prioritize them. In particular, it is important that you avoid reading entire source code files,
unless it is strictly necessary! Instead, for exploring and reading code in a token-efficient manner, 
you should use serena's overview and symbolic search tools. The call of the read_file tool on an entire source code 
file should only happen in exceptional cases, usually you should first explore the file (by itself or as part of exploring
the directory containing it) using the symbol_overview tool, and then make targeted reads using find_symbol and other symbolic tools.
For non-code files or for reads where you don't know the symbol's name path you can use the patterns searching tool,
using the read_file as a last resort.

Modes descriptions:

- You are operating in interactive mode. You should engage with the user throughout the task, asking for clarification
whenever anything is unclear, insufficiently specified, or ambiguous.

Break down complex tasks into smaller steps and explain your thinking at each stage. When you're uncertain about
a decision, present options to the user and ask for guidance rather than making assumptions.

Focus on providing informative results for intermediate steps so the user can follow along with your progress and
provide feedback as needed.

- You are operating in editing mode. You can edit files with the provided tools
to implement the requested changes to the code base while adhering to the project's code style and patterns.
Use symbolic editing tools whenever possible for precise code modifications.
If no editing task has yet been provided, wait for the user to provide one.

When writing new code, think about where it belongs best. Don't generate new files if you don't plan on actually
integrating them into the codebase, instead use the editing tools to insert the code directly into the existing files in that case.

You have two main approaches for editing code - editing by regex and editing by symbol.
The symbol-based approach is appropriate if you need to adjust an entire symbol, e.g. a method, a class, a function, etc.
But it is not appropriate if you need to adjust just a few lines of code within a symbol, for that you should
use the regex-based approach that is described below.

Let us first discuss the symbol-based approach.
Symbols are identified by their name path and relative file path, see the description of the `find_symbol` tool for more details
on how the `name_path` matches symbols.
You can get information about available symbols by using the `get_symbols_overview` tool for finding top-level symbols in a file,
or by using `find_symbol` if you already know the symbol's name path. You generally try to read as little code as possible
while still solving your task, meaning you only read the bodies when you need to, and after you have found the symbol you want to edit.
Before calling symbolic reading tools, you should have a basic understanding of the repository structure that you can get from memories
or by using the `list_dir` and `find_file` tools (or similar).
For example, if you are working with python code and already know that you need to read the body of the constructor of the class Foo, you can directly
use `find_symbol` with the name path `Foo/__init__` and `include_body=True`. If you don't know yet which methods in `Foo` you need to read or edit,
you can use `find_symbol` with the name path `Foo`, `include_body=False` and `depth=1` to get all (top-level) methods of `Foo` before proceeding
to read the desired methods with `include_body=True`.
In particular, keep in mind the description of the `replace_symbol_body` tool. If you want to add some new code at the end of the file, you should
use the `insert_after_symbol` tool with the last top-level symbol in the file. If you want to add an import, often a good strategy is to use
`insert_before_symbol` with the first top-level symbol in the file.
You can understand relationships between symbols by using the `find_referencing_symbols` tool. If not explicitly requested otherwise by a user,
you make sure that when you edit a symbol, it is either done in a backward-compatible way, or you find and adjust the references as needed.
The `find_referencing_symbols` tool will give you code snippets around the references, as well as symbolic information.
You will generally be able to use the info from the snippets and the regex-based approach to adjust the references as well.
You can assume that all symbol editing tools are reliable, so you don't need to verify the results if the tool returns without error.



INFO  2025-08-18 17:23:46,493 [SerenaAgentExecutor_0] serena.project:create_language_server:285 - Creating language server instance for /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder.
INFO  2025-08-18 17:23:46,496 [MainThread] serena.cli:start_mcp_server:185 - Starting MCP server …
INFO  2025-08-18 17:23:46,547 [MainThread] serena.mcp:_set_mcp_tools:231 - Starting MCP server with 18 tools: ['list_dir', 'find_file', 'search_for_pattern', 'get_symbols_overview', 'find_symbol', 'find_referencing_symbols', 'replace_symbol_body', 'insert_after_symbol', 'insert_before_symbol', 'write_memory', 'read_memory', 'list_memories', 'delete_memory', 'check_onboarding_performed', 'onboarding', 'think_about_collected_information', 'think_about_task_adherence', 'think_about_whether_you_are_done']
INFO  2025-08-18 17:23:46,548 [MainThread] serena.mcp:server_lifespan:338 - MCP server lifetime setup complete
INFO  2025-08-18 17:23:47,465 [SerenaAgentExecutor_0] solidlsp:load_cache:1638 - Loading document symbols cache from /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder/.serena/cache/python/document_symbols_cache_v23-06-25.pkl
INFO  2025-08-18 17:23:47,644 [SerenaAgentExecutor_0] solidlsp:load_cache:1642 - Loaded 198 document symbols from cache.
INFO  2025-08-18 17:23:47,646 [SerenaAgentExecutor_0] serena.agent:reset_language_server:589 - Starting the language server for diffusion_decoder
INFO  2025-08-18 17:23:47,646 [SerenaAgentExecutor_0] solidlsp:start:1684 - Starting language server with language python for /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder
INFO  2025-08-18 17:23:47,646 [SerenaAgentExecutor_0] solidlsp:_start_server:172 - Starting pyright-langserver server process
INFO  2025-08-18 17:23:47,647 [SerenaAgentExecutor_0] solidlsp.ls_handler:start:189 - Starting language server process via command: python -m pyright.langserver --stdio
INFO  2025-08-18 17:23:47,650 [SerenaAgentExecutor_0] solidlsp:_start_server:178 - Sending initialize request from LSP client to pyright server and awaiting response
INFO  2025-08-18 17:23:48,375 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Pyright language server 1.1.403 starting
INFO  2025-08-18 17:23:48,376 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Server root directory: file:///mnt/bn/cloud-project-hl/code/akide/.cache/uv/archive-v0/vf6zGoo-46ab_ZGB4EkSE/lib/python3.11/site-packages/pyright/dist/dist
INFO  2025-08-18 17:23:48,377 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Starting service instance "diffusion_decoder"
INFO  2025-08-18 17:23:48,377 [SerenaAgentExecutor_0] solidlsp:_start_server:183 - Received initialize response from pyright server: {"capabilities": {"textDocumentSync": 2, "definitionProvider": {"workDoneProgress": True}, "declarationProvider": {"workDoneProgress": True}, "typeDefinitionProvider": {"workDoneProgress": True}, "referencesProvider": {"workDoneProgress": True}, "documentSymbolProvider": {"workDoneProgress": True}, "workspaceSymbolProvider": {"workDoneProgress": True}, "hoverProvider": {"workDoneProgress": True}, "documentHighlightProvider": {"workDoneProgress": True}, "renameProvider": {"prepareProvider": True, "workDoneProgress": True}, "completionProvider": {"triggerCharacters": [".", "[", """, """], "resolveProvider": True, "workDoneProgress": True, "completionItem": {"labelDetailsSupport": True}}, "signatureHelpProvider": {"triggerCharacters": ["(", ",", ")"], "workDoneProgress": True}, "codeActionProvider": {"codeActionKinds": ["quickfix", "source.organizeImports"], "workDoneProgress": True}, "executeCommandProvider": {"commands": [], "workDoneProgress": True}, "callHierarchyProvider": True, "workspace": {"workspaceFolders": {"supported": True, "changeNotifications": True}}}}
INFO  2025-08-18 17:23:48,378 [SerenaAgentExecutor_0] solidlsp:_start_server:195 - Waiting for Pyright to complete initial workspace analysis...
WARNING 2025-08-18 17:23:53,379 [SerenaAgentExecutor_0] solidlsp:_start_server:199 - Timeout waiting for Pyright analysis completion, proceeding anyway
INFO  2025-08-18 17:23:53,379 [SerenaAgentExecutor_0] serena.agent:stop:336 - Language server initialization completed in 6.889 seconds
INFO  2025-08-18 17:23:53,379 [SerenaAgentExecutor_0] serena.agent:stop:336 - Task-1[init_language_server] completed in 6.889 seconds
INFO  2025-08-18 17:23:56,978 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: No include entries specified; assuming /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder
INFO  2025-08-18 17:23:56,979 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Auto-excluding **/node_modules
INFO  2025-08-18 17:23:56,979 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Auto-excluding **/__pycache__
INFO  2025-08-18 17:23:56,980 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Auto-excluding **/.*
INFO  2025-08-18 17:23:56,980 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Assuming Python version 3.11.13.final.0
INFO  2025-08-18 17:23:56,980 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Auto-excluding /mnt/bn/cloud-project-hl/code/akide/code/diffusion_decoder/dc1d
INFO  2025-08-18 17:23:56,981 [LSP-stdout-reader] solidlsp:window_log_message:142 - LSP: window/logMessage: Found 865 source files
INFO  2025-08-18 17:23:56,981 [LSP-stdout-reader] solidlsp:window_log_message:147 - Pyright workspace scanning complete

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions