MCP ExplorerExplorer

Chimp

@softwaremillon 10 months ago
16 Apache-2.0
FreeCommunity
AI Systems
Build type-safe, boilerplate-less MCP servers in Scala using the HTTP transport

Overview

What is Chimp

Chimp is a library for building type-safe, boilerplate-less MCP servers in Scala 3, utilizing the HTTP transport based on the Model Context Protocol (MCP).

Use cases

Use cases for Chimp include building APIs for data processing tools, creating microservices that require secure and efficient communication, and developing applications that leverage the MCP protocol for model context management.

How to use

To use Chimp, add the dependency to your build.sbt file and define your tools with type-safe inputs. You can create an MCP server endpoint and start it using a supported HTTP server implementation like Netty.

Key features

Key features of Chimp include type-safe input handling, integration with any Scala stack, and support for JSON-RPC HTTP API. It simplifies the process of building MCP servers by reducing boilerplate code.

Where to use

Chimp can be used in various domains where type safety and boilerplate reduction are essential, such as backend services, microservices, and applications that require a robust API layer.

Content

Chimp MCP Server

CI
Scala 3

A library for building MCP (Model Context Protocol) servers in Scala 3, based on Tapir. Describe MCP tools with type-safe input, expose them over a JSON-RPC HTTP API.

Integrates with any Scala stack, using any of the HTTP server implementations supported by Tapir.


Quickstart

Add the dependency to your build.sbt:

libraryDependencies += "com.softwaremill.chimp" %% "core" % "0.1.2"

Example: the simplest MCP server

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

//> using dep com.softwaremill.chimp::core:0.1.2

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 => Right(s"The result is ${i.a + i.b}"))

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

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

More examples

Are available here.


MCP Protocol

Chimp implements the HTTP transport of the MCP protocol (version 2025-03-26). Only tools are supported, via the following JSON-RPC commands:

  • Initialization and capabilities negotiation (initialize)
  • Listing available tools (tools/list)
  • Invoking a tool (tools/call)

All requests and responses use JSON-RPC 2.0. Tool input schemas are described using JSON Schema, auto-generated from Scala types.


Defining Tools and Server Logic

  • Use tool(name) to start defining a tool.
  • Add a description and annotations for metadata and hints.
  • Specify the input type (must have a Circe Codec and Tapir Schema).
  • Provide the server logic as a function from input to Either[String, String] (or a generic effect type).
  • Create a Tapir endpoint by providing your tools to mcpEndpoint
  • Start an HTTP server using your preferred Tapir server interpreter.

Contributing

Contributions are welcome! Please open issues or pull requests.


Commercial Support

We offer commercial support for Tapir and related technologies, as well as development services. Contact us to learn more about our offer!


Copyright

Copyright © 2025 SoftwareMill https://softwaremill.com.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers