Skip to main content

Metals v1.5.3 - Strontium

· 11 min read

We're happy to announce the release of Metals v1.5.3, which besides many bugfixes and improvements brings an MCP server implementation to Metals, allowing your AI agent to also use the information that Metals can provide.

Commits since last release135
Merged PRs89
Contributors24
Closed issues32
New features9

For full details: https://github.com/scalameta/metals/milestone/78?closed=1

Metals is a language server for Scala that works with VS Code, Vim, Emacs, Zed, Helix and Sublime Text. Metals is developed at the Scala Center and VirtusLab with the help from contributors from the community.

TL;DR

Check out https://scalameta.org/metals/, and give Metals a try!

MCP support

Starting with this release, Metals can serve an SSE, MCP server.

Why?

AI agents have the tendency to make up the existence of some functions, classes, arguments, and so on. If we allow them to use the information that Metals already has and provide them with such capabilities as searching for symbols, discovering class members, signature help, and getting symbol documentation, we expect AI agents to yield much more relevant suggestions.

Furthermore, giving the AI agent the capability to compile files, run tests, and import builds can further help automate your workflow.

How to use Metals MCP?

To enable Metals MCP support, set metals.startMcpServer to true. For common editors like Cursor or VSCode (GitHub Copilot), MCP configuration will be automatically added to your workspace. However, you should still check in your AI agent settings that the connection was made successfully. For other AI, Metals will show a message upon MCP server startup with the port on which it was started locally. If you miss it, Metals MCP server started on port: ${port} message is also printed in the Metals log (.metals/metals.log).

Current list of MCP tools:

  • compile-file -- Compile a chosen Scala file.
  • compile-full -- Compile the whole Scala project.
  • test -- Run Scala test suite.
  • glob-search -- Search for symbols containing substring
  • typed-glob-search -- Search for symbols containing a substring that match the allowed symbol kinds (e.g., class, method).
  • inspect -- Inspect a chosen Scala symbol. For packages, objects, and traits, it returns a list of members; for classes, it returns a list of members and constructors; and for methods, it returns signatures of all overloaded methods.
  • get-docs -- Get documentation for a chosen Scala symbol
  • get-usages -- Get usages for a chosen Scala symbol.
  • import-build -- Import the build to IDE. Should be performed after any build changes, e.g., adding dependencies or any changes in build.sbt.

This feature is still experimental, and we'd love to get your feedback and improvement suggestions.

Best effort compilation

Best effort compilation was first introduced to Metals v1.3.4 (see here); however, due to multiple issues with it, it was disabled. Since then, a lot was fixed and improved in the area, so this release reintroduces best effort compilation behind a setting; simply set metals.enable-best-effort to true and give it a try.

New inlay hints

Named parameters

tgodzik added inlay hints for showing parameters' names on call site. The new inlay hint is available under inlay-hints.named-parameters.enable Metals setting, for now available only for Scala 2. named-params Named parameters inlay hints

By-name parameters

We also have new inlay hints marking by-name parameters with => on the call site. Thanks go to harpocrates. by-name-params

Remove invalid imports code action

This release also has a new code action for removing invalid imports, saving you the trouble of deleting them manually. It is yet another improvement added by harpocrates. Code action works both for Scala 2 and Scala 3, though older Scala 2 versions might get only partial support.

remove-invalid-imports Remove invalid import remove-invalid-imports-2 Remove invalid import in multi-import statement

Convert to named lambda parameters code action

Thanks to KacperFKorban we have a new code action that converts a wildcard lambda into a lambda with parameters. This was only implemented for Scala 3 and will work from versions 3.7.2 and LTS 3.3.7.

convert-to-named-1 Convert to named lambda parameters with single wildcard.

convert-to-named-2 Convert to named lambda parameters with multiple wildcards.

Support using directives in worksheets

Since Metals has been supporting Scala-CLI for a while, and it is Metals's recommended tool for scripts, we are further embracing Scala-CLI style, and using directives are now supported also in the worksheets. Thanks go to tgodzik for adding this improvement.

using-directives-worksheet A dependency added with using directives in a worksheet.

Improve auto-fill arguments

For a while now, Metals had a special completion for auto-filling argument names, however it was somewhat hidden. Now, the discoveribility of that feature was improved, and it naturally appear in the completion suggestion list. Thanks, LiathHelvetica and natsukagami, for making the change.

auto-fill Auto-fill arguments for a case class.

Discover tests for ZIO test framework

With this release also comes support for discovering and running single test cases from Metals when using the ZIO test framework. Thanks go to kaplan-shaked, making this their first contribution!

run-zio-test Run single ZIO test testcase.

Miscellaneous

  • improvement : Able to get environment variables from shell ajafri2001
  • improvement: prefer .bazelproject as the Bazel BSP root harpocrates
  • improvement: add additional ScalaTest WordSpec types tmilner
  • fix: add backticks in hover output when needed harpocrates
  • fix: show more precise signature help types harpocrates
  • fix: consider build.mill and build.mill.scala when calculating Mill digest sake92
  • fix: completions respect backticks at defn site harpocrates
  • fix: don't rename if old and new packages are the same for package object kasiaMarek
  • fix: add fallback presentation compiler for Java kasiaMarek
  • fix: Add type param inlay hint for constuctor calls kasiaMarek
  • improvement: add selection ranges for name harpocrates
  • improvement: add folding range for function call harpocrates
  • feat: respect LSP build target no-ide tag ysedira
  • improvement: queue or cancel previous connect request kasiaMarek
  • fix & improvement: improvements in selection ranges harpocrates
  • feat: convert string to interpolation on ${ harpocrates
  • fix: don't remove non-existent entries from classpath kasiaMarek

Contributors

Big thanks to everybody who contributed to this release or reported an issue!

$ git shortlog -sn --no-merges v1.5.2..v1.5.3
19 Tomasz Godzik
16 amit.miran
14 Scalameta Bot
13 Alec Theriault
11 scalameta-bot
8 ajafri2001
6 Brice Jaglin
6 dependabot[bot]
6 kasiaMarek
5 Kacper Korban
5 Katarzyna Marek
5 Tobias Roeser
5 scarf
3 Przemyslaw Wierzbicki
3 Sakib Hadziavdic
2 Myungbae Son
1 Amit Miran
1 Christopher Vogt
1 Jens Kouros
1 Maciej Dragun
1 Michal Pawlik
1 Shaked Kaplan
1 Tom Milner
1 ysedira

Merged PRs

v1.5.3 (2025-05-13)

Full Changelog

Merged pull requests: