Linstor存储系统MCP服务器

Linstor MCP服务器是一个用于Linstor存储系统的模型上下文协议服务器,通过REST API与Linstor集群交互,支持AI助手和其他MCP客户端查询和管理存储资源。

  • by moandersson
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 moandersson/mcp-linstor

使用说明

Linstor MCP 服务器

一个模型上下文协议(MCP)服务器用于 Linstor(通常指的是一种用于容器编排和存储管理的系统或工具,具体名称可能根据上下文有所不同,但直接翻译即为“林斯托尔”) 存储系统。该服务器提供MCP工具,可通过其REST API与Linstor集群进行交互,使AI助手和其他MCP客户端能够查询和管理Linstor存储资源。

特点/特性

  • MCP标准合规性实现了MCP规范,使用 FastMCP
  • 可流式传输的HTTP传输使用可流式传输的HTTP传输以实现高效通信
  • 工具:
    • pingLinstor API可用性的健康检查
    • list_resources查询存储系统中的所有卷资源
    • list_nodes查询 Linstor 集群中的所有节点
  • 基于环境的配置通过环境变量进行配置

建筑学

该项目的设计兼顾了可维护性和可测试性:

mcp-linstor/
├── server.py              # Main MCP server with FastMCP
├── config.py              # Configuration management
├── linstor_client.py      # Linstor REST API client
├── requirements.txt       # Production dependencies
├── requirements-dev.txt   # Development dependencies
└── tests/                 # Comprehensive test suite
    ├── test_config.py
    ├── test_linstor_client.py
    └── test_server.py

安装

先决条件

  • Python 3.10 或更高版本
  • 访问启用了REST API的Linstor集群

设置

  1. 克隆或导航到项目目录:

    cd /path/to/mcp-linstor
    
  2. 创建并激活虚拟环境:

    python3 -m venv venv
    source venv/bin/activate  # On macOS/Linux
    # or
    venv\Scripts\activate  # On Windows
    
  3. 安装依赖项:

    pip install -r requirements.txt
    
  4. 用于开发(包括测试工具):

    pip install -r requirements-dev.txt
    

配置

使用环境变量配置服务器:

变量 描述 默认值
LINSTOR_BASE_URL Linstor REST API的基准URL http://localhost:3370
LINSTOR_TIMEOUT 请求超时时间(秒) 30
LINSTOR_DEBUG 启用调试日志记录 false
LINSTOR_USERNAME 可选:用于认证的用户名 无
LINSTOR_PASSWORD 可选:用于身份验证的密码 无

示例配置

export LINSTOR_BASE_URL="http://linstor-controller.example.com:3370"
export LINSTOR_TIMEOUT="60"
export LINSTOR_DEBUG="true"

或者创建一个 .env 文件:

LINSTOR_BASE_URL=http://linstor-controller.example.com:3370
LINSTOR_TIMEOUT=60
LINSTOR_DEBUG=true
LINSTOR_USERNAME=admin
LINSTOR_PASSWORD=secret

用法

运行服务器

# Activate virtual environment
source venv/bin/activate

# Run the server
python server.py

服务器将在默认的MCP流式HTTP传输上启动,并准备好接受MCP客户端的连接。

MCP规范

此服务器实现了工具的模型上下文协议规范:

  • 工具/列表列出可用工具(ping,list_resources,list_nodes)
  • 工具/调用执行带有给定参数的工具
  • 工具/结果返回工具执行结果

服务器使用:

  • 交通可流式传输的HTTP(无状态,使用JSON响应)
  • FastMCP从官方Python SDK简化实现的MCP服务器

参考文献