Skip to main content
Glama
Local Workspace Orchestrator

Local Workspace Orchestrator

ローカルワークスペースオーケストレーター

MCP (Model Context Protocol) クライアント・サーバーシステムで、Anthropic Claude を一連のワークスペースツールを通じてローカルファイルシステムに接続します。このオーケストレーターにより、Claude はファイルの読み取り、CSV の分析、スクリプトの実行、プロットの生成など、すべてをインタラクティブなチャットインターフェースから実行できます。

アーキテクチャ

┌───────────────────────────┐        stdio         ┌──────────────────────────┐
│  orchestrator_client.py   │ ◄──────────────────► │  workspace_server.py     │
│  (MCP Client + Anthropic) │     MCP protocol     │  (FastMCP Server)        │
│                           │                      │                          │
│  • Connects to 1+ servers │                      │  Tools:                  │
│  • Streams Claude output  │                      │   • list_workspace_files │
│  • Retries failed calls   │                      │   • summarize_csv_dataset│
│  • Saves chat history     │                      │   • execute_python_script│
│                           │                      │   • write_file           │
│                           │                      │   • run_shell_command    │
│                           │                      │   • plot_column_distrib. │
│                           │                      │                          │
│                           │                      │  Resources:              │
│                           │                      │   • workspace://files    │
│                           │                      │   • workspace://schema/* │
└───────────────────────────┘                      └──────────────────────────┘

Related MCP server: ai-distiller-mcp

クイックスタート

1. クローンとインストール

git clone <your-repo-url>
cd local-workspace-orchestrator

# Using uv (recommended)
uv sync

# Or using pip
pip install -r requirements.txt

2. API キーの設定

cp .env.example .env
# Edit .env and paste your Anthropic API key

3. オーケストレーターの実行

# Using uv
uv run orchestrator_client.py

# Or directly
python orchestrator_client.py

インタラクティブプロンプトが表示されます:

======================================================
   Local Workspace Orchestrator Active
   Type queries, or /help for commands, 'quit' to exit.
======================================================

Orchestrator >

4. クエリを試す

Orchestrator > list all files in this workspace
Orchestrator > summarize the sample_consumer.csv dataset
Orchestrator > plot the distribution of SpendingScore in sample_consumer.csv
Orchestrator > run the run_analysis.py script

サーバー設定

オーケストレーターは server_config.json を読み取り、起動する MCP サーバーを決定します。形式は標準の MCP mcpServers 構造を使用します:

{
  "mcpServers": {
    "workspace_orchestrator": {
      "command": "uv",
      "args": ["run", "workspace_server.py"]
    }
  }
}

サーバーの追加

複数のサーバーを接続できます。各サーバーのツールは自動的に検出され登録されます:

{
  "mcpServers": {
    "workspace_orchestrator": {
      "command": "uv",
      "args": ["run", "workspace_server.py"]
    },
    "my_other_server": {
      "command": "python",
      "args": ["other_server.py"]
    }
  }
}

チャットコマンド

コマンド

説明

/tools

サーバーごとに登録済みの全ツールを一覧表示

/save [filename]

会話履歴を JSON ファイルに保存

/load [filename]

保存された会話を読み込み

/reconnect <server>

切断されたサーバーに再接続

/history

会話メッセージ数を表示

/clear

会話履歴をクリア

/help

利用可能な全コマンドを表示

quit

オーケストレーターを終了

利用可能なツール

読み取り専用ツール

ツール

説明

list_workspace_files

ワークスペースパス内のファイルとサブディレクトリを一覧表示

summarize_csv_dataset

CSV の形状、列、dtypes、要約統計量を返す

run_shell_command

許可リストに登録されたシェルコマンド(ls、cat、grep など)を実行

破壊的ツール

ツール

説明

write_file

ワークスペース内のファイルを作成または上書き

execute_python_script

Python スクリプトを実行し、stdout/stderr を返す

plot_column_distribution

CSV 列のヒストグラム PNG を生成

リソース

URI

説明

workspace://files

ワークスペースルート内の全ファイルを一覧表示

workspace://schema/{file_name}

CSV ファイルの列名と dtypes

セキュリティ

  • パストラバーサル対策:ファイルを受け取るすべてのツールは、os.path.realpath() + pathlib.Path.resolve() を使用してパスを検証し、ディレクトリトラバーサル攻撃を防ぎます。

  • シェルコマンドの許可リスト:run_shell_command は、厳選された読み取り専用コマンド(ls、cat、grep、head、tail など)のみを許可します。

  • スクリプトのサンドボックス化:execute_python_script は、30 秒のタイムアウト付きでサブプロセス内でスクリプトを実行し、cwd を介してワークスペースディレクトリに制限します。注意:これは真のサンドボックスではありません。サブプロセスはサーバープロセスと同じ OS 権限を持ちます。

  • ツールアノテーション:各ツールには readOnlyHint / destructiveHint アノテーションが付与され、MCP クライアントが安全性を判断できるようにします。

CLI オプション

python orchestrator_client.py --help

options:
  --log-level {DEBUG,INFO,WARNING,ERROR}   Set logging verbosity (default: INFO)
  --system-prompt TEXT                     Custom system prompt for Claude
  --config PATH                            Path to server_config.json

環境変数

変数

説明

デフォルト

ANTHROPIC_API_KEY

Anthropic API キー(必須)

—

LOG_LEVEL

ログの詳細度

INFO

プロジェクト構造

local-workspace-orchestrator/
├── orchestrator_client.py    # MCP client + Anthropic integration
├── workspace_server.py       # FastMCP server with workspace tools
├── server_config.json        # MCP server connection configuration
├── main.py                   # Stub entry point
├── run_analysis.py           # Example analysis script
├── sample_consumer.csv       # Sample dataset
├── pyproject.toml            # Project metadata + dependencies
├── requirements.txt          # Pinned pip dependencies
├── .env.example              # API key template
├── .gitignore                # Git ignore rules
└── README.md                 # This file

ライセンス

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers