
drshade/haskell-mcp-server
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
drshade/haskell-mcp-server は [https://github.com/drshade/haskell-mcp-server.] からインポートされた MCP サーバーの候補です
概要
drshade/haskell-mcp-server は [https://github.com/drshade/haskell-mcp-server.] からインポートされた MCP サーバーの候補です
概要(AI 翻訳)
モデルコンテキストプロトコルサーバーをビルドする 明白なデータ タイプからの Haskell。 ツール、プロンプト、リソースの決定 ADT はタイプごとに 1 つのハンドラを記述し、ライブラリは JSON スキーマを導き出します。 引数のデコード、バリデーション、およびワイヤプロトコルは、 stdio または Claude コード、Codex、Claude デスクトップ、Cursor および任意の HTTP を Streamable その他のMCPクライアント。
つまり、MCP サーバが 2 つのツールを公開しているのは完了です。 [current_weather]
そして、コンストラクタのフィールドから派生するJSONスキーマを持つforecast。
無料で入手できるもの
派生はタイプを読みますので、ワイヤのスキーマは常にマッチします
引数を受け取るハンドラ。 このコンストラクタを
[examples/Complete]:
[[tools/list] はこれを正確に返します(実行例から呼び出されます。)
記述のない分野はその名前によって記述されます:
マッチする引数を持つ tools/call は、ハンドラに完全に到着します
Checkout Express (Address "1 Main St" "Springfield" Nothing) をデコードしました。
Malformed 引数は決して到達しません。ライブラリは適切な引数で応答します。
JSON-RPC エラー。 同一の機械はタイプされた結果のための逆で働きます(参照して下さい
構造化された出力).
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
mcp-server
Build Model Context Protocol servers in Haskell from plain data types. Declare your tools, prompts and resources as ADTs, write one handler per type, and the library derives the JSON schemas, argument decoding, validation and wire protocol for you — then serves it over stdio or Streamable HTTP to Claude Code, Codex, Claude Desktop, Cursor and any other MCP client.
{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
import Data.Text (Text)
import MCP.Server
import MCP.Server.Derive
data Units = Celsius | Fahrenheit
data WeatherTool
= CurrentWeather { city :: Text, units :: Maybe Units }
| Forecast { city :: Text, days :: Int }
handleTool :: ClientContext -> WeatherTool -> IO Content
handleTool _ (CurrentWeather c _) = pure $ ContentText $ "Sunny in " <> c
handleTool _ (Forecast c n) = pure $ ContentText $ "Forecast for " <> c
$(pure []) -- end the declaration group so the splice below can see the types
main :: IO ()
main = runMcpServerStdio serverInfo noHandlers
{ tools = Just $(deriveToolHandler ''WeatherTool 'handleTool) }
where
serverInfo = McpServerInfo
{ serverName = "weather", serverVersion = "1.0.0"
, serverInstructions = "Weather lookups" }
That is a complete, working MCP server exposing two tools, current_weather
and forecast, each with a JSON schema derived from its constructor’s fields.
What you get for free
The derivation reads your types, so the schema on the wire always matches the
handler that receives the arguments. Given this constructor from
examples/Complete:
data ShippingSpeed = Standard | Express | Overnight
data Address = Address
{ street :: Text
, city :: Text
, zipCode :: Maybe Text
}
data MyTool
= Checkout { speed :: ShippingSpeed, shipTo :: Address }
| ...
tools/list returns exactly this (captured from the running example; a
field without a description is described by its name):
{
"name": "checkout",
"description": "Checkout",
"annotations": { "destructiveHint": true },
"inputSchema": {
"type": "object",
"required": ["speed", "shipTo"],
"properties": {
"speed": { "type": "string", "enum": ["standard", "express", "overnight"],
"description": "speed" },
"shipTo": {
"type": "object",
"description": "shipTo",
"required": ["street", "city"],
"properties": {
"street": { "type": "string", "description": "street" },
"city": { "type": "string", "description": "city" },
インストール
docker run -i --entrypoint=/usr/local/bin/simple-example haskell-mcp-server設定
{
"mcpServers": {
"my-server": {
"type": "stdio",
"command": "/path/to/my-server",
"env": { "API_KEY": "${API_KEY}" }
}
}
}