Skip to main content

MCP Server

Constellations can expose a ToolDispatcher as Model Context Protocol tools for assistants like Claude.

Setup​

libraryDependencies += "io.github.serhiip" %% "constellations-mcp" % "0.1.33-SNAPSHOT"

This depends on constellations-common. Both common and MCP are built for Scala 3.3.8+.

Quick example​

  1. Build a ToolDispatcher from your traits (generate / to)
  2. Create MCPToolProvider with a Cats Effect Dispatcher
  3. Call create to get MCP tool specifications
  4. Register them on an MCP server
import io.github.serhiip.constellations.ToolDispatcher
import io.github.serhiip.constellations.mcp.*
import cats.effect.IO
import cats.effect.std.Dispatcher

trait Calculator[F[_]]:
def add(a: Int, b: Int): F[Int]

val calculator = new Calculator[IO]:
def add(a: Int, b: Int): IO[Int] = IO.pure(a + b)

val toolDispatcher = ToolDispatcher.generate[IO](calculator)

Dispatcher.parallel[IO].use { dispatcher =>
val mcpToolSpec = MCPToolProvider.core[IO](ReactorBridge.core[IO](dispatcher), MCPToolProvider.defaultConfig, CallScope.none[IO])
mcpToolSpec.create(toolDispatcher)
}

Tool names follow the usual naming contract (calculator_add). See ToolDispatcher.

Complete server​

sbt "examples/runMain io.github.serhiip.constellations.examples.mcp.McpServerExample"

See also examples/.../examples/mcp/README.md.

Claude Desktop​

Add to claude_desktop_config.json:

{
"mcpServers": {
"constellations": {
"command": "sbt",
"args": ["examples/runMain", "io.github.serhiip.constellations.examples.mcp.McpServerExample"]
}
}
}