Skip to main content

MCP server for Scala 3 (Dotty) compiler development

Project description

dotty-mcp

A Model Context Protocol (MCP) server for Scala 3 (Dotty) compiler development.

Overview

dotty-mcp provides a streamlined interface for interacting with the Scala 3 compiler through SBT. It maintains a persistent SBT session and exposes compiler functionality through the MCP protocol, making it ideal for AI-assisted compiler development workflows.

Features

  • Persistent SBT Session: Maintains a long-running SBT process for fast compilation
  • Direct scalac Access: Compile individual files with custom compiler options
  • MCP Integration: Works seamlessly with Claude Code and other MCP clients

Installation

For Claude Code

From a local clone:

cd /path/to/dotty-mcp
uv sync
claude mcp add dotty-mcp -- uv run --directory /path/to/dotty-mcp dotty-mcp --root /path/to/dotty-project

After publishing to PyPI:

# If running from within your Dotty project directory
claude mcp add dotty-mcp -- uvx dotty-mcp

# Or specify a custom root
claude mcp add dotty-mcp -- uvx dotty-mcp --root /path/to/dotty-project

Manual Installation

# Install dependencies
uv sync

# Run the server (from within Dotty project directory)
uv run dotty-mcp

# Or specify a custom root
uv run dotty-mcp --root /path/to/dotty-project

Note: The --root argument is optional and defaults to the current directory.

Usage

The server provides a single tool:

scalac(file: str, options: List[str] = None) -> str

Compiles a Scala file using the Dotty compiler through SBT.

Parameters:

  • file: Relative path from project root to the Scala file (e.g., "tests/pos/HelloWorld.scala")
  • options: Optional list of compiler options (e.g., ["-Xprint:typer", "-explain"])

Returns: Compilation output including errors, warnings, or success messages.

Example:

scalac("tests/pos/Test.scala", ["-Xprint:typer"])

Requirements

  • Python >= 3.10
  • SBT (must be in PATH)
  • A Dotty/Scala 3 project with a build.sbt file

Architecture

The tool consists of three main components:

  1. SBTProcess: Manages the persistent SBT process using pexpect
  2. DottyProject: Wraps the SBT process and provides high-level compilation operations
  3. MCP Server: Exposes functionality through the FastMCP framework

Development

This project uses uv for dependency management:

# Install dependencies
uv sync

# Run tests (if available)
uv run pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotty_mcp-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dotty_mcp-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file dotty_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: dotty_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.23

File hashes

Hashes for dotty_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c15b1e5af34f32fe060c269a176b6ed5468a45c5e44f82c6ab22c46dc225e1ba
MD5 da1dc32d36c16f7c43b16a5d92009ebe
BLAKE2b-256 c0a4f3bf8704ed7c47934aa89f797f3df13e56e15c54ce9ce9d0946e45233fd0

See more details on using hashes here.

File details

Details for the file dotty_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dotty_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.23

File hashes

Hashes for dotty_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97334c835d357a3804f9ddf6371fff782e774f18f53aa9c85116cc55a075d37d
MD5 9ad95f6b7327fd24bf8c4622ca440d47
BLAKE2b-256 c380bd40f76dc09efc974ab8555b4b48b62b8ee76a84edab8c48dc7cd682ac28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page