ZIO HTTP MCP
ZIO HTTP MCP is an MCP (Model Context Protocol) server and client library for Scala 3, ZIO, and ZIO HTTP.
Introductionโ
Key features of ZIO HTTP MCP:
- Server and Client โ The library provides both an MCP server and an MCP client.
- Transports โ The server and the client support the Streamable HTTP and stdio transports, with SSE streaming.
- MCP Features โ Tools, resources, prompts, sampling, elicitation, and progress notifications.
- Authorization โ The client supports OAuth 2.1 authorization, with both the
client_credentialsand theauthorization_code+ PKCE flows. - Two Specification Versions โ The library implements the MCP 2025-11-25 specification and the stateless MCP 2026-07-28 specification, and it negotiates the protocol version per connection.
Installationโ
In order to use this library, we need to add the following line to our build.sbt file:
libraryDependencies += "com.jamesward" %% "zio-http-mcp" % "<version>"
Exampleโ
Here is a minimal MCP server that exposes a greet tool. The input type derives a Schema, and the library generates the JSON Schema of the tool from it:
import com.jamesward.ziohttp.mcp.*
import zio.*
import zio.http.*
import zio.schema.*
case class NameInput(name: String) derives Schema
val server = McpServer("my-server", "1.0.0")
.tool(
McpTool("greet")
.description("Greets someone by name")
.handle: (input: NameInput) =>
ZIO.succeed(s"Hello, ${input.name}!")
)
object Main extends ZIOAppDefault:
def run =
Server.serve(server.routes).provide(Server.default, McpServer.State.default)
For the full documentation, see the ZIO HTTP MCP README.