Unison MCP Server
An MCP server for the Unison language, allowing AI assistants to interact with the Unison Codebase Manager (UCM).
unison-mcp-server
Unison言語のModel Context Protocol (MCP)サーバー実装です。AIアシスタントがUCM(Unison Codebase Manager)を操作できるようにします。
概要
このプロジェクトは、UnisonコードベースとやりとりするためのMCPインターフェースを提供し、AIアシスタントが以下の操作を実行できるようにします:
- 定義の検索
- コードの追加と更新
- Unison式の実行
- プロジェクトとブランチの管理
- 依存関係の分析
前提条件
1. Unisonのインストール
# macOS (Homebrew)
brew install unisonweb/unison/unison-language
# その他のOS
# https://www.unison-lang.org/install/ から最新版をダウンロード
2. Haskellのセットアップ
# Stack(Haskellビルドツール)のインストール
curl -sSL https://get.haskellstack.org/ | sh
# または
wget -qO- https://get.haskellstack.org/ | sh
セットアップ
1. リポジトリのクローン
git clone https://github.com/yourusername/unison-mcp-server.git
cd unison-mcp-server
2. ビルド
stack build
3. Claude Desktop への登録
手動設定
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) または対応するパスに以下を追加:
{
"mcpServers": {
"unison": {
"command": "/path/to/unison-mcp-server/.stack-work/install/.../bin/unison-mcp-server-exe",
"args": ["/path/to/your/unison/project"]
}
}
}
claude mcp add を使用(推奨)
# ビルドしたバイナリのパスを確認
stack path --local-install-root
# Claude MCP に追加
claude mcp add unison /path/to/binary/unison-mcp-server-exe /path/to/your/unison/project
使用方法
初期セットアップ
新しいUnisonプロジェクトを開始する場合:
# ターミナルで
cd /path/to/your/unison/project
ucm
# UCM内で
.myproject> project.create myproject
UCMとの連携
MCPサーバーと同じコードベースを使用してUCMを起動するには:
# MCPサーバーのディレクトリから起動
cd /path/to/unison-mcp-server
ucm
# または、どこからでも --codebase オプションを使用
ucm --codebase /path/to/unison-mcp-server/.unison
これにより、MCPサーバーと同じプロジェクト・ブランチにアクセスできます。
Claude での使用例
Claude Desktopで以下のようなプロンプトを使用:
unison mcp を使ってコードを書いてみて
実行デモ
以下は実際の使用例です:
-- 基本的な関数定義
id : a -> a
id x = x
-- リスト操作
head : [a] -> Optional a
head = cases
[] -> None
x +: _ -> Some x
-- 高階関数
map : (a -> b) -> [a] -> [b]
map f = cases
[] -> []
x +: xs -> f x +: map f xs
-- フィルター関数
filter : (a -> Boolean) -> [a] -> [a]
filter p = cases
[] -> []
x +: xs -> if p x then x +: filter p xs else filter p xs
アーキテクチャ
┌─────────────┐ JSON-RPC ┌──────────────┐
│ AI Assistant│ ←───────────────→ │ MCP Server │
└─────────────┘ └──────┬───────┘
│
v
┌─────────────┐
│ UCM │
└─────────────┘
利用可能なツール
MCPツールとして以下が利用可能です:
基本操作
mcp__unison__ucm_find- 定義の検索mcp__unison__ucm_add- 新しい定義の追加mcp__unison__ucm_run- Unison式の実行mcp__unison__ucm_view- 定義のソースコード表示mcp__unison__ucm_update- 既存定義の更新mcp__unison__ucm_ls- 名前空間の内容一覧mcp__unison__ucm_delete- 定義の削除mcp__unison__ucm_test- テストの実行(scratch.uがない場合は自動生成)mcp__unison__ucm_dependencies- 定義の依存関係表示
プロジェクト管理
mcp__unison__ucm_list_projects- プロジェクト一覧mcp__unison__ucm_switch_project- プロジェクトの切り替えmcp__unison__ucm_project_create- 新規プロジェクト作成mcp__unison__ucm_list_branches- ブランチ一覧mcp__unison__ucm_switch_branch- ブランチの切り替えmcp__unison__ucm_branch_create- 新規ブランチ作成mcp__unison__ucm_merge- ブランチのマージ
ライブラリ管理
mcp__unison__ucm_lib_install- ライブラリのインストール(例: @unison/base)mcp__unison__ucm_share_search- Unison Shareのライブラリ情報を表示(実際の検索は未対応)mcp__unison__ucm_share_install- Unison Shareから特定バージョンをインストール- インストール後:
mcp__unison__ucm_lsで "lib" を指定して確認 - 命名規則: @owner/library → lib.owner_library_version
汎用コマンド実行
mcp__unison__ucm_command- 任意のUCMコマンドを直接実行- 低レベルツール:使用前にコマンド構文と型要件を確認してください
- UCMからのエラーはそのまま返されます
- 例:
{"command": "pull", "args": ["@unison/base/main"]} - 例:
{"command": "fork", "args": ["testUuid", "myTests.uuid"]} - 将来追加されるUCMコマンドにも対応可能
ライブラリの使用例
-- baseライブラリをインストール後
use lib.unison_base_3_21_0
-- UUIDの生成
testUuid : '{IO, Exception} ()
testUuid = do
uuid = Uuid.parse "550e8400-e29b-41d4-a716-446655440000"
printLine (Uuid.toText uuid)
-- nanoidライブラリをインストール後
use lib.hojberg_nanoid_1_0_0
use lib.hojberg_nanoid_1_0_0.NanoId
-- NanoIDの生成
testNanoId : '{IO, Exception} ()
testNanoId = do
id = nanoid()
printLine (NanoId.toText id)
トラブルシューティング
UCMが見つからない場合
# PATHにUCMがあるか確認
which ucm
# なければPATHに追加
export PATH=$PATH:/path/to/unison/bin
ビルドエラーの場合
# 依存関係を更新
stack update
# クリーンビルド
stack clean
stack build
MCP接続エラーの場合
- バイナリパスが正しいか確認
- プロジェクトディレクトリが存在するか確認
- UCMが正常に動作するか確認
開発
プロジェクト構造:
src/Unison/MCP/Server.hs- MCPサーバーの実装src/Unison/MCP/Protocol.hs- MCPプロトコルの型定義src/Unison/MCP/Tools.hs- ツールの実装src/Unison/MCP/UCM.hs- UCM統合レイヤー
ライセンス
このプロジェクトはMITライセンスで公開されています。
Related Servers
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
Kafka MCP
A natural language interface to manage Apache Kafka operations.
MCP Agentic Development Platform
A comprehensive MCP development environment with interactive visualizations, multiple client interfaces, and advanced agentic capabilities.
gNMIBuddy
Retrieves essential network information from devices using gNMI and OpenConfig models.
MagicPod
A server for integrating with MagicPod, an AI-powered test automation platform.
Clappia
A Python-based server for programmatically managing Clappia applications, forms, and submissions via its API.
Remote MCP Server (Authless)
A simple, auth-less MCP server on Cloudflare Workers that provides the current time in the US Eastern timezone.
Remote MCP Server (Authless)
A remote MCP server for Cloudflare Workers, authless by default with optional token-based authentication.
Godot MCP Pro
Premium MCP server for Godot game engine with 84 AI-powered tools for scene editing, scripting, animation, tilemap, shader, input simulation, and runtime debugging.
Package Version Check
Returns the latest package / dependency / tool versions for Python, NPM, Go, Docker, Helm, etc.
Adobe After Effects MCP
An MCP server that allows AI assistants to interact with Adobe After Effects.