Back to MCP Catalog

Sakura MCP Server

Developer ToolsScala
A Scala library implementing the Model Context Protocol for AI model communication

Sakura MCP is a Scala implementation of the Model Context Protocol that enables interoperable communication between AI models and services. This library provides developers with a fluent API for constructing and sending model context requests, while handling the serialization and deserialization of JSON data. The library supports various input and output types including text and images, and offers configuration options for API keys, base URLs, and timeouts. With Sakura MCP, developers can easily integrate AI model capabilities into their Scala applications with minimal boilerplate code.

Overview

Sakura MCP is a Scala library that implements the Model Context Protocol, allowing for standardized communication between AI models and services. This library makes it easy to integrate AI capabilities into your Scala applications.

Installation

To use Sakura MCP in your Scala project, add the following dependency to your build.sbt file:

libraryDependencies += "com.github.mullerhai" %% "mcp" % "0.1.0" // Replace with latest version

Basic Usage

Here's a simple example of how to use the Sakura MCP library:

import com.github.mullerhai.mcp._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.duration._

// Configure client with your API key
val apiKey = "YOUR_API_KEY"
val client = new MCPClient(apiKey)

// Build a context for your request
val context = ModelContext(
  model = "llama2",
  input = TextInput("What is the capital of France?"),
  parameters = List(MaxTokens(50))
)

// Send the request
val future = client.send(context)

// Handle the response
val response = Await.result(future, 5.seconds)
println(response)

Configuration Options

The MCPClient can be configured with the following options:

  • apiKey: (Required) Your MCP API key
  • baseUrl: (Optional) The base URL of the MCP API (defaults to "https://api.modelcontext.com/v1")
  • timeout: (Optional) Request timeout in seconds (defaults to 10)

Example with custom configuration:

val client = new MCPClient(
  apiKey = "YOUR_API_KEY",
  baseUrl = "https://your-custom-api.com",
  timeout = 15
)

Supported Input & Output Types

Sakura MCP supports the following input and output types:

  • Input Types:

    • TextInput: For text-based input
    • ImageInput: For image input (base64 encoded)
  • Output Types:

    • TextOutput: For text-based output
    • ImageOutput: For image output (base64 encoded)

Error Handling

The send method returns a Future[Output]. You can handle errors using standard Scala error handling mechanisms:

try {
  val future = client.send(context)
  val response = Await.result(future, 5.seconds)
  println(response)
} catch {
  case e: Exception => println(s"Error: ${e.getMessage}")
}

Advanced Usage

For more complex scenarios, you can build more sophisticated contexts with multiple parameters:

val context = ModelContext(
  model = "gpt-4",
  input = TextInput("Generate a creative story about a robot learning to paint"),
  parameters = List(
    MaxTokens(500),
    Temperature(0.8),
    TopP(0.95)
  )
)

Related MCPs

Apple Shortcuts
Developer ToolsJavaScript

Control Apple Shortcuts automations from AI assistants

Clojars Dependency Lookup
Developer ToolsJavaScript

Fetch dependency information from Clojars, the Clojure community's artifact repository

Simple Timeserver
Developer ToolsPython

Provides Claude with current time and timezone information

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.