Skip to main content

MCP Server for ASAM MDF file analysis

Project description

MDF MCP Server

A Model Context Protocol (MCP) server for analyzing ASAM MDF (Measurement Data Format) files. Enables AI assistants to access and analyze automotive and industrial measurement data.

๐Ÿš€ Quick Start

Using uvx (Recommended)

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run the server directly
uvx mcp-server-mdf

Local Development

# Clone and setup
git clone https://github.com/Shanko-26/mdfmcp
cd mdfmcp

# Install in virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .

# Run the server
mcp-server-mdf

๐Ÿ“‹ Features

  • MDF File Support: Versions 2.x, 3.x, and 4.x
  • AI-Native Interface: Designed for LLM integration
  • Data Analysis: Statistics, plotting, signal processing
  • Format Export: CSV, HDF5, Parquet, MATLAB
  • Session Management: Multi-file support
  • High Performance: Efficient large file handling

๐Ÿ”ง Configuration

Important: This MCP server requires direct file system access to read MDF files. It works best with IDEs that support local file operations.

Compatible IDEs

For VS Code with Continue.dev

Add to your MCP configuration:

{
  "mcpServers": {
    "mdf": {
      "command": "uvx",
      "args": ["mcp-server-mdf"]
    }
  }
}

For Cursor IDE

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "mdf": {
      "command": "uvx",
      "args": ["mcp-server-mdf"]
    }
  }
}

For Windsurf/Codeium

Follow your IDE's MCP configuration guide with the same uvx command.

Troubleshooting uvx Path Issues

If you get "command not found" errors, find your uvx path:

which uvx  # On macOS/Linux  
where uvx  # On Windows

Then use the full path in your configuration:

{
  "mcpServers": {
    "mdf": {
      "command": "/Users/username/.local/bin/uvx",
      "args": ["mcp-server-mdf"]
    }
  }
}

๐Ÿ“ File Organization

Smart Workspace Search: The server automatically finds MDF files in your project:

your-project/
โ”œโ”€โ”€ data.mf4              # โœ… Found by filename
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ test.mf4          # โœ… Found in data/ folder
โ”œโ”€โ”€ measurements/
โ”‚   โ””โ”€โ”€ run1.mf4          # โœ… Found in measurements/ folder
โ”œโ”€โ”€ test_data/
โ”œโ”€โ”€ examples/
โ””โ”€โ”€ samples/

Usage Examples:

  • "data.mf4" โ†’ Searches workspace automatically
  • "./data/test.mf4" โ†’ Relative path from current directory
  • "/absolute/path/file.mf4" โ†’ Full absolute path
  • Case insensitive: "DATA.MF4" finds "data.mf4"

๐Ÿ“Š Usage Examples

Open and Analyze MDF Files

User: Open the measurement file at /data/test_drive.mf4
Assistant: I'll open that MDF file for you.

[Opens file]
Successfully opened test_drive.mf4:
- Session ID: mdf_a3b2c1d4
- Version: 4.10
- Channels: 847
- Duration: 1823.4 seconds

List and Search Channels

User: What temperature channels are available?
Assistant: Let me search for temperature-related channels.

Found 23 temperature channels:
- Engine_Temp (ยฐC) - Engine coolant temperature
- Oil_Temp (ยฐC) - Engine oil temperature
- Ambient_Temp (ยฐC) - Outside air temperature

Analyze and Plot Signals

User: Show me the engine speed statistics and plot it
Assistant: I'll analyze the engine speed signal.

Engine Speed Analysis:
- Mean: 2,847 RPM
- Max: 6,234 RPM
- Std Dev: 1,123 RPM

[Shows time-series plot of engine speed]

๐Ÿ› ๏ธ Available Tools

Session Management

  • open_mdf - Open an MDF file
  • close_mdf - Close a session
  • list_sessions - Show active sessions
  • get_file_info - Get file metadata

Data Access

  • list_channels - List available channels
  • mdf_get - Extract single channel data
  • mdf_select - Extract multiple channels
  • mdf_get_master - Get time channel data

Analysis

  • calculate_statistics - Compute signal statistics
  • plot_signals - Create visualizations
  • mdf_to_dataframe - Convert to pandas DataFrame

Data Manipulation

  • mdf_cut - Extract time slice
  • mdf_filter - Filter specific channels
  • mdf_resample - Change sampling rate

Export

  • mdf_export - Export to various formats
  • mdf_convert - Convert between MDF versions
  • mdf_save - Save modified file

๐Ÿณ Docker Deployment (Alternative)

Build Image

docker build -t mcp-server-mdf .

Run Container

# Basic run
docker run -it --rm mcp-server-mdf

# With volume mount for data
docker run -it --rm -v /path/to/mdf/files:/data mcp-server-mdf

# With custom environment
docker run -it --rm -e MAX_SESSIONS=20 mcp-server-mdf

MCP Configuration for Docker

{
  "mcpServers": {
    "mdf": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-v", "/path/to/data:/data", "mcp-server-mdf"]
    }
  }
}

๐Ÿงช Testing

# Run tests
pytest tests/

# Test server manually
python tests/manual_test.py

๐Ÿ“ Project Structure

mdfmcp/
โ”œโ”€โ”€ src/mdfmcp/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ server.py          # Main MCP server
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ conftest.py
โ”‚   โ”œโ”€โ”€ manual_test.py
โ”‚   โ””โ”€โ”€ test_server.py
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ basic_usage.py
โ”‚   โ””โ”€โ”€ test_data_generator.py
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

๐Ÿ”ง Development

Setup Development Environment

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install in development mode
pip install -e .

Code Quality

# Format code
black src/

# Lint
ruff src/

# Type checking
mypy src/

๐Ÿšจ Troubleshooting

Common Issues

  1. Memory errors with large files

    • Use memory="low" when opening files
    • Reduce concurrent sessions
  2. Cannot find channels

    • Channel names are case-sensitive
    • Use regex patterns for flexible searching
  3. Docker build fails

    • Ensure Docker is running
    • Check Dockerfile syntax

๐Ÿ™ Acknowledgments

  • Built on asammdf by Daniel Hrisca (LGPL v3+)
  • Uses the Model Context Protocol by Anthropic
  • Matplotlib for plotting capabilities
  • Pandas and NumPy for data processing

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies: This project uses asammdf which is licensed under LGPL v3+. The asammdf library remains a separate component and is not modified by this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_mdf-0.1.2.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_mdf-0.1.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_mdf-0.1.2.tar.gz.

File metadata

  • Download URL: mcp_server_mdf-0.1.2.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for mcp_server_mdf-0.1.2.tar.gz
Algorithm Hash digest
SHA256 072c1a906757fa9332ef7e7e1ae2dfa291e9aabc0e32e5298d7f6e3588723636
MD5 e6e1d38d766f0ec5dacceb3d9b6f8cb4
BLAKE2b-256 be4478737fdc0d0cf7e4ad921684be80179d9e37c8d916021fcb4f6265849ac6

See more details on using hashes here.

File details

Details for the file mcp_server_mdf-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mcp_server_mdf-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for mcp_server_mdf-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 441ba3d918821560623a71c5e58d2b06c8501364556c8cd421d8cd383bc58d85
MD5 42451e3e3db8b6c5e71eec7c1d33999b
BLAKE2b-256 34cdb4678b80341c800d9e45e0f4bfdee2ac7c9d817e7e4d849b25fbe1daa5bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page