data-mcp

patrickoleary/data-mcp

3.3

If you are the rightful owner of data-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Data MCP Server is a Model Context Protocol server designed for scientific data introspection and visualization, offering comprehensive analysis of VTK datasets with format-specific metadata extraction and interactive 3D visualization.

Tools
10
Resources
0
Prompts
0

Data MCP Server

A Model Context Protocol (MCP) server for scientific data introspection and visualization. Provides comprehensive analysis of VTK datasets with format-specific metadata extraction and interactive 3D visualization.

โœจ Features

  • 10 MCP Tools for complete dataset analysis
  • Format-Adaptive Metadata - Specialized handlers for VTI, VTU, VTP formats
  • Interactive 3D Visualization using Trame/VTK
  • Memory-Efficient Architecture with automatic cleanup
  • Comprehensive Component Analysis with detailed statistics

๐Ÿš€ Quick Start

1. Setup Environment

# Clone or navigate to the project directory
cd data-mcp

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On macOS/Linux
# .venv\Scripts\activate   # On Windows

# Install dependencies
pip install -r requirements.txt
pip install -e .

2. Run Basic Demo

# Test MCP server functionality
python examples/walkthrough/demo_mcp_usage.py

3. Sample Data

Pre-generated VTK files in examples/sample_data/:

  • gaussian_simple.vti - 3D structured grid (20ร—15ร—12)
  • wave_pattern.vti - Wave pattern data

4. Interactive Visualization

# Launch 3D viewer (opens at localhost:8080)
python -c "
from src.data_mcp.viewers.vtk_viewer import VTKViewer
VTKViewer.show_file('examples/sample_data/gaussian_simple.vti')
"

5. Start MCP Server

# Start the MCP server (requires MCP client to connect)
python -m data_mcp.server

๐Ÿ”Œ MCP Client Configuration

Connecting MCP Clients

Use the provided mcp_client_config.json to connect MCP-compatible clients:

{
  "mcpServers": {
    "data-mcp": {
      "command": "python",
      "args": ["-m", "data_mcp.server"],
      "cwd": "/Users/patrick.oleary/code/AI Experiments/data-mcp",
      "env": {}
    }
  }
}

Supported MCP Clients

  • Claude Desktop - Anthropic's desktop application
  • Custom MCP applications - Built with MCP client libraries
  • Development tools - IDEs and testing frameworks with MCP support

Integration Steps

  1. Copy the config to your MCP client's configuration directory
  2. Update the cwd path to match your project location
  3. Restart your MCP client to register the server
  4. Access via client - The server will appear as "data-mcp" with 10 available tools

๐Ÿงช Testing & Examples

Comprehensive Walkthrough

# Test all 10 MCP tools with detailed output
python examples/walkthrough/manual_tool_test.py

# Test format-specific metadata adaptation
python examples/walkthrough/test_format_adaptation.py

Integration Tests

# Full MCP workflow testing
python tests/integration/test_full_mcp_workflow.py

# Real MCP client connection test
python tests/integration/test_real_mcp_client.py

๐ŸŽฏ Available MCP Tools

  • upload_dataset - Load and register dataset files
  • list_datasets - Show all loaded datasets
  • query_dataset - Get comprehensive dataset information
  • get_schema - Extract detailed schema information
  • list_components - Show available data arrays/components
  • get_component_info - Get detailed component information
  • get_statistics - Calculate statistics for components
  • visualize_dataset - Launch interactive 3D viewer
  • suggest_visualizations - Get visualization recommendations
  • remove_dataset - Remove dataset from memory

๐Ÿ“‹ Usage Examples

Programmatic Usage

from data_mcp.formats.vtk_factory import VTKHandlerFactory
from data_mcp.core.dataset import Dataset
from data_mcp.viewers.vtk_viewer import VTKViewer

# Load dataset with format-specific handler
handler = VTKHandlerFactory.create_handler("path/to/file.vti")
dataset = Dataset("path/to/file.vti", handler)
dataset.introspect()

# Get comprehensive information
info = dataset.get_info()
components = dataset.list_components()
stats = dataset.get_statistics("temperature")

# Launch interactive viewer (convenience method)
VTKViewer.show_file("path/to/file.vti")  # Opens at localhost:8080

# Or create viewer with dataset
viewer = VTKViewer(dataset=dataset)
viewer.show()

MCP Client Usage

Connect via MCP client and use these tools:

  • Upload datasets, query metadata, analyze components
  • Get format-specific information (VTI/VTU/VTP)
  • Launch interactive 3D visualizations
  • Calculate detailed statistics

๐Ÿ—๏ธ Architecture

