Skip to main content
Glama
Local Workspace Orchestrator

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

执行白名单中的 shell 命令(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() 验证路径,以防止目录遍历攻击。

  • Shell 命令白名单:run_shell_command 只允许一组精选的只读命令(ls、cat、grep、head、tail 等)。

  • 脚本沙箱:execute_python_script 在子进程中运行脚本,超时时间为 30 秒,并通过 cwd 将运行范围限制在工作区目录内。注意:这 不是 真正的沙箱——子进程拥有与服务器进程相同的操作系统权限。

  • 工具注解:每个工具都带有 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