Scala with Claude Code
Claude Code does not yet provide a native LSP plugin for Scala (see tracking issue #45132). This post explains how to work around this limitation.
Let’s start with some definitions
LSP (Language Server Protocol): A standard protocol that allows text editors and IDEs to communicate with language servers for features like code completion, diagnostics, and navigation. Language-agnostic and editor-agnostic.
BSP (Build Server Protocol): A standard protocol for IDEs to communicate with build tools (like sbt, Maven, Gradle). Allows editors to query build information, compile code, run tests, etc. without knowing specific build tool details.
Bloop: A build server specifically designed for Scala/Java that implements BSP. It provides fast compilation and integrates with various IDEs and editors.
Metals: A Scala language server that implements LSP. It provides IDE features (completion, hover, diagnostics, refactoring) for Scala code and integrates with build servers via BSP (like Bloop) to understand project structure and dependencies.
In practice: Metals (LSP) talks to Bloop (BSP) to understand your Scala project and provide intelligent code editing features in your editor.
Metals
Since Metals version 1.6.6., a standalone MCP server is included.
Install it using coursier
cs install metals-mcp
Then, in your project directory, run
metals-mcp --workspace . --client claude
What happens under the hood
It creates a .mcp.json at the root of your project. This is how you define a project-scope MCP server for Claude
{
"mcpServers": {
"metals": {
"url": "http://localhost:59182/mcp",
"type": "http"
}
}
}
When you launch claude, it will detect the server automatically
New MCP server found in .mcp.json: metals
MCP servers may execute code or access system resources. All tool calls require approval. Learn more in the
MCP documentation.
❯ 1. Use this and all future MCP servers in this project
2. Use this MCP server
3. Continue without using this MCP server
Enter to confirm · Esc to cancel
It also starts Bloop if no instance is already running, as shown in the log
2026.04.29 08:51:41:788 pool-2-thread-2 INFO scala.meta.internal.metals.BloopServers.maybeStartBloop:386
No running Bloop server found, starting one.
Here’s how Claude Code uses Metals to compile your project
❯ compile the project
⏺ metals - compile-full (MCP)
This setup is particularly useful when you want Claude Code to reason about your Scala project with full awareness of its structure, dependencies, and compiler errors rather than treating it as plain text.
IntelliJ
IntelliJ offers two paths for Scala: use sbt directly, or integrate via BSP. The tradeoff is stability vs. efficiency. With sbt, metals and sbt compile independently (double compilation). With BSP, you eliminate redundant builds but may hit edge cases in IntelliJ’s BSP support.