diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 00000000..e62d5cd2 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,63 @@ +name: Docs Build + +on: + push: + branches: [ main ] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install uv + run: pip install uv + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/uv + key: uv-${{ hashFiles('pyproject.toml') }} + + - name: Install dependencies + run: | + uv venv + uv pip install -e ".[dev]" + + - name: Build docs + run: uv run poe doc-build + continue-on-error: false + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/_build + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/lint_and_docs.yaml b/.github/workflows/lint_and_docs.yaml deleted file mode 100644 index daef60c8..00000000 --- a/.github/workflows/lint_and_docs.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Linting, Types and Docs Check - -on: - workflow_dispatch: # Manual trigger only - workflow disabled from auto-running - -jobs: - check: - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - id-token: write - pages: write - actions: write - contents: read - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - - # use uv package manager - - name: Install uv - run: pip install uv - - uses: actions/cache@v3 - name: Cache dependencies - with: - path: ~/.cache/uv - key: uv-${{ hashFiles('pyproject.toml') }} - - name: Install dependencies - run: | - uv venv - uv pip install -e ".[dev]" - - name: Lint - run: uv run poe lint - - name: Types - run: uv run poe type-check - - name: Docs - run: uv run poe doc-build - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - path: "docs/_build" - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 6261a79e..22209e48 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -154,6 +154,40 @@ jobs: - name: Install Julia LanguageServer shell: bash run: julia -e 'using Pkg; Pkg.add("LanguageServer")' + - name: Setup Haskell toolchain + if: runner.os != 'Windows' + uses: haskell/ghcup-setup@v1 + with: + ghc: '9.12.2' + cabal: '3.10.3.0' + hls: '2.11.0.0' + - name: Verify Haskell tools + if: runner.os != 'Windows' + run: | + echo "Verifying installed Haskell tools:" + which ghc && ghc --version + which cabal && cabal --version + # HLS verification - non-blocking in case of version incompatibility + if command -v haskell-language-server-wrapper &>/dev/null; then + echo "Found haskell-language-server-wrapper" + haskell-language-server-wrapper --version || echo "WARNING: HLS wrapper found but version check failed" + elif command -v haskell-language-server &>/dev/null; then + echo "Found haskell-language-server" + haskell-language-server --version || echo "WARNING: HLS found but version check failed" + else + echo "WARNING: HLS not found (may be incompatible with GHC 9.12.2)" + echo "This is not a critical error - tests will use HLS if available at runtime" + fi + shell: bash + - name: Pre-build Haskell test project for HLS + if: runner.os != 'Windows' + run: | + cd test/resources/repos/haskell/test_repo + cabal update + cabal build --only-dependencies + cabal build + echo "Haskell test project built successfully" + shell: bash - name: Install Zig uses: goto-bus-stop/setup-zig@v2 with: diff --git a/.gitignore b/.gitignore index 32386b39..89bbe0b2 100644 --- a/.gitignore +++ b/.gitignore @@ -200,6 +200,7 @@ pylint.html /*.yml !*.template.yml /agent-ui +/test/**/.serena # dynamic LS installations /src/multilspy/language_servers/*/static @@ -215,9 +216,11 @@ pylint.html # Cache is in .multilspy **/.multilspy/** +# temporary and backup files +*.bak +*.tmp tmp/ -.serena/ .vscode/ # Claude settings @@ -248,4 +251,12 @@ tmp/ .scala-build/ .bloop/ bootstrap -test/resources/repos/scala/.bloop/ \ No newline at end of file +test/resources/repos/scala/.bloop/ + +# Haskell +.stack-work/ +*.cabal +stack.yaml.lock +dist-newstyle/ +cabal.project.local* +.ghc.environment.* \ No newline at end of file diff --git a/.serena/.gitignore b/.serena/.gitignore new file mode 100644 index 00000000..14d86ad6 --- /dev/null +++ b/.serena/.gitignore @@ -0,0 +1 @@ +/cache diff --git a/.serena/project.yml b/.serena/project.yml index a265810e..edba1eeb 100644 --- a/.serena/project.yml +++ b/.serena/project.yml @@ -1,11 +1,5 @@ -# language of the project (csharp, python, rust, java, typescript, javascript, go, cpp, or ruby) -# Special requirements: -# * csharp: Requires the presence of a .sln file in the project folder. -language: python - -# whether to use the project's gitignore file to ignore files -# Added on 2025-04-07 ignore_all_files_in_gitignore: true + # list of additional paths to ignore # same syntax as gitignore, so you can use * and ** # Was previously called `ignored_dirs`, please update your config if you are using that. @@ -64,3 +58,8 @@ excluded_tools: [] initial_prompt: "" project_name: "serena" +languages: +- python +- typescript +included_optional_tools: [] +encoding: utf-8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 91963c29..d8137826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,43 @@ # latest Status of the `main` branch. Changes prior to the next official version change will appear here. + +* General: + * Add monorepo/multi-language support + * Project configuration files (`project.yml`) can now define multiple languages. + Auto-detection adds only the most prominent language by default. + * Additional languages can be conveniently added via the Dashboard while a project is already activated. + * Support overloaded symbols in `FindSymbolTool` and related tools + * Name paths of overloaded symbols now include an index (e.g., `myOverloadedFunction[2]`) + * Responses of the Java language server, which handled this in its own way, are now adapted accordingly, + solving several issues related to retrieval problems in Java projects + * Major extensions to the dashboard, which now serves as a central web interface for Serena + * View current configuration + * View the executions, with the possibility to cancel running/scheduled executions + * View tool usage statistics + * View and create memories and edit the serena configuration file + * New two-tier caching of language server document symbols and considerable performance improvements surrounding symbol retrieval/indexing + * Various fixes related to indexing, special paths and determination of ignored paths + * Decreased `TOOL_DEFAULT_MAX_ANSWER_LENGTH` to be in accordance with (below) typical max-tokens configurations + * Allow passing language server specific settings through `ls_specific_settings` field (in `serena_config.yml`) + * Add notion of a "single-project context" (flag `single_project`), allowing user-defined contexts to behave + like the built-in `ide-assistant` context (where the available tools are restricted to ones required by the active + project and project changes are disabled) + +* Client support: + * New mode `oaicompat-agent` and extensions enhancing OpenAI tool compatibility, permitting Serena to work with llama.cpp + * Tools: * Added `RenameSymbolTool` for renaming symbols across the codebase (if LS supports this operation). + * Replaced `ReplaceRegexTool` with `ReplaceContentTool`, which supports both plain text and regex-based replacements + (and which requires no escaping in the replacement text, making it more robust) * Language support: - * **Add support for Scala** via Metals language server (requires some [manual setup](docs/scala_setup_guide_for_serena.md)) + + * **Add support for Fortran** via fortls language server (requires `pip install fortls`) + * **Add support for Julia** via LanguageServer.jl + * **Add support for Haskell** via Haskell Language Server (HLS) with automatic discovery via ghcup, stack, or system PATH; supports both Stack and Cabal projects + * **Add support for Scala** via Metals language server (requires some [manual setup](docs/03-special-guides/scala_setup_guide_for_serena.md)) * **Add support for Elm** via @elm-tooling/elm-language-server (automatically downloads if not installed; requires Elm compiler) * **Add support for Perl** via Perl::LanguageServer with LSP integration for .pl, .pm, and .t files * **Add support for AL (Application Language)** for Microsoft Dynamics 365 Business Central development. Requires VS Code AL extension (ms-dynamics-smb.al). @@ -13,19 +45,13 @@ Status of the `main` branch. Changes prior to the next official version change w * **Add support for Zig** via ZLS (cross-file references may not fully work on Windows) * **Add support for Lua** via lua-language-server * **Add support for Nix** requires nixd installation (Windows not supported) + * **Add experimental support for YAML** via yaml-language-server with LSP integration for .yaml and .yml files * **Dart now officially supported**: Dart was always working, but now tests were added, and it is promoted to "officially supported" * **Rust now uses already installed rustup**: The rust-analyzer is no longer bundled with Serena. Instead, it uses the rust-analyzer from your Rust toolchain managed by rustup. This ensures compatibility with your Rust version and eliminates outdated bundled binaries. - * **Kotlin now officially supported**: We now use the official Kotlin LS, tests run through and performance is good, even though the LS is in an early development stage. + * **Kotlin now officially supported**: We now use the official Kotlin LS, tests run through and performance is good, even though the LS is in an early development stage. * **Add support for Erlang** experimental, may hang or be slow, uses the recently archived [erlang_ls](https://github.com/erlang-ls/erlang_ls) * **Ruby dual language server support**: Added ruby-lsp as the modern primary Ruby language server. Solargraph remains available as an experimental legacy option. ruby-lsp supports both .rb and .erb files, while Solargraph supports .rb files only. -* Client support: - * New mode `oaicompat-agent` and extensions in the openai tool compatibility, **permitting Serena to work with llama.cpp** - -* General: - * Various fixes related to indexing, special paths and determation of ignored paths - * Decreased `TOOL_DEFAULT_MAX_ANSWER_LENGTH` to be in accordance with (below) typical max-tokens configurations - * Allow passing language server specific settings through `ls_specific_settings` field (in `serena_config.yml`) # 0.1.4 diff --git a/README.md b/README.md index 8e33859f..92970158 100644 --- a/README.md +++ b/README.md @@ -8,46 +8,39 @@ * :wrench: Serena provides essential **semantic code retrieval and editing tools** that are akin to an IDE's capabilities, extracting code entities at the symbol level and exploiting relational structure. When combined with an existing coding agent, these tools greatly enhance (token) efficiency. * :free: Serena is **free & open-source**, enhancing the capabilities of LLMs you already have access to free of charge. -You can think of Serena as providing IDE-like tools to your LLM/coding agent. With it, the agent no longer needs to read entire -files, perform grep-like searches or string replacements to find and edit the right code. Instead, it can use code centered tools like `find_symbol`, `find_referencing_symbols` and `insert_after_symbol`. +You can think of Serena as providing IDE-like tools to your LLM/coding agent. +With it, the agent no longer needs to read entire files, perform grep-like searches or basic string replacements to find the right parts of the code and to edit code. +Instead, it can use code-centric tools like `find_symbol`, `find_referencing_symbols` and `insert_after_symbol`.
Serena is under active development! See the latest updates, upcoming features, and lessons learned to stay up to date.
-### LLM Integration +## LLM Integration -Serena provides the necessary [tools](#list-of-tools) for coding workflows, but an LLM is required to do the actual work, +Serena provides the necessary [tools](https://oraios.github.io/serena/01-about/035_tools.html) for coding workflows, but an LLM is required to do the actual work, orchestrating tool use. -For example, **supercharge the performance of Claude Code** with a [one-line shell command](#claude-code). - In general, Serena can be integrated with an LLM in several ways: * by using the **model context protocol (MCP)**. Serena provides an MCP server which integrates with * Claude Code and Claude Desktop, - * Terminal-based clients like Codex, Gemini-CLI, Qwen3-Coder, rovodev, OpenHands CLI and others, + * terminal-based clients like Codex, Gemini-CLI, Qwen3-Coder, rovodev, OpenHands CLI and others, * IDEs like VSCode, Cursor or IntelliJ, * Extensions like Cline or Roo Code * Local clients like [OpenWebUI](https://docs.openwebui.com/openapi-servers/mcp), [Jan](https://jan.ai/docs/mcp-examples/browser/browserbase#enable-mcp), [Agno](https://docs.agno.com/introduction/playground) and others -* by using [mcpo to connect it to ChatGPT](docs/serena_on_chatgpt.md) or other clients that don't support MCP but do support tool calling via OpenAPI. -* by incorporating Serena's tools into an agent framework of your choice, as illustrated [here](docs/custom_agent.md). +* by using [mcpo to connect it to ChatGPT](docs/03-special-guides/serena_on_chatgpt.md) or other clients that don't support MCP but do support tool calling via OpenAPI. +* by incorporating Serena's tools into an agent framework of your choice, as illustrated [here](docs/03-special-guides/custom_agent.md). Serena's tool implementation is decoupled from the framework-specific code and can thus easily be adapted to any agent framework. -### Serena in Action +## Serena in Action #### Demonstration 1: Efficient Operation in Claude Code @@ -74,44 +67,45 @@ complex projects! So not only is it free and open-source, it frequently achieves than existing solutions that charge a premium. Language servers provide support for a wide range of programming languages. -With Serena, we provide direct, out-of-the-box support for: +With Serena's LSP library, we provide **support for over 30 programming languages**, including +AL, Bash, C#, C/C++, Clojure, Dart, Elixir, Elm, Erlang, Fortran, Go, Haskell, Java, Javascript, Julia, Kotlin, Lua, Markdown, Nix, Perl, PHP, Python, R, Ruby, Rust, Scala, Swift, TypeScript, YAML and Zig. - * Python - * TypeScript/Javascript - * PHP (uses Intelephense LSP; set `INTELEPHENSE_LICENSE_KEY` environment variable for premium features) - * Go (requires installation of gopls) - * R (requires installation of the `languageserver` R package) - * Rust (requires [rustup](https://rustup.rs/) - uses rust-analyzer from your toolchain) - * C/C++ (you may experience issues with finding references, we are working on it) - * Zig (requires installation of ZLS - Zig Language Server) - * C# - * Ruby (by default, uses [ruby-lsp](https://github.com/Shopify/ruby-lsp), specify ruby_solargraph as your language to use the previous solargraph based implementation) - * Swift - * Kotlin (uses the pre-alpha [official kotlin LS](https://github.com/Kotlin/kotlin-lsp), some issues may appear) - * Java (_Note_: startup is slow, initial startup especially so. There may be issues with java on macos and linux, we are working on it.) - * Clojure - * Dart - * Bash - * Lua (automatically downloads lua-language-server if not installed) - * Nix (requires nixd installation) - * Elixir (requires installation of NextLS and Elixir; **Windows not supported**) - * Elm (automatically downloads elm-language-server if not installed; requires Elm compiler) - * Scala (requires some [manual setup](docs/scala_setup_guide_for_serena.md); uses Metals LSP) - * Erlang (requires installation of beam and [erlang_ls](https://github.com/erlang-ls/erlang_ls), experimental, might be slow or hang) - * Perl (requires installation of Perl::LanguageServer) - * AL - * Markdown (must be explicitly specified via `--language markdown` when generating project config, primarily useful for documentation-heavy projects) +> [!IMPORTANT] +> Some languages require additional dependencies to be installed; see the [Language Support](https://oraios.github.io/serena/01-about/020_programming-languages.html) page for details. -Support for further languages can easily be added by providing a shallow adapter for a new language server implementation, -see Serena's [memory on that](.serena/memories/adding_new_language_support_guide.md). +## Quick Start -### Community Feedback +**Prerequisites**. Serena is managed by *uv*. If you don’t already have it, you need to [install uv](https://docs.astral.sh/uv/getting-started/installation/) before proceeding. + +**Starting the MCP Server**. The easiest way to start the Serena MCP server is by running the latest version from GitHub using uvx. +Issue this command to see available options: + +```bash +uvx --from git+https://github.com/oraios/serena serena start-mcp-server --help +``` + +**Configuring Your Client**. To connect Serena to your preferred MCP client, you typically need to [configure a launch command in your client](https://oraios.github.io/serena/02-usage/030_clients.html). +Follow the link for specific instructions on how to set up Serena for Claude Code, Codex, Claude Desktop, MCP-enabled IDEs and other clients (such as local and web-based GUIs). + +> [!TIP] +> While getting started quickly is easy, Serena is a powerful toolkit with many configuration options. +> We highly recommend reading through the [user guide](https://oraios.github.io/serena/02-usage/000_intro.html) to get the most out of Serena. +> +> Specifically, we recommend to read about ... +> * [Serena's project-based workflow](https://oraios.github.io/serena/02-usage/040_workflow.html) and +> * [configuring Serena](https://oraios.github.io/serena/02-usage/050_configuration.html). + +## User Guide + +Please refer to the [user guide](https://oraios.github.io/serena/02-usage/000_intro.html) for detailed instructions on how to use Serena effectively. + +## Community Feedback Most users report that Serena has strong positive effects on the results of their coding agents, even when used within very capable agents like Claude Code. Serena is often described to be a [game changer](https://www.reddit.com/r/ClaudeAI/comments/1lfsdll/try_out_serena_mcp_thank_me_later/), providing an enormous [productivity boost](https://www.reddit.com/r/ClaudeCode/comments/1mguoia/absolutely_insane_improvement_of_claude_code). Serena excels at navigating and manipulating complex codebases, providing tools that support precise code retrieval and editing in the presence of large, strongly structured codebases. -However, when dealing with tasks that involve only very few/small files, you may not benefit from including Serena on top of your existing coding agent. +However, when dealing with tasks that involve only very few/small files, you may not benefit from including Serena on top of your existing coding agent. In particular, when writing code from scratch, Serena will not provide much value initially, as the more complex structures that Serena handles more gracefully than simplistic, file-based approaches are yet to be created. Several videos and blog posts have talked about Serena: @@ -126,673 +120,6 @@ Several videos and blog posts have talked about Serena: * [Serena with Claude Code (in Japanese)](https://blog.lai.so/serena/) * [Turning Claude Code into a Development Powerhouse](https://robertmarshall.dev/blog/turning-claude-code-into-a-development-powerhouse/) -## Table of Contents - - - - - - -- [Quick Start](#quick-start) - * [Running the Serena MCP Server](#running-the-serena-mcp-server) - + [Usage](#usage) - + [Using uvx](#using-uvx) - + [Local Installation](#local-installation) - + [Using Docker (Experimental)](#using-docker-experimental) - + [Using Nix](#using-nix) - + [Streamable HTTP Mode](#streamable-http-mode) - + [Command-Line Arguments](#command-line-arguments) - * [Configuration](#configuration) - * [Project Activation & Indexing](#project-activation--indexing) - * [Claude Code](#claude-code) - * [Codex](#codex) - * [Other Terminal-Based Clients](#other-terminal-based-clients) - * [Claude Desktop](#claude-desktop) - * [MCP Coding Clients (Cline, Roo-Code, Cursor, Windsurf, etc.)](#mcp-coding-clients-cline-roo-code-cursor-windsurf-etc) - * [Local GUIs and Frameworks](#local-guis-and-frameworks) -- [Detailed Usage and Recommendations](#detailed-usage-and-recommendations) - * [Tool Execution](#tool-execution) - + [Shell Execution and Editing Tools](#shell-execution-and-editing-tools) - * [Modes and Contexts](#modes-and-contexts) - + [Contexts](#contexts) - + [Modes](#modes) - + [Customization](#customization) - * [Onboarding and Memories](#onboarding-and-memories) - * [Prepare Your Project](#prepare-your-project) - + [Structure Your Codebase](#structure-your-codebase) - + [Start from a Clean State](#start-from-a-clean-state) - + [Logging, Linting, and Automated Tests](#logging-linting-and-automated-tests) - * [Prompting Strategies](#prompting-strategies) - * [Running Out of Context](#running-out-of-context) - * [Serena's Logs: The Dashboard and GUI Tool](#serenas-logs-the-dashboard-and-gui-tool) - * [Serena and GIT worktrees](#serena-and-git-worktrees) -- [Comparison with Other Coding Agents](#comparison-with-other-coding-agents) - * [Subscription-Based Coding Agents](#subscription-based-coding-agents) - * [API-Based Coding Agents](#api-based-coding-agents) - * [Other MCP-Based Coding Agents](#other-mcp-based-coding-agents) -- [Acknowledgements](#acknowledgements) - * [Sponsors](#sponsors) - * [Community Contributions](#community-contributions) - * [Technologies](#technologies) -- [Customizing and Extending Serena](#customizing-and-extending-serena) -- [List of Tools](#list-of-tools) - - - -## Quick Start - -Serena can be used in various ways, below you will find instructions for selected integrations. - -* For coding with Claude, we recommend using Serena through [Claude Code](#claude-code) or [Claude Desktop](#claude-desktop). You can also use Serena in most other [terminal-based clients](#other-terminal-based-clients). -* If you want a GUI experience outside an IDE, you can use one of the many [local GUIs](#local-guis-and-frameworks) that support MCP servers. - You can also connect Serena to many web clients (including ChatGPT) using [mcpo](docs/serena_on_chatgpt.md). -* If you want to use Serena integrated in your IDE, see the section on [other MCP clients](#other-mcp-clients---cline-roo-code-cursor-windsurf-etc). -* You can use Serena as a library for building your own applications. We try to keep the public API stable, but you should still - expect breaking changes and pin Serena to a fixed version if you use it as a dependency. - -Serena is managed by `uv`, so you will need to [install it](https://docs.astral.sh/uv/getting-started/installation/). - -### Running the Serena MCP Server - -You have several options for running the MCP server, which are explained in the subsections below. - -#### Usage - -The typical usage involves the client (Claude Code, Claude Desktop, etc.) running -the MCP server as a subprocess (using stdio communication), -so the client needs to be provided with the command to run the MCP server. -(Alternatively, you can run the MCP server in Streamable HTTP or SSE mode and tell your client -how to connect to it.) - -Note that no matter how you run the MCP server, Serena will, by default, start a small web-based dashboard on localhost that will display logs and allow shutting down the -MCP server (since many clients fail to clean up processes correctly). -This and other settings can be adjusted in the [configuration](#configuration) and/or by providing [command-line arguments](#command-line-arguments). - -#### Using uvx - -`uvx` can be used to run the latest version of Serena directly from the repository, without an explicit local installation. - -```shell -uvx --from git+https://github.com/oraios/serena serena start-mcp-server -``` - -Explore the CLI to see some of the customization options that serena provides (more info on them below). - -#### Local Installation - -1. Clone the repository and change into it. - - ```shell - git clone https://github.com/oraios/serena - cd serena - ``` - -2. Optionally edit the configuration file in your home directory with - - ```shell - uv run serena config edit - ``` - - If you just want the default config, you can skip this part, and a config file will be created when you first run Serena. -3. Run the server with `uv`: - - ```shell - uv run serena start-mcp-server - ``` - - When running from outside the serena installation directory, be sure to pass it, i.e., use - - ```shell - uv run --directory /abs/path/to/serena serena start-mcp-server - ``` - -#### Using Docker (Experimental) - -⚠️ Docker support is currently experimental with several limitations. Please read the [Docker documentation](DOCKER.md) for important caveats before using it. - -You can run the Serena MCP server directly via docker as follows, -assuming that the projects you want to work on are all located in `/path/to/your/projects`: - -```shell -docker run --rm -i --network host -v /path/to/your/projects:/workspaces/projects ghcr.io/oraios/serena:latest serena start-mcp-server --transport stdio -``` - -Replace `/path/to/your/projects` with the absolute path to your projects directory. The Docker approach provides: - -* Better security isolation for shell command execution -* No need to install language servers and dependencies locally -* Consistent environment across different systems - -Alternatively, use docker compose with the `compose.yml` file provided in the repository. - -See the [Docker documentation](DOCKER.md) for detailed setup instructions, configuration options, and known limitations. - -#### Using Nix - -If you are using Nix and [have enabled the `nix-command` and `flakes` features](https://nixos.wiki/wiki/flakes), you can run Serena using the following command: - -```bash -nix run github:oraios/serena -- start-mcp-server --transport stdio -``` - -You can also install Serena by referencing this repo (`github:oraios/serena`) and using it in your Nix flake. The package is exported as `serena`. - -#### Streamable HTTP Mode - -ℹ️ Note that MCP servers which use stdio as a protocol are somewhat unusual as far as client/server architectures go, as the server -necessarily has to be started by the client in order for communication to take place via the server's standard input/output stream. -In other words, you do not need to start the server yourself. The client application (e.g. Claude Desktop) takes care of this and -therefore needs to be configured with a launch command. - -When using instead the *Streamable HTTP* mode, you control the server lifecycle yourself, -i.e. you start the server and provide the client with the URL to connect to it. - -Simply provide `start-mcp-server` with the `--transport streamable-http` option and optionally provide the port. -For example, to run the Serena MCP server in Streamable HTTP mode on port 9121 using a local installation, -you would run this command from the Serena directory, - -```shell -uv run serena start-mcp-server --transport streamable-http --port 9121 -``` - -and then configure your client to connect to `http://localhost:9121/mcp`. - -ℹ️ Note that SSE transport is supported as well, but its use is discouraged. -Use Streamable HTTP instead. - -#### Command-Line Arguments - -The Serena MCP server supports a wide range of additional command-line options, including the option to run in Streamable HTTP or SSE mode -and to adapt Serena to various [contexts and modes of operation](#modes-and-contexts). - -Run with parameter `--help` to get a list of available options. - -### Configuration - -Serena is very flexible in terms of configuration. While for most users, the default configurations will work, -you can fully adjust it to your needs by editing a few yaml files. You can disable tools, change Serena's instructions -(what we denote as the `system_prompt`), adjust the output of tools that just provide a prompt, and even adjust tool descriptions. - -Serena is configured in four places: - -1. The `serena_config.yml` for general settings that apply to all clients and projects. - It is located in your user directory under `.serena/serena_config.yml`. - If you do not explicitly create the file, it will be auto-generated when you first run Serena. - You can edit it directly or use - - ```shell - uvx --from git+https://github.com/oraios/serena serena config edit - ``` - - (or use the `--directory` command version). -2. In the arguments passed to the `start-mcp-server` in your client's config (see below), - which will apply to all sessions started by the respective client. In particular, the [context](#contexts) parameter - should be set appropriately for Serena to be best adjusted to existing tools and capabilities of your client. - See for a detailed explanation. You can override all entries from the `serena_config.yml` through command line arguments. -3. In the `.serena/project.yml` file within your project. This will hold project-level configuration that is used whenever - that project is activated. This file will be autogenerated when you first use Serena on that project, but you can also - generate it explicitly with - - ```shell - uvx --from git+https://github.com/oraios/serena serena project generate-yml - ``` - - (or use the `--directory` command version). -4. Through the context and modes. Explore the [modes and contexts](#modes-and-contexts) section for more details. - -After the initial setup, continue with one of the sections below, depending on how you -want to use Serena. - -### Project Activation & Indexing - -If you are mostly working with the same project, you can configure to always activate it at startup -by passing `--project