Format Handler Inheritance System

  • BaseVTKHandler - Common VTK functionality
  • VTKImageDataHandler (.vti) - Structured grids with spacing/dimensions
  • VTKUnstructuredGridHandler (.vtu) - Irregular meshes with cell analysis
  • VTKPolyDataHandler (.vtp) - Surface meshes with topology analysis
  • VTKHandlerFactory - Automatic handler selection by file extension

Supported Formats

Currently supports VTK formats with format-specific metadata:

  • .vti - ImageData (regular grids, voxel data)
  • .vtu - UnstructuredGrid (irregular meshes, FEM data)
  • .vtp - PolyData (surface meshes, CAD data)

Memory Management

  • Automatic cleanup after dataset introspection
  • Stored component data for efficient access
  • Handler recycling to prevent memory bloat

๐Ÿ“ Project Structure

data-mcp/
โ”œโ”€โ”€ README.md                    # Project documentation
โ”œโ”€โ”€ MCP_WALKTHROUGH.md          # Comprehensive walkthrough guide
โ”œโ”€โ”€ pyproject.toml              # Python packaging configuration
โ”œโ”€โ”€ requirements.txt            # Dependencies
โ”œโ”€โ”€ src/data_mcp/              # Main package
โ”‚   โ”œโ”€โ”€ server.py              # MCP server implementation
โ”‚   โ”œโ”€โ”€ core/                  # Core functionality
โ”‚   โ”‚   โ”œโ”€โ”€ dataset.py         # Dataset abstraction with cleanup
โ”‚   โ”‚   โ”œโ”€โ”€ introspector.py    # Dataset analysis engine
โ”‚   โ”‚   โ”œโ”€โ”€ schema.py          # Schema representation
โ”‚   โ”‚   โ””โ”€โ”€ visualizer.py      # Visualization engine
โ”‚   โ”œโ”€โ”€ formats/               # Format handlers (inheritance system)
โ”‚   โ”‚   โ”œโ”€โ”€ base.py           # Base format handler interface
โ”‚   โ”‚   โ”œโ”€โ”€ vtk_base.py       # Base VTK handler
โ”‚   โ”‚   โ”œโ”€โ”€ vtk_imagedata.py  # VTI handler (structured grids)
โ”‚   โ”‚   โ”œโ”€โ”€ vtk_unstructured.py # VTU handler (irregular meshes)
โ”‚   โ”‚   โ”œโ”€โ”€ vtk_polydata.py   # VTP handler (surface meshes)
โ”‚   โ”‚   โ””โ”€โ”€ vtk_factory.py    # Handler factory
โ”‚   โ”œโ”€โ”€ viewers/               # Trame-based visualization
โ”‚   โ”‚   โ””โ”€โ”€ vtk_viewer.py     # VTK 3D viewer
โ”‚   โ””โ”€โ”€ utils/                 # Utilities
โ”‚       โ””โ”€โ”€ file_utils.py     # File handling
โ”œโ”€โ”€ examples/                  # Usage examples
โ”‚   โ”œโ”€โ”€ basic_usage.py        # Basic programmatic usage
โ”‚   โ”œโ”€โ”€ walkthrough/          # Walkthrough examples
โ”‚   โ”‚   โ”œโ”€โ”€ demo_mcp_usage.py # Basic MCP demo
โ”‚   โ”‚   โ”œโ”€โ”€ manual_tool_test.py # All 10 tools test
โ”‚   โ”‚   โ””โ”€โ”€ test_format_adaptation.py # Format adaptation demo
โ”‚   โ””โ”€โ”€ sample_data/          # Sample VTK files
โ”‚       โ”œโ”€โ”€ gaussian_simple.vti # 3D structured grid
โ”‚       โ””โ”€โ”€ wave_pattern.vti   # Wave pattern data
โ””โ”€โ”€ tests/                     # Test suite
    โ”œโ”€โ”€ integration/           # Integration tests
    โ””โ”€โ”€ test_formats/         # Format handler tests

๐Ÿ”ง Current Status

  • โœ… 10/10 MCP Tools Working (100% success rate)
  • โœ… Format-Adaptive Metadata for VTI/VTU/VTP files
  • โœ… Memory-Efficient Architecture with automatic cleanup
  • โœ… Interactive 3D Visualization via Trame/VTK
  • โœ… Production-Ready for scientific data workflows

๐Ÿ“š Documentation

  • - Complete step-by-step walkthrough
  • - Hands-on examples and demos
  • - Basic usage guide

๐Ÿค Contributing

This project demonstrates a production-ready MCP server with:

  • Format-adaptive metadata extraction
  • Memory-efficient architecture
  • Comprehensive testing suite
  • Interactive visualization capabilities

For extending to new formats, follow the inheritance pattern established in the VTK handlers.

๐Ÿ“„ License

MIT License - see LICENSE file for details.