Quickstart

Chimp lets you expose MCP tools over a JSON-RPC HTTP API. Tool inputs are described with type-safe Scala types; the JSON schema and JSON-RPC plumbing are generated for you.

Add the dependency to your build.sbt:

libraryDependencies += "com.softwaremill.chimp" %% "chimp-server" % "0.3.0"

Example: the simplest MCP server

Below is a self-contained, scala-cli-runnable example:

//> using dep com.softwaremill.chimp::chimp-server:0.3.0

import chimp.*
import sttp.tapir.*
import sttp.tapir.server.netty.sync.NettySyncServer

// define the input type for your tool
case class AdderInput(a: Int, b: Int) derives io.circe.Codec, Schema

@main def mcpApp(): Unit =
  // describe the tool providing the name, description, and input type
  val adderTool = tool("adder").description("Adds two numbers").input[AdderInput]

  // combine the tool description with the server-side logic
  val adderServerTool = adderTool.handle(i => ToolResult.text(s"The result is ${i.a + i.b}"))

  // create the MCP server endpoint; it will be available at http://localhost:8080/mcp
  val mcpServerEndpoint = McpServer(tools = List(adderServerTool)).endpoint(List("mcp"))

  // start the server
  NettySyncServer().port(8080).addEndpoint(mcpServerEndpoint).startAndWait()

For a streaming server that pushes progress and log notifications over SSE, add the dependency for your effect system — ZIO:

libraryDependencies += "com.softwaremill.chimp" %% "chimp-server-zio" % "0.3.0"

or direct-style Ox:

libraryDependencies += "com.softwaremill.chimp" %% "chimp-server-ox" % "0.3.0"

More runnable examples live in examples/.