Unified MCP Server
by mon50
README.md
# 統合MCPサーバー (Unified MCP Server)
複数のOSS MCPサーバーを統合して扱える統合サーバーです。
VSCode / Cursor / CLI環境でシームレスにMCPを利用できます。
## 🚀 クイックスタート
### 前提条件
- **Node.js 18以上**
- **yarn パッケージマネージャー**
### インストール
```bash
# リポジトリをクローン
git clone <repository-url>
cd unified_mcp_server
# 依存関係をインストール
yarn install
# TypeScriptをコンパイル
yarn build
```
### 起動
```bash
# 開発モードで起動(推奨)
yarn dev
```
初回起動時に必要なMCPのインストール確認が表示されます:
```
🔍 MCP依存関係をチェックしています...
⚠️ 4個のMCPがインストールされていません:
• Playwright MCP (@playwright/mcp)
• Browser MCP (@browsermcp/mcp)
• Context7 MCP (@upstash/context7-mcp)
• Sequential Thinking MCP (@modelcontextprotocol/server-sequential-thinking)
不足しているMCPをすべてインストールしますか? (Y/n)
```
## 📋 利用可能なコマンド
### 基本コマンド
```bash
yarn dev # 開発モードでサーバー起動
yarn start # 本番モードでサーバー起動(要build)
yarn build # TypeScriptをコンパイル
yarn watch # ファイル変更を監視してコンパイル
yarn clean # ビルド済みファイルを削除
```
### ユーティリティコマンド
```bash
yarn health # サーバーのヘルスチェック
yarn install-mcps # MCPを手動でインストール
yarn dev --help # ヘルプを表示
```
## 🌐 エンドポイント
サーバー起動後、以下のエンドポイントが利用可能になります:
### HTTP API
- **`http://localhost:5001`** - メインエンドポイント
- **`http://localhost:5001/health`** - ヘルスチェック
- **`http://localhost:5001/mcps`** - MCP一覧とステータス・機能詳細
- **`http://localhost:5001/mcps/:name`** - 特定MCP詳細情報
- **`http://localhost:5001/rpc`** - JSON-RPC over HTTP
- **`http://localhost:5001/prompt-guide`** - プロンプト最適化ガイド
- **`POST http://localhost:5001/suggest-mcp`** - プロンプト解析・MCP推奨
### WebSocket
- **`ws://localhost:5001`** - JSON-RPC over WebSocket
- リアルタイムステータス更新(30秒間隔)
## 💻 Cursor/VSCode連携
### 自動設定
サーバー起動時に `.cursor/mcp_config.json` が自動生成されます:
```json
{
"mcpServers": {
"unified-mcp": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"UNIFIED_MCP_PORT": "5001",
"UNIFIED_MCP_HOST": "localhost"
}
}
}
}
```
### 手動設定
Cursorの設定に以下を追加:
```json
{
"mcp": {
"servers": {
"unified-mcp": {
"command": "node",
"args": ["/path/to/unified_mcp_server/dist/index.js"]
}
}
}
}
```
## 📦 対応MCP
### デフォルトMCP
- **Playwright MCP** - ブラウザ自動化・テスト
- パッケージ: `@playwright/mcp`
- GitHub: [playwright-mcp](https://github.com/microsoft/playwright-mcp)
- **Browser MCP** - ブラウザ操作・ナビゲーション
- パッケージ: `@browsermcp/mcp`
- GitHub: [browsermcp](https://github.com/browsermcp/mcp)
- **Context7 MCP** - コンテキスト管理・メモリ
- パッケージ: `@upstash/context7-mcp`
- GitHub: [context7-mcp](https://github.com/upstash/context7-mcp)
- **Sequential Thinking MCP** - 論理的思考プロセス
- パッケージ: `@modelcontextprotocol/server-sequential-thinking`
- GitHub: [server-sequential-thinking](https://github.com/modelcontextprotocol/server-sequential-thinking)
### 利用可能なMCP(無効化済み)
- **Figma MCP** - デザインファイルアクセス
- **Serena MCP** - クエリ処理機能
### MCPの追加方法
1. `src/config/mcps.ts` に新しいMCP定義を追加:
```typescript
newmcp: {
name: 'newmcp',
displayName: 'New MCP Server',
npmPackage: '@org/mcp-server-package',
githubRepo: 'https://github.com/org/mcp-server',
command: ['npx', '@org/mcp-server-package'],
protocol: 'stdio',
enabled: true
}
```
2. サーバーを再起動すると自動でインストール確認されます
## 🎯 プロンプト最適化
### MCP自動選択を改善するプロンプトのコツ
統合MCPサーバーは、プロンプト内容を解析して最適なMCPを自動選択します。
**効果的なプロンプト例:**
```text
# Playwright MCP が選択される
"PlaywrightでGoogleのスクリーンショットを撮影してください"
# Browser MCP が選択される
"このWebサイトのコンテンツを抽出してください"
# Context7 MCP が選択される
"この会話の内容をコンテキストに保存してください"
# Sequential Thinking MCP が選択される
"この問題を段階的に分析してください"
```
### プロンプト推奨API
最適なMCPを事前に確認:
```bash
curl -X POST http://localhost:5001/suggest-mcp \
-H "Content-Type: application/json" \
-d '{"prompt": "ブラウザでテストを実行してください"}'
```
### プロンプトガイド取得
```bash
curl http://localhost:5001/prompt-guide
```
詳細なプロンプト最適化については `MCP_PROMPT_GUIDE.md` を参照してください。
## 🔧 設定
### 環境変数
```bash
UNIFIED_MCP_PORT=5001 # サーバーポート(デフォルト: 5001)
UNIFIED_MCP_HOST=localhost # サーバーホスト(デフォルト: localhost)
LOG_LEVEL=info # ログレベル(debug, info, warn, error)
INSTALL_TIMEOUT=300000 # インストールタイムアウト(ms)
MCP_START_TIMEOUT=30000 # MCP起動タイムアウト(ms)
```
### 設定ファイル
- **`.unified_mcp_install_status.json`** - インストール状況(自動生成)
- **`.cursor/mcp_config.json`** - Cursor設定(自動生成)
- **`unified_mcp.log`** - 実行ログ
## 📊 レスポンス形式
すべてのMCPレスポンスにメタデータが自動付加されます:
```json
{
"jsonrpc": "2.0",
"id": "request-id",
"result": {
// 元のMCPレスポンス
},
"_meta": {
"source": "figma",
"githubRepo": "https://github.com/modelcontextprotocol/server-figma",
"timestamp": "2024-01-15T10:30:00.000Z"
}
}
```
## 🔍 トラブルシューティング
### よくある問題
**Q: MCPがインストールされない**
```bash
# npmのグローバル設定を確認
npm config get prefix
# 手動でMCPをインストール
npm install -g @playwright/mcp
npm install -g @browsermcp/mcp
npm install -g @upstash/context7-mcp
npm install -g @modelcontextprotocol/server-sequential-thinking
```
**Q: サーバーが起動しない**
```bash
# ポートが使用中かチェック
lsof -i :5001
# ログを確認
tail -f unified_mcp.log
```
**Q: MCPサーバーが応答しない**
```bash
# ヘルスチェックを実行
yarn health
# 手動でMCPプロセスを確認
ps aux | grep @modelcontextprotocol
```
### デバッグモード
```bash
# デバッグログ有効化
LOG_LEVEL=debug yarn dev
```
## 🤝 開発・カスタマイズ
### ディレクトリ構成
```
src/
├── index.ts # メインエントリーポイント
├── mcp/
│ ├── manager.ts # MCPプロセス管理
│ ├── proxy.ts # 統合プロキシサーバー
│ └── installer.ts # 自動インストーラー
├── config/
│ ├── mcps.ts # MCP設定定義
│ └── server.ts # サーバー設定
├── utils/
│ ├── logger.ts # ログ機能
│ └── config-generator.ts # 設定ファイル生成
└── types/
└── mcp.ts # 型定義
```
### 開発用コマンド
```bash
yarn watch # ファイル変更監視
yarn clean && yarn build # クリーンビルド
yarn dev --help # オプション確認
```
## 📄 ライセンス
MIT License
## 🔗 関連リンク
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [MCP Servers Repository](https://github.com/modelcontextprotocol)
- [Cursor IDE](https://cursor.ai/)
- [VSCode](https://code.visualstudio.com/)
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues