Skip to content

moandersson/mcp-linstor

Repository files navigation

Linstor MCP Server

A Model Context Protocol (MCP) server for Linstor storage system. This server provides MCP tools to interact with a Linstor cluster via its REST API, enabling AI assistants and other MCP clients to query and manage Linstor storage resources.

Features

  • MCP Standard Compliance: Implements the MCP specification using FastMCP
  • Streamable HTTP Transport: Uses streamable-http transport for efficient communication
  • Tools:
    • ping: Health check for Linstor API availability
    • list_resources: Query all volume resources in the storage system
    • list_nodes: Query all nodes in the Linstor cluster
  • Environment-based Configuration: Configuration via environment variables

Architecture

The project is structured for maintainability and testability:

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

Installation

Prerequisites

  • Python 3.10 or higher
  • Access to a Linstor cluster with REST API enabled

Setup

  1. Clone or navigate to the project directory:

    cd /path/to/mcp-linstor
  2. Create and activate a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On macOS/Linux
    # or
    venv\Scripts\activate  # On Windows
  3. Install dependencies:

    pip install -r requirements.txt
  4. For development (includes testing tools):

    pip install -r requirements-dev.txt

Configuration

Configure the server using environment variables:

Variable Description Default
LINSTOR_BASE_URL Base URL of the Linstor REST API http://localhost:3370
LINSTOR_TIMEOUT Request timeout in seconds 30
LINSTOR_DEBUG Enable debug logging false
LINSTOR_USERNAME Optional: Username for authentication None
LINSTOR_PASSWORD Optional: Password for authentication None

Example Configuration

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

Or create a .env file:

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

Usage

Running the Server

# Activate virtual environment
source venv/bin/activate

# Run the server
python server.py

The server will start on the default MCP streamable-http transport and will be ready to accept MCP client connections.

MCP Specification

This server implements the Model Context Protocol specification for tools:

  • tool/list: Lists available tools (ping, list_resources, list_nodes)
  • tool/call: Executes a tool with given parameters
  • tool/results: Returns tool execution results

The server uses:

  • Transport: streamable-http (stateless with JSON responses)
  • FastMCP: Simplified MCP server implementation from the official Python SDK

References

About

MCP Server for Linstor (Linbit) storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages