Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mcp-scala

MCP.Pizza Chef: windymelt

mcp-scala is a Model Context Protocol server implemented in Scala 3, currently in alpha stage. It supports automatic JSON Schema derivation, tool definition, text content handling, and stdio transport. Designed for developers to integrate MCP servers in Scala environments, it enables structured context sharing and tool execution with MCP clients. The project is open for contributions and aims to expand features like HTTP transport and authorization.

Use This MCP server To

Integrate MCP server functionality in Scala-based applications Generate random numbers and sequences via MCP tools Execute numeric computations like sum through MCP tools Develop custom MCP tools using Scala 3 Test MCP client-server communication using stdio transport Extend MCP server with additional content parts and transports Contribute to open-source MCP server development in Scala

README

MCP-scala

Model Context Protocol server written in Scala 3

Development stage

This software is currently ALPHA state.

  • Automatic derivation of JSON Schema
  • Define your tool
  • Text content part
  • Other content parts
  • Notification handling
  • Capability handling
  • stdio transport
  • HTTP transport
  • Authorization feature

This implementation needs your attention and contribution.

Feel free to open Issue / PR to contribute this project.

Demo

First, build server into JS:

sbt example/fastLinkJS

Then, utilize server in your MCP client:

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

You can run some tool:

  • randomNumber
    • generate random number between min to max.
  • iota
    • generate a sequence of numbers from min to max.
  • sum
    • calculate the sum of a sequence of numbers.

Implement your tool

See Main.scala for details.

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

package dev.capslock.mcpscala

import cats.effect.IO
import cats.effect.IOApp
import dev.capslock.mcpscala.transport.StdioServer
import dev.capslock.mcpscala.mcp.ContentPart
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

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

/** Entry point for the Stdio server.
  */
object StdioMain extends McpIOApp(
    name = "random-number",
    header = "Generate a random number",
  ):
    
  val handlers = Handler.methodHandlers(
    Map(
      "randomNumber" -> server.Tool(randomNumber),
    )
  )

mcp-scala FAQ

How do I run the mcp-scala server?
Build the server using sbt and run it via a shell script with stdio transport as shown in the demo.
What transport protocols does mcp-scala support?
Currently, mcp-scala supports stdio transport; HTTP transport is planned for future releases.
Can I define custom tools in mcp-scala?
Yes, mcp-scala allows defining custom tools with automatic JSON Schema derivation.
Is mcp-scala production-ready?
No, it is currently in alpha stage and may lack some features like authorization and notification handling.
How can I contribute to mcp-scala?
You can contribute by opening issues or pull requests on the GitHub repository.
Does mcp-scala support authorization?
Authorization handling is not yet implemented but planned for future updates.
What programming language is mcp-scala written in?
It is written in Scala 3, leveraging its features for MCP server implementation.
Can mcp-scala be used with different LLM providers?
Yes, as an MCP server, it is provider-agnostic and can work with OpenAI, Claude, Gemini, and others.