MCP Scala

v1.0.0Developer Toolsstable

Model Context Protocol server written in Scala

mcp-scalamcpai-integration
Share:
35
Stars
0
Downloads
0
Weekly
0/5

What is MCP Scala?

MCP Scala is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to model context protocol server written in scala

Model Context Protocol server written in Scala

This server falls under the Developer Tools and APIs categories on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Model Context Protocol server written in Scala

Use Cases

Build MCP servers using Scala language.
Integrate with Scala applications and libraries.
Create type-safe MCP implementations.
windymelt

Maintainer

LicenseMIT
Languagescala
Versionv1.0.0
UpdatedMay 13, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-scala

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MCP Scala

MCP-Scala is an Alpha-stage Model Context Protocol server library written in Scala 3 that lets you build and run MCP tools using functional, type-safe Scala code. It compiles your server to JavaScript via Scala.js and communicates over stdio transport. The library provides automatic JSON Schema derivation from case classes, making it ideal for Scala developers who want to expose tools to LLM clients without leaving the JVM/JS ecosystem.

Prerequisites

  • Scala 3 and sbt (Scala Build Tool) installed
  • Node.js runtime to execute the compiled JavaScript output
  • An MCP-compatible client such as Claude Desktop or Cline
  • Basic familiarity with Scala and functional programming
1

Add the mcp-scala dependency

In your sbt project, add the mcp-scala library as a dependency. The library is published for Scala.js so your project must target Scala.js.

//> using scala 3
//> using toolkit typelevel:default
//> using dep dev.capslock::mcpscala:0.1.0
2

Define your input types with JSON Schema annotations

Create case classes for your tool inputs and derive both circe JSON decoders and tapir schemas automatically. Use the @description annotation to document each parameter.

import sttp.tapir.Schema.annotations.description

case class RandomNumberInput(
    @description("Minimum value (inclusive)") min: Int,
    @description("Maximum value (exclusive)") max: Int
) derives io.circe.Decoder,
      sttp.tapir.Schema
3

Implement your tool handler

Write a function that takes your input type and returns IO[Seq[ContentPart]]. Use ContentPart.TextContentPart to return text results to the LLM client.

import cats.effect.IO
import dev.capslock.mcpscala.mcp.ContentPart

def randomNumber(input: RandomNumberInput): IO[Seq[ContentPart]] = IO {
  val result = scala.util.Random.between(input.min, input.max)
  Seq(ContentPart.TextContentPart(result.toString))
}
4

Register tools and create the server entry point

Extend McpIOApp and register your tool handlers in the handlers map. Each handler must be wrapped with server.Tool().

object StdioMain extends McpIOApp(
    name = "my-mcp-server",
    header = "My Scala MCP Server",
  ):
  val handlers = Handler.methodHandlers(
    Map(
      "randomNumber" -> server.Tool(randomNumber),
    )
  )
5

Build the server to JavaScript

Use the sbt fastLinkJS task (for development) or fullLinkJS (for production) to compile your Scala code to JavaScript.

sbt example/fastLinkJS
6

Create a run script and configure your MCP client

Create a shell script that runs the compiled JavaScript with Node.js, then add the server to your MCP client configuration.

#!/bin/sh
node /path/to/your/project/.js/main.js

MCP Scala Examples

Client configuration (Cline/Claude Desktop)

Add the compiled Scala MCP server to your MCP client using a shell script wrapper that launches the Node.js output.

{
  "mcpServers": {
    "mcpscala": {
      "disabled": false,
      "timeout": 30,
      "command": "sh",
      "args": ["/path/to/your/run.sh"],
      "transportType": "stdio"
    }
  }
}

Prompts to try

Example prompts that use the built-in demo tools exposed by the example server.

- "Generate a random number between 1 and 100"
- "Give me a sequence of numbers from 5 to 20"
- "Calculate the sum of numbers from 1 to 10"

Troubleshooting MCP Scala

sbt build fails with Scala.js dependency errors

Ensure your project is configured as a Scala.js project in build.sbt with enablePlugins(ScalaJSPlugin). The mcp-scala library targets Scala.js and cannot be used as a JVM dependency.

MCP client cannot connect to the server

Verify your run.sh script is executable (chmod +x run.sh) and the path to the compiled .js file is correct. Check the fastLinkJS output directory — it is typically target/scala-3.x/project-name-fastopt/.

JSON Schema validation errors at runtime

Make sure all case class fields have both io.circe.Decoder and sttp.tapir.Schema derivations. Fields without @description annotations will still work but the LLM will receive less context about each parameter.

Frequently Asked Questions about MCP Scala

What is MCP Scala?

MCP Scala is a Model Context Protocol (MCP) server that model context protocol server written in scala It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MCP Scala?

Follow the installation instructions on the MCP Scala GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with MCP Scala?

MCP Scala works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MCP Scala free to use?

Yes, MCP Scala is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcp-scala": { "command": "npx", "args": ["-y", "mcp-scala"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MCP Scala?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides