MCP Scala
Model Context Protocol server written in Scala
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
Maintainer
Works with
Installation
Manual Installation
npx mcp-scalaConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
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.0Define 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.SchemaImplement 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))
}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),
)
)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/fastLinkJSCreate 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.jsMCP 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.
MCP Scala Alternatives — Similar Developer Tools Servers
Looking for alternatives to MCP Scala? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
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.
Set Up MCP Scala in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.