科学命令行自然语言接口

SciPilot通过模型上下文协议(MCP)为科学命令行工具提供自然语言接口,允许用户通过YAML定义工具,由LLM处理参数、文件路径和输出解析。

  • by grebenyyk
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 grebenyyk/scipilot

使用说明

SciPilot

通过模型上下文协议(MCP)为科学命令行工具提供自然语言界面。

SciPilot弥合了自然语言和科学CLI工具之间的差距。在YAML中定义一次工具,然后让LLM处理其余部分——参数、文件路径、输出解析、工作。适用于任何值得交流的命令行。

快速开始

git clone https://github.com/grebenyyk/scipilot
cd scipilot
pip install -e .
scipilot --tools-dir ./tools

用法

  1. 将工具描述符添加到 tools/ (参见 examples/raspa.yaml)
  2. 连接MCP客户端(克劳德桌面、VS代码等)
  3. 用自然语言提问:
    • “在298 K下对MIL-47进行氦气空隙率计算”
    • “比较昨天模拟的结果”

工具描述符格式

您编写了一个工具描述符-一个YAML文件,它告诉SciPilot:

•您的工具期望什么(输入、类型、默认值) •如何构建命令(模板) •在哪里可以找到输出(文件路径、正则表达式模式) SciPilot将这些作为MCP工具公开,任何LLM都可以调用。

tool:
  name: mytool
  binary: mytool
  
operations:
  - name: run_simulation
    description: "Run a simulation"
    inputs:
      - name: input_file
        type: file
        required: true
    outputs:
      - name: result
        path: "output.txt"
        extract_pattern: "Result: ([0-9.]+)"

看 examples/ 获取完整的工具描述符。

⚠️ 安全说明:工具YAML文件以完全shell权限执行。仅加载您信任并已审阅的工具描述符。用户输入直接替换到shell命令模板中。

项目结构

scipilot/
├── server.py          # MCP server entry point
├── tool_loader.py     # YAML parsing, tool discovery
├── executor.py        # Subprocess execution, output parsing
└── models.py          # Dataclasses for tool descriptors

tools/                 # Your tool descriptors (gitignored)
examples/              # Example descriptors

发展

# Run tests
pytest

# Type checking
mypy scipilot/

# Format
ruff format .

许可证

麻省理工学院