WM

windymelt/mcp-scala

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

37 stars 4 forks 品質 66 トレンド 20MIT

Scala で書いたモデルコンテキストプロトコルサーバ

概要

Scala 3 で書いたモデルコンテキストプロトコルサーバ - [x] JSON スキーマの自動運転 - [x] ツールを定義する - [x] テキストコンテンツ部分 - [ ] その他のコンテンツ部品 - [ ] 通知処理 - [ ] 機能処理 - [x] stdio 輸送 - [ ] HTTP 輸送 - [ ] 認証機能 この実装は、あなたの注意と貢献を必要とします。 課題・PRを自由に感じて、このプロジェクトに貢献します。 次に、MCP クライアントでサーバーを利用します。 - ランダム番号 - 最小から最大までのランダム番号を生成します。 - iota - 最小から最大までの数字のシーケンスを生成します。 - sum - 数値の順序の合計を計算します.

概要(AI 翻訳)

Scala 3 で書いたモデルコンテキストプロトコルサーバ

##開発段階

このソフトウェアは、現在 ALPHA 状態です。

  • [x] JSON スキーマの自動運転
  • [x] ツールを定義する
  • [x] テキストコンテンツ部分
  • [ ] その他のコンテンツ部品
  • [ ] 通知処理
  • [ ] 機能処理
  • [x] stdio 輸送
  • [ ] HTTP トランスポート
  • [ ] 認証機能

この実装は、あなたの注意と貢献を必要とします。

課題・PRを自由に感じて、このプロジェクトに貢献します。

デモ

まず、JS にサーバーをビルドします。

次に、MCP クライアントでサーバーを利用します。

いくつかのツールを実行できます。

  • [randomNumber]
  • [min から [max の間にランダムな数値を生成します。
  • [iota
  • [minから[max]までの数字のシーケンスを生成します。
  • [sum
  • 数値の配列の合計を計算します。

ツールの実装

詳細はMain.scalaを参照してください.

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

MCP-scala

Model Context Protocol server written in Scala 3

Development stage

This software is currently ALPHA state.

  • [x] Automatic derivation of JSON Schema
  • [x] Define your tool
  • [x] Text content part
  • [ ] Other content parts
  • [ ] Notification handling
  • [ ] Capability handling
  • [x] stdio transport
  • [ ] HTTP transport
  • [ ] Authorization feature

This implementation needs your attention and contribution.

Feel free to open Issue / PR to contribute this project.

Demo

First, build server into JS:

sbt example/fastLinkJS

Then, utilize server in your MCP client:

// Example for Cline
{
  "mcpServers": {
    "mcpscala": {
      "disabled": false,
      "timeout": 30,
      "command": "sh",
      "args": ["/path/to/run.sh"],
      "transportType": "stdio"
    }
  }
}

You can run some tool:

  • randomNumber
    • generate random number between min to max.
  • iota
    • generate a sequence of numbers from min to max.
  • sum
    • calculate the sum of a sequence of numbers.

Implement your tool

See Main.scala for details.

//> using scala 3
//> using toolkit typelevel:default
//> using dep dev.capslock::mcpscala:0.1.0

package dev.capslock.mcpscala

import cats.effect.IO
import cats.effect.IOApp
import dev.capslock.mcpscala.transport.StdioServer
import dev.capslock.mcpscala.mcp.ContentPart
import sttp.tapir.Schema.annotations.description

case class RandomNumberInput(
    @description("Minimum value (inclusive)") min: Int,
    @description("Maximum value (exclusive)") max: Int
) derives io.circe.Decoder,
      sttp.tapir.Schema

def randomNumber(input: RandomNumberInput): IO[Seq[ContentPart]] = IO {
  val random = scala.util.Random.between(input.min, input.max)
  Seq(ContentPart.TextContentPart(random.toString))
}

/** Entry point for the Stdio server.
  */
object StdioMain extends McpIOApp(
    name = "random-number",
    header = "Generate a random number",
  ):
    
  val handlers = Handler.methodHandlers(
    Map(
      "randomNumber" -> server.Tool(randomNumber),
    )
  )

GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

// Example for Cline { "mcpServers": { "mcpscala": { "disabled": false, "timeout": 30, "command": "sh", "args": ["/path/to/run.sh"], "transportType": "stdio" } } }