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

fast-mcp-scala

MCP.Pizza Chef: TJC-LP

fast-mcp-scala is a high-level Scala 3 library designed for rapid and developer-friendly creation of MCP servers. It leverages ZIO for effect handling and asynchronous operations, uses annotation-driven APIs for tools, resources, and prompts, and automates JSON Schema and handler generation via Scala 3 macros. It integrates seamlessly with the Java MCP SDK, simplifying MCP server development in Scala environments.

Use This MCP server To

Build scalable MCP servers with asynchronous ZIO effects Create MCP tools and resources using annotation-driven APIs Automatically generate JSON schemas and handlers for MCP entities Integrate Scala MCP servers with Java MCP SDK seamlessly Deploy MCP servers quickly in Scala 3 projects Simplify MCP server development with macro-based code generation

README

FastMCP-Scala

A high‑level, developer‑friendly Scala 3 library for building Model Context Protocol (MCP) servers.

Features

  • ZIO‑based effect handling and async support
  • Annotation‑driven API (@Tool, @Resource, @Prompt)
  • Automatic JSON Schema & handler generation via Scala 3 macros
  • Seamless integration with the Java MCP SDK

Installation

Add to your build.sbt (defaulting to Scala 3.6.4):

libraryDependencies += "com.tjclp" %% "fast-mcp-scala" % "0.1.1"

Quickstart

//> using scala 3.6.4
//> using dep com.tjclp::fast-mcp-scala:0.1.1
//> using options "-Xcheck-macros" "-experimental"

import com.tjclp.fastmcp.core.{Tool, ToolParam, Prompt, PromptParam, Resource}
import com.tjclp.fastmcp.server.FastMcpServer
import com.tjclp.fastmcp.macros.RegistrationMacro.*
import zio.*

// Define annotated tools, prompts, and resources
object Example:
  @Tool(name = Some("add"), description = Some("Add two numbers"))
  def add(
      @ToolParam("First operand") a: Double,
      @ToolParam("Second operand") b: Double
    ): Double = a + b

  @Prompt(name = Some("greet"), description = Some("Generate a greeting message"))
  def greet(@PromptParam("Name to greet") name: String): String =
    s"Hello, $name!"

  // Note: resource templates (templated URIs) are not yet supported;
  // coming soon when the MCP java‑sdk adds template support.
  @Resource(uri = "file://test", description = Some("Test resource"))
  def test(): String = "This is a test"

object ExampleServer extends ZIOAppDefault:
  override def run =
    for
      server <- ZIO.succeed(FastMcpServer("ExampleServer"))
      _      <- ZIO.attempt(server.scanAnnotations[Example.type])
      _      <- server.runStdio()
    yield ()

Running Examples

The above example can be run using scala-cli scripts/quickstart.scala from the repo root. You can run the server via the MCP inspector by running:

npx @modelcontextprotocol/inspector scala-cli <path_to_repo>/scripts/quickstart.scala

You can also run examples directly from the command line:

scala-cli \
    -e '//> using dep com.tjclp::fast-mcp-scala:0.1.1' \
    --main-class com.tjclp.fastmcp.examples.AnnotatedServer

Integration with Claude Desktop

In Claude desktop, you can add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "example-fast-mcp-server": {
      "command": "scala-cli",
      "args": [
        "-e",
        "//> using dep com.tjclp::fast-mcp-scala:0.1.1",
        "--main-class",
        "com.tjclp.fastmcp.examples.AnnotatedServer"
      ]
    }
  }
}

Note: FastMCP-Scala example servers are for demo purposes only and don't do anything useful

For additional examples and in‑depth docs, see docs/guide.md.

License

MIT


Development Documentation

Developing Locally

When hacking on FastMCP‑Scala itself, you can consume a local build in any project.

🔨 Publish to the Local Ivy Repository with sbt

In your cloned repository, set a working version

ThisBuild / version := "0.1.1-SNAPSHOT"
# From the fast-mcp-scala root
sbt publishLocal

Then, in your consuming sbt project:

libraryDependencies += "com.tjclp" %% "fast-mcp-scala" % "0.1.1-SNAPSHOT"

publishLocal installs the artifact under ~/.ivy2/local (or the Coursier cache when enabled).

📦 Use the JAR Directly (Unmanaged Dependencies)
# Package the library
sbt package

# Copy the JAR – adjust Scala version / name if you change them
cp target/scala-3.6.4/fast-mcp-scala_3-0.1.1-SNAPSHOT.jar \
   /path/to/other-project/lib/

Unmanaged JARs placed in a project's lib/ folder are picked up automatically by sbt.

🚀 Using with scala‑cli

You can use fast-mcp-scala in another scala‑cli project:

//> using scala 3.6.4
//> using dep com.tjclp::fast-mcp-scala:0.1.1
//> using options "-Xcheck-macros" "-experimental"

You can also point directly at the local JAR:

//> using scala 3.6.4
//> using lib "/absolute/path/to/fast-mcp-scala_3-0.1.1.jar"
//> using options "-Xcheck-macros" "-experimental"

fast-mcp-scala FAQ

How do I add fast-mcp-scala to my Scala project?
Add the dependency 'com.tjclp %% fast-mcp-scala % 0.1.1' to your build.sbt file, targeting Scala 3.6.4 or later.
What effect system does fast-mcp-scala use?
It uses ZIO for effect handling and asynchronous programming, enabling robust and scalable MCP servers.
How does fast-mcp-scala simplify MCP server development?
It provides annotation-driven APIs and Scala 3 macros to automatically generate JSON schemas and handlers, reducing boilerplate code.
Can fast-mcp-scala integrate with Java MCP SDK?
Yes, it offers seamless integration with the Java MCP SDK, allowing interoperability between Scala and Java MCP components.
What Scala version is required for fast-mcp-scala?
It requires Scala 3, specifically tested with Scala 3.6.4.
Does fast-mcp-scala support asynchronous operations?
Yes, it supports asynchronous operations through ZIO, enabling non-blocking MCP server implementations.
What annotations are available in fast-mcp-scala?
It provides @Tool, @Resource, and @Prompt annotations to define MCP tools, resources, and prompts declaratively.
Is fast-mcp-scala suitable for production use?
While designed for developer-friendliness and performance, evaluate it in your environment; it supports robust async and macro features.